Skip to content

Commit

Permalink
btrfs: update stripe_extent delete loop assumptions
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Johannes Thumshirn <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
morbidrsa authored and kdave committed Jul 18, 2024
1 parent d4db859 commit 6a2611b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/btrfs/raid-stripe-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ int btrfs_delete_raid_extent(struct btrfs_trans_handle *trans, u64 start, u64 le
if (ret)
break;

start += key.offset;
length -= key.offset;
if (length == 0)
break;

btrfs_release_path(path);
}

Expand Down

0 comments on commit 6a2611b

Please sign in to comment.