From: Miroslav Cimerman <mc@raidlab.org>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>, Chris Mason <mason@kernel.org>,
Naohiro Aota <naohiro.aota@wdc.com>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>,
Qu Wenruo <wqu@suse.com>, Damien Le Moal <dlemoal@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] btrfs: zoned: do not fail an ordered extent on a zone finish error
Date: Sun, 22 Nov 2026 23:23:08 +0000 [thread overview]
Message-ID: <20261122232310.4099580-2-mc@raidlab.org> (raw)
In-Reply-To: <20261122232310.4099580-1-mc@raidlab.org>
When an ordered extent ends at the zone capacity of its block group,
btrfs_zone_finish_endio() finishes the zones of the block group. Since
commit c428b763f29b ("btrfs: zoned: propagate do_zone_finish() error in
btrfs_zone_finish_endio()"), it returns the error of do_zone_finish().
btrfs_finish_one_ordered() then fails the ordered extent. It skips the
file extent item that points the file to the new data. It also frees the
new extent.
However, the data of the ordered extent is already written. Only the
ZONE_FINISH command failed, for example on one device of a RAID1 block
group. The write is still lost:
O_DIRECT overwrite, the last extent ends at the zone capacity
write and sync return 0
ZONE_FINISH fails on one device
btrfs_finish_one_ordered(): no file extent item, extent freed
first O_DIRECT read of the file: -EIO (writeback error of the mapping)
later reads, also after a remount: the old data of that extent
do_zone_finish() marks the block group as finished before it sends
ZONE_FINISH, so nothing writes to these zones anymore. Report the error
and let the ordered extent complete, as before that commit.
Fixes: c428b763f29b ("btrfs: zoned: propagate do_zone_finish() error in btrfs_zone_finish_endio()")
CC: stable@vger.kernel.org # 7.3+
Signed-off-by: Miroslav Cimerman <mc@raidlab.org>
---
fs/btrfs/zoned.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index e6ce6f05ad75..45bd05d8edb4 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -2783,7 +2783,7 @@ int btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 leng
{
struct btrfs_block_group *block_group;
u64 min_alloc_bytes;
- int ret = 0;
+ int ret;
if (!btrfs_is_zoned(fs_info))
return 0;
@@ -2803,11 +2803,18 @@ int btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 leng
block_group->start + block_group->zone_capacity)
goto out;
+ /*
+ * The data of the ordered extent is written. A failure to finish the
+ * zones does not change that, so only report it.
+ */
ret = do_zone_finish(block_group, true);
+ if (ret)
+ btrfs_warn(fs_info, "zoned: failed to finish zones of block group %llu: %d",
+ block_group->start, ret);
out:
btrfs_put_block_group(block_group);
- return ret;
+ return 0;
}
static void btrfs_zone_finish_endio_workfn(struct work_struct *work)
--
2.53.0
next prev parent reply other threads:[~2026-11-22 23:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 23:23 [PATCH 0/3] btrfs: zoned: handle a failed zone finish on one device Miroslav Cimerman
2026-11-22 23:23 ` Miroslav Cimerman [this message]
2026-11-22 23:23 ` [PATCH 2/3] btrfs: zoned: tolerate a failed zone finish on a full block group Miroslav Cimerman
2026-11-22 23:23 ` [PATCH 3/3] btrfs: zoned: do not WARN when zones fail to finish before relocation Miroslav Cimerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261122232310.4099580-2-mc@raidlab.org \
--to=mc@raidlab.org \
--cc=dlemoal@kernel.org \
--cc=dsterba@suse.com \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mason@kernel.org \
--cc=naohiro.aota@wdc.com \
--cc=wqu@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox