Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2186387iof; Tue, 7 Jun 2022 22:33:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrzfXLIWvVO/TJi9sny5ZbfLSj2kkrwzF3dhuWkyciRQewha942aYO8gm0kfR8JoK7Kowj X-Received: by 2002:a65:554b:0:b0:3fc:159c:823e with SMTP id t11-20020a65554b000000b003fc159c823emr28645050pgr.33.1654666408833; Tue, 07 Jun 2022 22:33:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666408; cv=none; d=google.com; s=arc-20160816; b=VWkWgMdHJvW25QstGTCAij1O0zpQub1Td929tEvptOPJHq7UoXhLXOtioYCZh0klmx EvxK67okbu7wIriUZRQd21NgUJSRfcCYEhawt7hWhLMW1cBWsXqIKJNzNWDOOViX+7rh nyVjrOywKxTLTPHCm4JRskrvidloK5eehQP92TcVtt1SbVC0MxZCHVr6kwYnux0OTzC8 3qkheWW1eb6fyGhgoV/KcbwPOJoFPPrlNVs5NbgXHGOimNY4eMfdwc2OneM/7P1RSAaV C0sOEliSqUC+BJLNRuseCLICIBnR5UB5LLSxqLq8FIR4A7gDi0tZOvALHUPLvz+Tqnu7 C2lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4iNASf5slKSpIbit+kwnuBHLOAKI0Yj3dRY11sQEPAU=; b=FFD1abebVINeEhFlvNFmYRp/KhyOBk2DSFiRYZo5lh7BqUn5+nhOXWD0p+FGgt9uVX OSECsiboIdfsfyhkTbxkkO+zVKtYON/11FVwPPt06f/X/GiAfiC4tW+Prbj3sJryhmbQ jxU/cIVmXAGQzQqSe+yR8eNXNktA3t+D1zrK7StTkKNxmo3oaYlI5urvfJY2R/1HST55 tRO9HbdcAUVEc3ivpFzgnv+MlHPGIWMm3d9hSqFFgjubAFnRX11lGtY5g1wu12yEyjy6 3CsOwdp2+nI3b2mQ2QGR63yI1kLqdU0hjv+n26LKW8SRPhUlPiEHFtwQEMP0e195KqCr +s7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Rg6nDat7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s192-20020a632cc9000000b003fce50f8e2esi1271680pgs.204.2022.06.07.22.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:33:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Rg6nDat7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 873132C7097; Tue, 7 Jun 2022 22:01:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382806AbiFGV6N (ORCPT + 99 others); Tue, 7 Jun 2022 17:58:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379383AbiFGVCY (ORCPT ); Tue, 7 Jun 2022 17:02:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E87B7A82E; Tue, 7 Jun 2022 11:47:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BB0CEB81FE1; Tue, 7 Jun 2022 18:47:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D9B4C385A2; Tue, 7 Jun 2022 18:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627674; bh=GHSWOLtaRIxGcfDoMTvsX1OVEgJYxZloovcbfd7Oric=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rg6nDat7SkRD6I6XQcOBUq0WiwNYRIwzUGj2Dv/1hlalQh/SR1hsNJ1jWKgmy9ULH iORyDFFTFsgk4NrjkgRGXG3mf6YcCGY5NAqF61gLgLHnY29p1jrpMbrIT3dxiIQEyd J9oJuDeEKt0vqMQfCyQLVVFXd1WoCB8kNoRl5BLo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Naohiro Aota , David Sterba Subject: [PATCH 5.18 051/879] btrfs: zoned: zone finish unused block group Date: Tue, 7 Jun 2022 18:52:49 +0200 Message-Id: <20220607165004.167780399@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Naohiro Aota commit 74e91b12b11560f01d120751d99d91d54b265d3d upstream. While the active zones within an active block group are reset, and their active resource is released, the block group itself is kept in the active block group list and marked as active. As a result, the list will contain more than max_active_zones block groups. That itself is not fatal for the device as the zones are properly reset. However, that inflated list is, of course, strange. Also, a to-appear patch series, which deactivates an active block group on demand, gets confused with the wrong list. So, fix the issue by finishing the unused block group once it gets read-only, so that we can release the active resource in an early stage. Fixes: be1a1d7a5d24 ("btrfs: zoned: finish fully written block group") CC: stable@vger.kernel.org # 5.16+ Reviewed-by: Johannes Thumshirn Signed-off-by: Naohiro Aota Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/block-group.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -1367,6 +1367,14 @@ void btrfs_delete_unused_bgs(struct btrf goto next; } + ret = btrfs_zone_finish(block_group); + if (ret < 0) { + btrfs_dec_block_group_ro(block_group); + if (ret == -EAGAIN) + ret = 0; + goto next; + } + /* * Want to do this before we do anything else so we can recover * properly if we fail to join the transaction.