From patchwork Wed Apr 14 12:08:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 12202567 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02E73C433ED for ; Wed, 14 Apr 2021 12:08:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BBDDD60200 for ; Wed, 14 Apr 2021 12:08:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350667AbhDNMIv (ORCPT ); Wed, 14 Apr 2021 08:08:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:54418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233651AbhDNMIq (ORCPT ); Wed, 14 Apr 2021 08:08:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4F85A60200 for ; Wed, 14 Apr 2021 12:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618402104; bh=Y24bp2BgYW3YgLECIR0ZgkP3hjFBaHy5B0LDAXQLA6g=; h=From:To:Subject:Date:From; b=Wh5PWl5xD2+0G6garmc/OnzxbNknypw0EwA62hFviTemVbED3f1PauAWApP6K1eup dcCkLn4F3Q+qXTKkb81vSMVwathXcQbBodU62StdA4Hzu4l6xr0CJJVLYls2B2oDyk c58576SX0bYeuANIwytOrrT1wvx5L9i8d7VTuPlLvZuWSJ/iDyroxqywXBukYeQ9HY YENVNYrS65guhODGTpizfsGR7lULJpptTZSzCWkc6aCjSPilXCohtMrqE7EQIyIQxw CVJGZQdQ9MGUVRW2/3wuskxLo2s9ViGrV18r8slv0CweUSQ9Oyhc59sKfcHVA9smu+ 93d//y1W6stnw== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs: zoned: fix unpaired block group unfreeze during device replace Date: Wed, 14 Apr 2021 13:08:21 +0100 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Filipe Manana 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") Signed-off-by: Filipe Manana Reviewed-by: Johannes Thumshirn Reported-by: kernel test robot --- fs/btrfs/scrub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 17e49caad1f9..e0d54ed9acee 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -3674,8 +3674,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); }