btrfs: remove lock protection for BLOCK_GROUP_FLAG_TO_COPY
authorJosef Bacik <josef@toxicpanda.com>
Fri, 15 Jul 2022 19:45:25 +0000 (15:45 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 26 Sep 2022 10:27:54 +0000 (12:27 +0200)
We use this during device replace for zoned devices, we were simply
taking the lock because it was in a bit field and we needed the lock to
be safe with other modifications in the bitfield.  With the bit helpers
we no longer require that locking.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.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/dev-replace.c
fs/btrfs/scrub.c
fs/btrfs/volumes.c

index 46b608260b33e4c513c5597639c1f25d88d6fe13..88b2c256dc837a9dde49d3be83daa28154e6efd5 100644 (file)
@@ -545,10 +545,7 @@ static int mark_block_group_to_copy(struct btrfs_fs_info *fs_info,
                if (!cache)
                        continue;
 
-               spin_lock(&cache->lock);
                set_bit(BLOCK_GROUP_FLAG_TO_COPY, &cache->runtime_flags);
-               spin_unlock(&cache->lock);
-
                btrfs_put_block_group(cache);
        }
        if (iter_ret < 0)
@@ -610,9 +607,7 @@ bool btrfs_finish_block_group_to_copy(struct btrfs_device *srcdev,
        }
 
        /* Last stripe on this device */
-       spin_lock(&cache->lock);
        clear_bit(BLOCK_GROUP_FLAG_TO_COPY, &cache->runtime_flags);
-       spin_unlock(&cache->lock);
 
        return true;
 }
index 534dd680a6aa08b3175efc4713f8f7ee23aea8f0..d05025034b0aae0ef1bc84fca170a1a2beb66ae3 100644 (file)
@@ -3755,13 +3755,11 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
                }
 
                if (sctx->is_dev_replace && btrfs_is_zoned(fs_info)) {
-                       spin_lock(&cache->lock);
                        if (!test_bit(BLOCK_GROUP_FLAG_TO_COPY, &cache->runtime_flags)) {
                                spin_unlock(&cache->lock);
                                btrfs_put_block_group(cache);
                                goto skip;
                        }
-                       spin_unlock(&cache->lock);
                }
 
                /*
index fcde4f085cb6e0bd71c968f56ee3ee646b3833d5..4d03d2f47dc381576e0384405d974c06d61f612b 100644 (file)
@@ -6153,9 +6153,7 @@ static bool is_block_group_to_copy(struct btrfs_fs_info *fs_info, u64 logical)
 
        cache = btrfs_lookup_block_group(fs_info, logical);
 
-       spin_lock(&cache->lock);
        ret = test_bit(BLOCK_GROUP_FLAG_TO_COPY, &cache->runtime_flags);
-       spin_unlock(&cache->lock);
 
        btrfs_put_block_group(cache);
        return ret;