[sheepdog] [PATCH v2] cache: correct block size calculation for inode object
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Thu Aug 8 08:02:08 CEST 2013
>
> - /*
> - * CACHE_BLOCK_SIZE may not be divisible by SD_INODE_SIZE,
> - * so (offset + data_length) could larger than SD_INODE_SIZE
> - */
> + /* Handle last partial block for inode object */
> if (is_vdi_obj(oid) && (offset + data_length) > SD_INODE_SIZE)
> data_length = SD_INODE_SIZE - offset;
I think we can generalize this further to handle any kinds of objects.
if (offset + data_length > get_obj_size(oid))
data_length = get_obj_size(oid) - offset;
or
data_length = min(data_length, get_obj_size(oid) - offset);
Then, we can safely remove assert() from get_cache_block_size()
because this code works even if the cache block size for data objects
is not block-aligned.
Thanks,
Kazutaka
More information about the sheepdog
mailing list