Commit efc34534 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

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: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 4785e24f
...@@ -3932,15 +3932,14 @@ int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info) ...@@ -3932,15 +3932,14 @@ int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info)
int i = 0; int i = 0;
int err = 0; int err = 0;
unsigned int ret = 0; unsigned int ret = 0;
int index;
while (1) { while (1) {
index = srcu_read_lock(&fs_info->subvol_srcu); spin_lock(&fs_info->fs_roots_radix_lock);
ret = radix_tree_gang_lookup(&fs_info->fs_roots_radix, ret = radix_tree_gang_lookup(&fs_info->fs_roots_radix,
(void **)gang, root_objectid, (void **)gang, root_objectid,
ARRAY_SIZE(gang)); ARRAY_SIZE(gang));
if (!ret) { if (!ret) {
srcu_read_unlock(&fs_info->subvol_srcu, index); spin_unlock(&fs_info->fs_roots_radix_lock);
break; break;
} }
root_objectid = gang[ret - 1]->root_key.objectid + 1; root_objectid = gang[ret - 1]->root_key.objectid + 1;
...@@ -3954,7 +3953,7 @@ int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info) ...@@ -3954,7 +3953,7 @@ int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info)
/* grab all the search result for later use */ /* grab all the search result for later use */
gang[i] = btrfs_grab_root(gang[i]); gang[i] = btrfs_grab_root(gang[i]);
} }
srcu_read_unlock(&fs_info->subvol_srcu, index); spin_unlock(&fs_info->fs_roots_radix_lock);
for (i = 0; i < ret; i++) { for (i = 0; i < ret; i++) {
if (!gang[i]) if (!gang[i])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment