Skip to content

Commit efc3453

Browse files
josefbacikkdave
authored andcommitted
btrfs: make btrfs_cleanup_fs_roots use the radix tree lock
The radix root is primarily protected by the fs_roots_radix_lock, so use that to lookup and get a ref on all of our fs roots in btrfs_cleanup_fs_roots. The tree reference is taken in the protected section as before. Signed-off-by: Josef Bacik <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 4785e24 commit efc3453

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

fs/btrfs/disk-io.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3932,15 +3932,14 @@ int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info)
39323932
int i = 0;
39333933
int err = 0;
39343934
unsigned int ret = 0;
3935-
int index;
39363935

39373936
while (1) {
3938-
index = srcu_read_lock(&fs_info->subvol_srcu);
3937+
spin_lock(&fs_info->fs_roots_radix_lock);
39393938
ret = radix_tree_gang_lookup(&fs_info->fs_roots_radix,
39403939
(void **)gang, root_objectid,
39413940
ARRAY_SIZE(gang));
39423941
if (!ret) {
3943-
srcu_read_unlock(&fs_info->subvol_srcu, index);
3942+
spin_unlock(&fs_info->fs_roots_radix_lock);
39443943
break;
39453944
}
39463945
root_objectid = gang[ret - 1]->root_key.objectid + 1;
@@ -3954,7 +3953,7 @@ int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info)
39543953
/* grab all the search result for later use */
39553954
gang[i] = btrfs_grab_root(gang[i]);
39563955
}
3957-
srcu_read_unlock(&fs_info->subvol_srcu, index);
3956+
spin_unlock(&fs_info->fs_roots_radix_lock);
39583957

39593958
for (i = 0; i < ret; i++) {
39603959
if (!gang[i])

0 commit comments

Comments
 (0)