]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
btrfs: kill the RCU protection for fs_info->space_info
authorJosef Bacik <josef@toxicpanda.com>
Tue, 1 Sep 2020 21:40:37 +0000 (17:40 -0400)
committerDavid Sterba <dsterba@suse.com>
Wed, 7 Oct 2020 10:13:19 +0000 (12:13 +0200)
We have this thing wrapped in an RCU lock, but it's really not needed.
We create all the space_info's on mount, and we destroy them on unmount.
The list never changes and we're protected from messing with it by the
normal mount/umount path, so kill the RCU stuff around it.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c
fs/btrfs/ioctl.c
fs/btrfs/space-info.c
fs/btrfs/super.c

index 01e8ba1da1d3ed8b4e3d63e543cd4441f4aa23f2..a3b27204371c0e4c06bb96d068692ee771df9c0a 100644 (file)
@@ -2031,8 +2031,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
                btrfs_release_path(path);
        }
 
-       rcu_read_lock();
-       list_for_each_entry_rcu(space_info, &info->space_info, list) {
+       list_for_each_entry(space_info, &info->space_info, list) {
                if (!(btrfs_get_alloc_profile(info, space_info->flags) &
                      (BTRFS_BLOCK_GROUP_RAID10 |
                       BTRFS_BLOCK_GROUP_RAID1_MASK |
@@ -2052,7 +2051,6 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
                                list)
                        inc_block_group_ro(cache, 1);
        }
-       rcu_read_unlock();
 
        btrfs_init_global_block_rsv(info);
        ret = check_chunk_block_group_mappings(info);
@@ -3007,12 +3005,10 @@ static void force_metadata_allocation(struct btrfs_fs_info *info)
        struct list_head *head = &info->space_info;
        struct btrfs_space_info *found;
 
-       rcu_read_lock();
-       list_for_each_entry_rcu(found, head, list) {
+       list_for_each_entry(found, head, list) {
                if (found->flags & BTRFS_BLOCK_GROUP_METADATA)
                        found->force_alloc = CHUNK_ALLOC_FORCE;
        }
-       rcu_read_unlock();
 }
 
 static int should_alloc_chunk(struct btrfs_fs_info *fs_info,
@@ -3343,14 +3339,6 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
        }
        spin_unlock(&info->block_group_cache_lock);
 
-       /*
-        * Now that all the block groups are freed, go through and free all the
-        * space_info structs.  This is only called during the final stages of
-        * unmount, and so we know nobody is using them.  We call
-        * synchronize_rcu() once before we start, just to be on the safe side.
-        */
-       synchronize_rcu();
-
        btrfs_release_global_block_rsv(info);
 
        while (!list_empty(&info->space_info)) {
index 8091324341a536856c699c01b5558dee544f6f4e..de65cf6105e4b8c1451ecf165e5431a06717d1a8 100644 (file)
@@ -3475,15 +3475,12 @@ static long btrfs_ioctl_space_info(struct btrfs_fs_info *fs_info,
                struct btrfs_space_info *tmp;
 
                info = NULL;
-               rcu_read_lock();
-               list_for_each_entry_rcu(tmp, &fs_info->space_info,
-                                       list) {
+               list_for_each_entry(tmp, &fs_info->space_info, list) {
                        if (tmp->flags == types[i]) {
                                info = tmp;
                                break;
                        }
                }
-               rcu_read_unlock();
 
                if (!info)
                        continue;
@@ -3531,15 +3528,12 @@ static long btrfs_ioctl_space_info(struct btrfs_fs_info *fs_info,
                        break;
 
                info = NULL;
-               rcu_read_lock();
-               list_for_each_entry_rcu(tmp, &fs_info->space_info,
-                                       list) {
+               list_for_each_entry(tmp, &fs_info->space_info, list) {
                        if (tmp->flags == types[i]) {
                                info = tmp;
                                break;
                        }
                }
-               rcu_read_unlock();
 
                if (!info)
                        continue;
index 0f16a2ce5401553e0285903bca31a1efbbbd344a..64099565ab8f5d2d038a6ff84b76501fde56e686 100644 (file)
@@ -175,10 +175,8 @@ void btrfs_clear_space_info_full(struct btrfs_fs_info *info)
        struct list_head *head = &info->space_info;
        struct btrfs_space_info *found;
 
-       rcu_read_lock();
-       list_for_each_entry_rcu(found, head, list)
+       list_for_each_entry(found, head, list)
                found->full = 0;
-       rcu_read_unlock();
 }
 
 static int create_space_info(struct btrfs_fs_info *info, u64 flags)
@@ -213,7 +211,7 @@ static int create_space_info(struct btrfs_fs_info *info, u64 flags)
        if (ret)
                return ret;
 
-       list_add_rcu(&space_info->list, &info->space_info);
+       list_add(&space_info->list, &info->space_info);
        if (flags & BTRFS_BLOCK_GROUP_DATA)
                info->data_sinfo = space_info;
 
@@ -290,14 +288,10 @@ struct btrfs_space_info *btrfs_find_space_info(struct btrfs_fs_info *info,
 
        flags &= BTRFS_BLOCK_GROUP_TYPE_MASK;
 
-       rcu_read_lock();
-       list_for_each_entry_rcu(found, head, list) {
-               if (found->flags & flags) {
-                       rcu_read_unlock();
+       list_for_each_entry(found, head, list) {
+               if (found->flags & flags)
                        return found;
-               }
        }
-       rcu_read_unlock();
        return NULL;
 }
 
index 3ebe7240c63d6608ea3e7713c3925e7dc87ec3d4..8840a4fa81eb7894cdefbce9e9d81dd19d6e9dab 100644 (file)
@@ -2164,8 +2164,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
        u64 thresh = 0;
        int mixed = 0;
 
-       rcu_read_lock();
-       list_for_each_entry_rcu(found, &fs_info->space_info, list) {
+       list_for_each_entry(found, &fs_info->space_info, list) {
                if (found->flags & BTRFS_BLOCK_GROUP_DATA) {
                        int i;
 
@@ -2194,8 +2193,6 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
                total_used += found->disk_used;
        }
 
-       rcu_read_unlock();
-
        buf->f_blocks = div_u64(btrfs_super_total_bytes(disk_super), factor);
        buf->f_blocks >>= bits;
        buf->f_bfree = buf->f_blocks - (div_u64(total_used, factor) >> bits);