From nobody Fri Oct 24 20:28:43 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 19A14C00140 for ; Mon, 15 Aug 2022 23:29:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244861AbiHOX2z (ORCPT ); Mon, 15 Aug 2022 19:28:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353468AbiHOXWR (ORCPT ); Mon, 15 Aug 2022 19:22:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66EA65D138; Mon, 15 Aug 2022 13:05:25 -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 726FDB80EB1; Mon, 15 Aug 2022 20:05:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCEEFC433D7; Mon, 15 Aug 2022 20:05:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593923; bh=rfv18tYRRuE5kOUwwHi+YUZvKlCKY5Ad8oTOAlFiY/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gh6hIILyp/wi831+gcCwJuhPxI90blok2KbRAaXi9Y9wDFc5kxi/BJ57O9jPMB51X jsEz2W8u/a1G1zNM33Mih5gzwxlzPDDIa8JaMQCLGO+ZycIuJzQrL4Ghc4tnJLAt0y 5OE4ie0hASZL3FD3JaGS1lHD0mb6Bes/BOVuWc4A= 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.18 1029/1095] btrfs: zoned: activate necessary block group Date: Mon, 15 Aug 2022 20:07:08 +0200 Message-Id: <20220815180511.621961976@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 88f59a2e4113..0c7fe3142d7c 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -2659,6 +2659,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; @@ -3853,6 +3861,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