From: Johannes Thumshirn Date: Mon, 13 Jan 2025 19:31:46 +0000 (+0100) Subject: btrfs: fix tail delete of RAID stripe-extents X-Git-Tag: v6.14-rc1~207^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=50cae2ca69561cbd9a90308ad2a14a442d230662;p=thirdparty%2Fkernel%2Flinux.git btrfs: fix tail delete of RAID stripe-extents Fix tail delete of RAID stripe-extents, if there is a range to be deleted as well after the tail delete of the extent. Reviewed-by: Filipe Manana Signed-off-by: Johannes Thumshirn Signed-off-by: David Sterba --- diff --git a/fs/btrfs/raid-stripe-tree.c b/fs/btrfs/raid-stripe-tree.c index 9e559ad48810b..ef76202c3a384 100644 --- a/fs/btrfs/raid-stripe-tree.c +++ b/fs/btrfs/raid-stripe-tree.c @@ -119,11 +119,18 @@ int btrfs_delete_raid_extent(struct btrfs_trans_handle *trans, u64 start, u64 le * length to the new size and then re-insert the item. */ if (found_start < start) { - u64 diff = start - found_start; + u64 diff_start = start - found_start; btrfs_partially_delete_raid_extent(trans, path, &key, - diff, 0); - break; + diff_start, 0); + + start += (key.offset - diff_start); + length -= (key.offset - diff_start); + if (length == 0) + break; + + btrfs_release_path(path); + continue; } /*