Skip to content

Commit 9257d86

Browse files
morbidrsakdave
authored andcommitted
btrfs: don't try to delete RAID stripe-extents if we don't need to
Even if the RAID stripe-tree is not enabled in the filesystem, do_free_extent_accounting() still calls into btrfs_delete_raid_extent(). Check if the extent in question is on a block-group that has a profile which is used by RAID stripe-tree before attempting to delete a stripe extent. Return early if it doesn't, otherwise we're doing a unnecessary search. Reviewed-by: Filipe Manana <[email protected]> Signed-off-by: Johannes Thumshirn <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent c221a9a commit 9257d86

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

fs/btrfs/raid-stripe-tree.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,22 @@ int btrfs_delete_raid_extent(struct btrfs_trans_handle *trans, u64 start, u64 le
5959
int slot;
6060
int ret;
6161

62-
if (!stripe_root)
62+
if (!btrfs_fs_incompat(fs_info, RAID_STRIPE_TREE) || !stripe_root)
6363
return 0;
6464

65+
if (!btrfs_is_testing(fs_info)) {
66+
struct btrfs_chunk_map *map;
67+
bool use_rst;
68+
69+
map = btrfs_find_chunk_map(fs_info, start, length);
70+
if (!map)
71+
return -EINVAL;
72+
use_rst = btrfs_need_stripe_tree_update(fs_info, map->type);
73+
btrfs_free_chunk_map(map);
74+
if (!use_rst)
75+
return 0;
76+
}
77+
6578
path = btrfs_alloc_path();
6679
if (!path)
6780
return -ENOMEM;

0 commit comments

Comments
 (0)