[PATCH] iomap: don't invalidate folios after writeback errors

From: driz2t@xxxxxx

Date: Tue Mar 24 2026 - 09:46:33 EST


This patch is a backport to stable 5.15.y of upstream commit e9c3a8e820ed0eeb2be05072f29f80d1b79f053b
("iomap: don't invalidate folios after writeback errors").

Fixes: 3330a8d33e08 ("iomap, xfs: fix page discard handling on shutdown")
Reported-by: syzbot+c0ffed3897231d71f047@xxxxxxxxxxxxxxxxxxxxxxxxx
Tested-by: syzbot+c0ffed3897231d71f047@xxxxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: Changjian Liu <driz2t@xxxxxx>
---
fs/iomap/buffered-io.c | 1 -
fs/xfs/xfs_aops.c | 4 +---
2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 87a4f5a2ded0..1f0bfe0b8bae 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1350,7 +1350,6 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
if (wpc->ops->discard_page)
wpc->ops->discard_page(page, file_offset);
if (!count) {
- ClearPageUptodate(page);
unlock_page(page);
goto done;
}
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index c8c15c3c3147..56a5bd7ad8c4 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -450,7 +450,7 @@ xfs_discard_page(
int error;

if (xfs_is_shutdown(mp))
- goto out_invalidate;
+ return;

xfs_alert_ratelimited(mp,
"page discard on page "PTR_FMT", inode 0x%llx, offset %llu.",
@@ -460,8 +460,6 @@ xfs_discard_page(
i_blocks_per_page(inode, page) - pageoff_fsb);
if (error && !xfs_is_shutdown(mp))
xfs_alert(mp, "page discard unable to remove delalloc mapping.");
-out_invalidate:
- iomap_invalidatepage(page, pageoff, PAGE_SIZE - pageoff);
}

static const struct iomap_writeback_ops xfs_writeback_ops = {
--
2.43.0