summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYao Sang <sangyao@kylinos.cn>2026-06-12 05:44:30 +0300
committerCarlos Maiolino <cem@kernel.org>2026-06-12 10:51:55 +0300
commitf4f28ffe09248e747ffd6b752cbad0f7a34af475 (patch)
tree53d49b1834e1ae0fbd190fcad91a96c6033df9bf
parentdfac6ba84819bd12535943c4090766bbc6c5ea7e (diff)
downloadlinux-f4f28ffe09248e747ffd6b752cbad0f7a34af475.tar.xz
xfs: shut down zoned file systems on writeback errors
Zoned writeback allocates space from an open zone and advances the in-memory allocation state before submitting the bio. The completion path only records the written blocks and updates the mapping on success. If the write fails, XFS cannot tell how far the device write pointer advanced and cannot safely roll the open zone accounting back. This was observed while investigating xfs/643 and xfs/646 on an external ZNS realtime device. A writeback error after consuming space from an open zone left later writers waiting for open-zone or GC progress that could not happen. xfs/643 exposed this through the GC defragmentation path, while xfs/646 exposed the same failure mode through the truncate/EOF-zeroing space wait path. There is no local recovery path in ioend completion that can restore a consistent zoned allocation state after the device has rejected the write. Treat writeback errors for zoned inodes as fatal and force a file system shutdown from the ioend completion path. The existing shutdown path wakes zoned allocation waiters and makes future space waits return -EIO instead of leaving tasks stuck waiting for progress. Signed-off-by: Yao Sang <sangyao@kylinos.cn> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Carlos Maiolino <cem@kernel.org>
-rw-r--r--fs/xfs/xfs_aops.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 1a82cf625a08..2a0c54256e93 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -139,6 +139,17 @@ xfs_end_ioend_write(
*/
error = blk_status_to_errno(ioend->io_bio.bi_status);
if (unlikely(error)) {
+ /*
+ * Zoned writes update the in-core open zone accounting before
+ * I/O submission. A failed write leaves that state
+ * inconsistent, so shut down the filesystem instead of letting
+ * later writers wait forever for open zone space to become
+ * available.
+ */
+ if (is_zoned) {
+ xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR);
+ goto done;
+ }
if (ioend->io_flags & IOMAP_IOEND_SHARED) {
ASSERT(!is_zoned);
xfs_reflink_cancel_cow_range(ip, offset, size, true);