Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2150410iof; Tue, 7 Jun 2022 21:25:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTlsVeAgjDipP/cgF2d+ZRJbJCVPQyPmDyZClk9GnDhwBvFP+LKCUriIUgXofFJHwU/KnF X-Received: by 2002:a17:903:130d:b0:164:17f5:9de5 with SMTP id iy13-20020a170903130d00b0016417f59de5mr33250097plb.132.1654662357662; Tue, 07 Jun 2022 21:25:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654662357; cv=none; d=google.com; s=arc-20160816; b=EeiU2E54NWeW6mFKZJTkN4fekMMGqbxYg8v38aOIiU1/5sxVZUjbvwGX/YzDH+fmr9 nvCk0VM54C5QDnuSHfgRrV4fRzXt791p8MCcGqjNV0LJMiZQjaX6wJvZlfOuC94isF2j auHlW8N4XHh6ERPVSPS8BTG95fcwQdG6NbdbXBEpYoWA5cYlwDRjQl8CW61Xms4spnTr WAMHjxlxlE5kwssSdbrC3DeZmYL1XME+2uvJq9ewlG9INAel6hpZjI7/AXWFi/e1qIyL 5PDhFxZGGjc/7ZzwW7MnSDZ6m7DDjS5FNHDBEEZIsamywfXjrdKwFtuJn/rmBVUol4VK NxhA== 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=GY7yrqUoyVBA7zChkbzRf1e0lXmUcHcJvlnepXYszcHQVwi4IgWyakWZ8F6wDLMX9o eaMGx7pUr/FL5H909kIk8nlVy8mTgyJIwUOWnBAC20hT2t3n0K7gA2XKJF6AmHBZKD6j 94eggTVTwo13aqKD8QWmICvx38vvCv2ELz8Py3jWpjlB4AAB/D5qmUWVMOFyv3T7l8L6 UOB5iCwQ6pOf2o642bqriJktdVnuc3NQs0gVr8fREmk/1NpZrBCpm/pxrKqEIX5+0aFN 3KcilamfodG5PsZin5Zk4NSW3c3BIKGkG/d1Oq4CgZ4xj+83fReOiucXkKqW0Y0yR0Vp tq3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Mr+3p2Pn; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id bg18-20020a056a02011200b003ab1d7664e8si15303301pgb.66.2022.06.07.21.25.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:25:57 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Mr+3p2Pn; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 F3AAC3F4A16; Tue, 7 Jun 2022 21:00:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358554AbiFGUXT (ORCPT + 99 others); Tue, 7 Jun 2022 16:23:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355770AbiFGTao (ORCPT ); Tue, 7 Jun 2022 15:30:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B5081A43C8; Tue, 7 Jun 2022 11:12:01 -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 7418FB81F38; Tue, 7 Jun 2022 18:11:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C46CDC385A5; Tue, 7 Jun 2022 18:11:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654625516; bh=GHSWOLtaRIxGcfDoMTvsX1OVEgJYxZloovcbfd7Oric=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mr+3p2Pnv/hkhS0l5Sw/rcjk4YGIyMf9JQ75pTkDj67kP/2otndFwMKBc9rn9etqK IqXs3fUcfTsE0l0gCE5s02vUYxjZcoyUCzg+wylGzCL5k3jCR+NTwIn9MSpcPrrNOO 3s4VylXWpuul0n9/BMt0QE61aCUZ0hd3cQ30zGU4= 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.17 047/772] btrfs: zoned: zone finish unused block group Date: Tue, 7 Jun 2022 18:53:59 +0200 Message-Id: <20220607164950.422368315@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164948.980838585@linuxfoundation.org> References: <20220607164948.980838585@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.