[dm-devel] Chunk size, mask and shift

Guilherme Moro guilherme.moro at gmail.com
Wed Aug 19 14:58:48 UTC 2009


hello,

Im trying to understand the dm-snapshot target, but Im not sure how it uses
the size, mask and shift of the chunks, not sure if I understand it
correctly.

Can anyone give an overall idea of why they are initialized this way

store->chunk_size = chunk_size_ulong;
store->chunk_mask = chunk_size_ulong - 1;
store->chunk_shift = ffs(chunk_size_ulong) - 1;

and why use this to translate sector to chunks

static inline chunk_t sector_to_chunk(struct dm_exception_store *store,
                      sector_t sector)
{
    return (sector & ~store->chunk_mask) >> store->chunk_shift;
}

thanks,

Guilherme Moro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/dm-devel/attachments/20090819/ea9cafdf/attachment.htm>


More information about the dm-devel mailing list