btrfs: remove spurious unlock/lock of unused_bgs_lock
authorNikolay Borisov <nborisov@suse.com>
Thu, 14 Oct 2021 07:03:11 +0000 (10:03 +0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 3 Jan 2022 14:09:42 +0000 (15:09 +0100)
Since both unused block groups and reclaim bgs lists are protected by
unused_bgs_lock then free them in the same critical section without
doing an extra unlock/lock pair.

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

index 444e9c89ff3e9a798be1c863df88154e321dc380..6ab864655090dc72c112fa6712d495808ca2ff8b 100644 (file)
@@ -3911,9 +3911,7 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
                list_del_init(&block_group->bg_list);
                btrfs_put_block_group(block_group);
        }
-       spin_unlock(&info->unused_bgs_lock);
 
-       spin_lock(&info->unused_bgs_lock);
        while (!list_empty(&info->reclaim_bgs)) {
                block_group = list_first_entry(&info->reclaim_bgs,
                                               struct btrfs_block_group,