From nobody Mon Sep 29 21:17:41 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9558FC00140 for ; Tue, 16 Aug 2022 01:03:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348019AbiHPBCG (ORCPT ); Mon, 15 Aug 2022 21:02:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344401AbiHPA4c (ORCPT ); Mon, 15 Aug 2022 20:56:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DEED17B83A; Mon, 15 Aug 2022 13:48:03 -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 A278BB8114A; Mon, 15 Aug 2022 20:48:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB9D3C433D6; Mon, 15 Aug 2022 20:48:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596481; bh=vIGpQcAgld7A+4ecjA7VklllgQvBCtIXhrhWmWy5tT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TO1VOhKVK5aOlJui03VeL1s6xjyO76+Q3M+PeLk23FZmqe9Ntm91dB0OLm5z1lqmg 1P8/NqVnpmV40cLQxhZh5WA63bvR7XboRweTk677MQ4WWh/16YA0DOpL44ePNFse2+ QvNrDdqlSY7crdWt25HWP7AtXJT0a6Tl0Kf39xO8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Naohiro Aota , David Sterba , Sasha Levin Subject: [PATCH 5.19 1094/1157] btrfs: zoned: activate necessary block group Date: Mon, 15 Aug 2022 20:07:30 +0200 Message-Id: <20220815180523.983097592@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Naohiro Aota [ Upstream commit b6a98021e4019c562a23ad151a7e40adfa9f91e5 ] There are two places where allocating a chunk is not enough. These two places are trying to ensure the space by allocating a chunk. To meet the condition for active_total_bytes, we also need to activate a block group there. CC: stable@vger.kernel.org # 5.16+ Fixes: afba2bc036b0 ("btrfs: zoned: implement active zone tracking") Signed-off-by: Naohiro Aota Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/block-group.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 20c78ae7d150..5627b43d4cc2 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -2665,6 +2665,14 @@ int btrfs_inc_block_group_ro(struct btrfs_block_grou= p *cache, ret =3D btrfs_chunk_alloc(trans, alloc_flags, CHUNK_ALLOC_FORCE); if (ret < 0) goto out; + /* + * We have allocated a new chunk. We also need to activate that chunk to + * grant metadata tickets for zoned filesystem. + */ + ret =3D btrfs_zoned_activate_one_bg(fs_info, cache->space_info, true); + if (ret < 0) + goto out; + ret =3D inc_block_group_ro(cache, 0); if (ret =3D=3D -ETXTBSY) goto unlock_out; @@ -3890,6 +3898,14 @@ static void reserve_chunk_space(struct btrfs_trans_h= andle *trans, if (IS_ERR(bg)) { ret =3D PTR_ERR(bg); } else { + /* + * We have a new chunk. We also need to activate it for + * zoned filesystem. + */ + ret =3D btrfs_zoned_activate_one_bg(fs_info, info, true); + if (ret < 0) + return; + /* * If we fail to add the chunk item here, we end up * trying again at phase 2 of chunk allocation, at --=20 2.35.1