summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/space-info.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2022-07-15 21:45:23 +0200
committerDavid Sterba <dsterba@suse.com>2022-09-26 12:27:54 +0200
commit723de71d41f50709eaf2eef1b08aa409687a3c97 (patch)
tree3353865eb66ededaa5cd2d1986ae9e8f54c07978 /fs/btrfs/space-info.c
parentbtrfs: simplify arguments of btrfs_update_space_info and rename (diff)
downloadlinux-723de71d41f50709eaf2eef1b08aa409687a3c97.tar.xz
linux-723de71d41f50709eaf2eef1b08aa409687a3c97.zip
btrfs: handle space_info setting of bg in btrfs_add_bg_to_space_info
We previously had the pattern of btrfs_update_space_info(all, the, bg, fields, &space_info); link_block_group(bg); bg->space_info = space_info; Now that we're passing the bg into btrfs_add_bg_to_space_info we can do the linking in that function, transforming this to simply btrfs_add_bg_to_space_info(fs_info, bg); and put the link_block_group() and bg->space_info assignment directly in btrfs_add_bg_to_space_info. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/space-info.c')
-rw-r--r--fs/btrfs/space-info.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index 6974bbef0fea..6260e52d76f4 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -294,11 +294,10 @@ out:
}
void btrfs_add_bg_to_space_info(struct btrfs_fs_info *info,
- struct btrfs_block_group *block_group,
- struct btrfs_space_info **space_info)
+ struct btrfs_block_group *block_group)
{
struct btrfs_space_info *found;
- int factor;
+ int factor, index;
factor = btrfs_bg_type_to_factor(block_group->flags);
@@ -317,7 +316,13 @@ void btrfs_add_bg_to_space_info(struct btrfs_fs_info *info,
found->full = 0;
btrfs_try_granting_tickets(info, found);
spin_unlock(&found->lock);
- *space_info = found;
+
+ block_group->space_info = found;
+
+ index = btrfs_bg_flags_to_raid_index(block_group->flags);
+ down_write(&found->groups_sem);
+ list_add_tail(&block_group->list, &found->block_groups[index]);
+ up_write(&found->groups_sem);
}
struct btrfs_space_info *btrfs_find_space_info(struct btrfs_fs_info *info,