]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: zoned: fix unpaired block group unfreeze during device replace
authorFilipe Manana <fdmanana@suse.com>
Wed, 14 Apr 2021 13:05:26 +0000 (14:05 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 12 May 2021 06:39:32 +0000 (08:39 +0200)
commit 0dc16ef4f6c2708407fab6d141908d46a3b737bc upstream.

When doing a device replace on a zoned filesystem, if we find a block
group with ->to_copy == 0, we jump to the label 'done', which will result
in later calling btrfs_unfreeze_block_group(), even though at this point
we never called btrfs_freeze_block_group().

Since at this point we have neither turned the block group to RO mode nor
made any progress, we don't need to jump to the label 'done'. So fix this
by jumping instead to the label 'skip' and dropping our reference on the
block group before the jump.

Fixes: 78ce9fc269af6e ("btrfs: zoned: mark block groups to copy for device-replace")
CC: stable@vger.kernel.org # 5.12
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/scrub.c

index 3d9088eab2fca3492762ae9f370e13d25baa9f3b..b9202a1f1af10281b745b5f5aec91614674b0654 100644 (file)
@@ -3682,8 +3682,8 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
                        spin_lock(&cache->lock);
                        if (!cache->to_copy) {
                                spin_unlock(&cache->lock);
-                               ro_set = 0;
-                               goto done;
+                               btrfs_put_block_group(cache);
+                               goto skip;
                        }
                        spin_unlock(&cache->lock);
                }
@@ -3841,7 +3841,6 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
                                                      cache, found_key.offset))
                        ro_set = 0;
 
-done:
                down_write(&dev_replace->rwsem);
                dev_replace->cursor_left = dev_replace->cursor_right;
                dev_replace->item_needs_writeback = 1;