FAILED: patch "[PATCH] btrfs: zoned: fix missing chunk metadata reservation" failed to apply to 6.18-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 8bc4d7209611e8aa9d5409b6a4a86a9eb91b69a3
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026080520-celestial-balmy-f31a@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 8bc4d7209611e8aa9d5409b6a4a86a9eb91b69a3 Mon Sep 17 00:00:00 2001
From: Guanghui Yang <[email protected]>
Date: Tue, 14 Jul 2026 17:55:43 +0800
Subject: [PATCH] btrfs: zoned: fix missing chunk metadata reservation
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.
fs/btrfs/block-group.c +19 -15
@@ -4532,25 +4532,29 @@ static void reserve_chunk_space(struct btrfs_trans_handle *trans,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); + } } }
Sasha Levin
maintainerPATCH 1/2 btrfs: remove fs_info argument from btrfs_zoned_activate_one_bg()
From: Filipe Manana <[email protected]>
[ Upstream commit a232ff90d14657c8637c6e94b606bb5d700a2ecb ]
We don't need it since we can grab fs_info from the given space_info. So remove the fs_info argument.
Stable-dep-of: 8bc4d7209611 ("btrfs: zoned: fix missing chunk metadata reservation")
--- fs/btrfs/block-group.c | 4 ++-- fs/btrfs/zoned.c | 5 ++--- fs/btrfs/zoned.h | 6 ++---- 3 files changed, 6 insertions(+), 9 deletions(-)
fs/btrfs/block-group.c +2 -2
@@ -3073,7 +3073,7 @@ int btrfs_inc_block_group_ro(struct btrfs_block_group *cache,* We have allocated a new chunk. We also need to activate that chunk to * grant metadata tickets for zoned filesystem. */ - ret =btrfs_zoned_activate_one_bg (fs_info, space_info, true); + ret =btrfs_zoned_activate_one_bg (space_info, true);if (ret <0 ) goto out;
@@ -4354,7 +4354,7 @@ static void reserve_chunk_space(struct btrfs_trans_handle *trans,* We have a new chunk. We also need to activate it for * zoned filesystem. */ - ret =btrfs_zoned_activate_one_bg (fs_info, info, true); + ret =btrfs_zoned_activate_one_bg (info, true);if (ret <0 )return ;
fs/btrfs/zoned.c +2 -3
@@ -2959,10 +2959,9 @@ int btrfs_zone_finish_one_bg(struct btrfs_fs_info *fs_info)return ret <0 ? ret :1 ; } -int btrfs_zoned_activate_one_bg (struct btrfs_fs_info *fs_info, -struct btrfs_space_info *space_info, -bool do_finish) +int btrfs_zoned_activate_one_bg (struct btrfs_space_info *space_info,bool do_finish) { +struct btrfs_fs_info *fs_info = space_info->fs_info;struct btrfs_block_group *bg;int index;
fs/btrfs/zoned.h +2 -4
@@ -93,8 +93,7 @@ bool btrfs_zoned_should_reclaim(const struct btrfs_fs_info *fs_info);void btrfs_zoned_release_data_reloc_bg (struct btrfs_fs_info *fs_info,u64 logical,u64 length);int btrfs_zone_finish_one_bg (struct btrfs_fs_info *fs_info); -int btrfs_zoned_activate_one_bg (struct btrfs_fs_info *fs_info, -struct btrfs_space_info *space_info,bool do_finish); +int btrfs_zoned_activate_one_bg (struct btrfs_space_info *space_info,bool do_finish);void btrfs_check_active_zone_reservation (struct btrfs_fs_info *fs_info);int btrfs_reset_unused_block_groups (struct btrfs_space_info *space_info,u64 num_bytes);#else /* CONFIG_BLK_DEV_ZONED */
@@ -261,8 +260,7 @@ static inline int btrfs_zone_finish_one_bg(struct btrfs_fs_info *fs_info)return 1 ; } -static inline int btrfs_zoned_activate_one_bg (struct btrfs_fs_info *fs_info, -struct btrfs_space_info *space_info, +static inline int btrfs_zoned_activate_one_bg (struct btrfs_space_info *space_info,bool do_finish) {/* Consider all the block groups are active */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 btrfs: zoned: fix missing chunk metadata reservation
From: Guanghui Yang <[email protected]>
[ Upstream commit 8bc4d7209611e8aa9d5409b6a4a86a9eb91b69a3 ]
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.
--- fs/btrfs/block-group.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
fs/btrfs/block-group.c +19 -15
@@ -4350,25 +4350,29 @@ static void reserve_chunk_space(struct btrfs_trans_handle *trans,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); + } } }
Signature · 1 line
2.53.0