aboutsummaryrefslogtreecommitdiff
path: root/lib/memory-notifier-error-inject.c
diff options
context:
space:
mode:
authorFilipe Manana <[email protected]>2022-12-23 18:28:53 +0000
committerDavid Sterba <[email protected]>2023-01-03 15:53:18 +0100
commit2f2e84ca60660402bd81d0859703567c59556e6a (patch)
tree4da98c4a48464bbc6242aaada3a31f4773321753 /lib/memory-notifier-error-inject.c
parent1d854e4fbabb0cb12ca4a7fcd784eb67a65de5f8 (diff)
btrfs: fix off-by-one in delalloc search during lseek
During lseek, when searching for delalloc in a range that represents a hole and that range has a length of 1 byte, we end up not doing the actual delalloc search in the inode's io tree, resulting in not correctly reporting the offset with data or a hole. This actually only happens when the start offset is 0 because with any other start offset we round it down by sector size. Reproducer: $ mkfs.btrfs -f /dev/sdc $ mount /dev/sdc /mnt/sdc $ xfs_io -f -c "pwrite -q 0 1" /mnt/sdc/foo $ xfs_io -c "seek -d 0" /mnt/sdc/foo Whence Result DATA EOF It should have reported an offset of 0 instead of EOF. Fix this by updating btrfs_find_delalloc_in_range() and count_range_bits() to deal with inclusive ranges properly. These functions are already supposed to work with inclusive end offsets, they just got it wrong in a couple places due to off-by-one mistakes. A test case for fstests will be added later. Reported-by: Joan Bruguera Micó <[email protected]> Link: https://lore.kernel.org/linux-btrfs/[email protected]/ Fixes: b6e833567ea1 ("btrfs: make hole and data seeking a lot more efficient") CC: [email protected] # 6.1 Tested-by: Joan Bruguera Micó <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: David Sterba <[email protected]>
Diffstat (limited to 'lib/memory-notifier-error-inject.c')
0 files changed, 0 insertions, 0 deletions