Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: update stripe_extent delete loop assumptions

btrfs_delete_raid_extent() was written under the assumption, that it's
call-chain always passes a start, length tuple that matches a single
extent. But btrfs_delete_raid_extent() is called by
do_free_extent_accounting() which in turn is called by
__btrfs_free_extent().

But this call-chain passes in a start address and a length that can
possibly match multiple on-disk extents.

To make this possible, we have to adjust the start and length of each
btree node lookup, to not delete beyond the requested range.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Johannes Thumshirn and committed by
David Sterba
7fa5230b 8c4cba2a

+5
+5
fs/btrfs/raid-stripe-tree.c
··· 66 66 if (ret) 67 67 break; 68 68 69 + start += key.offset; 70 + length -= key.offset; 71 + if (length == 0) 72 + break; 73 + 69 74 btrfs_release_path(path); 70 75 } 71 76