OSDN Git Service

btrfs: Don't trim returned range based on input value in find_first_clear_extent_bit
authorNikolay Borisov <nborisov@suse.com>
Mon, 3 Jun 2019 10:06:02 +0000 (13:06 +0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 1 Jul 2019 11:35:02 +0000 (13:35 +0200)
commit1eaebb341d2b4183d0112b76e31ccff3e1fe3092
tree91ab17f1a296d66d5707c5063f1a61084611ae0d
parent53460a4572585b508dc4cb6f09653ac50ba3fc49
btrfs: Don't trim returned range based on input value in find_first_clear_extent_bit

Currently find_first_clear_extent_bit always returns a range whose
starting value is >= passed 'start'. This implicit trimming behavior is
somewhat subtle and an implementation detail.

Instead, this patch modifies the function such that now it always
returns the range which contains passed 'start' and has the given bits
unset. This range could either be due to presence of existing records
which contains 'start' but have the bits unset or because there are no
records that contain the given starting offset.

This patch also adds test cases which cover find_first_clear_extent_bit
since they were missing up until now.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c
fs/btrfs/tests/extent-io-tests.c