Chunk size, mask and shift
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