Skip to content

Commit d2e174d

Browse files
Johannes Thumshirnkdave
authored andcommitted
btrfs: document extent mapping assumptions in checksum
Document why map_private_extent_buffer() cannot return '1' (i.e. the map spans two pages) for the csum_tree_block() case. The current algorithm for detecting a page boundary crossing in map_private_extent_buffer() will return a '1' *IFF* the extent buffer's offset in the page + the offset passed in by csum_tree_block() and the minimal length passed in by csum_tree_block() - 1 are bigger than PAGE_SIZE. We always pass BTRFS_CSUM_SIZE (32) as offset and a minimal length of 32 and the current extent buffer allocator always guarantees page aligned extends, so the above condition can't be true. Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: Johannes Thumshirn <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent cc2c39d commit d2e174d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/btrfs/disk-io.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@ static int csum_tree_block(struct btrfs_fs_info *fs_info,
279279

280280
len = buf->len - offset;
281281
while (len > 0) {
282+
/*
283+
* Note: we don't need to check for the err == 1 case here, as
284+
* with the given combination of 'start = BTRFS_CSUM_SIZE (32)'
285+
* and 'min_len = 32' and the currently implemented mapping
286+
* algorithm we cannot cross a page boundary.
287+
*/
282288
err = map_private_extent_buffer(buf, offset, 32,
283289
&kaddr, &map_start, &map_len);
284290
if (err)

0 commit comments

Comments
 (0)