From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A34CF3A6F0A; Fri, 7 Aug 2026 15:40:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786117243; cv=none; b=W1g/rweK0t8aiDLdrFhe68XSOltYMyazw2VMwizPEBKoh3PsfvJCec7mVxMoefHn1yIQmdoYA4ATSuQexDcbL8MefOYZZfVWUJXnfOo2FBipO46/bp+BrpvdR2vquzejtswHM4ioJarT8eexJZVH7R2cp/+3xbSC3wHaFYuPGVE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786117243; c=relaxed/simple; bh=AM7klv9qdBmZIh5WW5G8oZMbpmRpnQJ8rGdYSWkY3J8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=prgKLLdMX/TUF0dKFBCfHXP9oay8MQ1vmqzuNcuuPfQOLVTb0YFQ4c/lwCRCXSd2EwqVcc9gZgflBtSMZGu2i7hWjoCCdFzL9jUxmaBqH4TWnlEpQaqPsjd2F3QH5PrFn5VIVBUeYAdO6taUMNgRfwM3LaTHvEQwBU1N2la5hWM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1zmJs2vl; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="1zmJs2vl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B3CF1F000E9; Fri, 7 Aug 2026 15:40:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786117242; bh=s1g5fwN3wj7JR3pgJDfUOj/NXSZkIGTJ1fPzoQTBMQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1zmJs2vluC/yi/RbVhfgVAouRYdoviTdrhM5UwinF1TWiURq553NE6FT5iHJ2nzq1 +M60/41lI9wQbCGVk2NGz7+FL4MJjqMGOrkdPbcY3TVyjGP26PAlyUhhtWYyB2KbpB OLq6ObHJXeqePNKNr7LYHv72Aj7gsMnfm/ePqw+Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Johannes Thumshirn , Guanghui Yang <3497809730@qq.com>, David Sterba Subject: [PATCH 7.1 213/438] btrfs: zoned: fix missing chunk metadata reservation Date: Fri, 7 Aug 2026 16:36:49 +0200 Message-ID: <20260807143432.552670362@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807143428.008222056@linuxfoundation.org> References: <20260807143428.008222056@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guanghui Yang <3497809730@qq.com> commit 8bc4d7209611e8aa9d5409b6a4a86a9eb91b69a3 upstream. reserve_chunk_space() stores the return value of btrfs_zoned_activate_one_bg() in ret. The helper can return 1 after successfully activating a block group, but ret is later used to decide whether to reserve metadata for chunk tree updates. As a result, successful activation skips btrfs_block_rsv_add() and leaves trans->chunk_bytes_reserved unchanged. Use a separate variable for the activation result so positive success does not affect the later reservation. Keep activation failures in ret instead of returning early so the function uses the common tail path. Fixes: b6a98021e401 ("btrfs: zoned: activate necessary block group") CC: stable@vger.kernel.org Reviewed-by: Johannes Thumshirn Signed-off-by: Guanghui Yang <3497809730@qq.com> Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/block-group.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -4504,25 +4504,29 @@ static void reserve_chunk_space(struct b if (IS_ERR(bg)) { ret = PTR_ERR(bg); } else { + int activate_ret; + /* * We have a new chunk. We also need to activate it for * zoned filesystem. */ - ret = btrfs_zoned_activate_one_bg(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 - * btrfs_create_pending_block_groups(). So ignore - * any error here. An ENOSPC here could happen, due to - * the cases described at do_chunk_alloc() - the system - * block group we just created was just turned into RO - * mode by a scrub for example, or a running discard - * temporarily removed its free space entries, etc. - */ - btrfs_chunk_alloc_add_chunk_item(trans, bg); + activate_ret = btrfs_zoned_activate_one_bg(info, true); + if (activate_ret < 0) { + ret = activate_ret; + } else { + /* + * If we fail to add the chunk item here, we end + * up trying again at phase 2 of chunk allocation, + * at btrfs_create_pending_block_groups(). So + * ignore any error here. An ENOSPC here could + * happen, due to the cases described at + * do_chunk_alloc() - the system block group we + * just created was just turned into RO mode by a + * scrub for example, or a running discard + * temporarily removed its free space entries, etc. + */ + btrfs_chunk_alloc_add_chunk_item(trans, bg); + } } }