All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fuse: let memory-failure remove poisoned page-cache folios
@ 2026-11-28  6:30 Andrew Morton
  2026-11-28 18:36 ` Kurt Lin
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2026-11-28  6:30 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: fuse-devel, Andrew Morton, Miaohe Lin, Naoya Horiguchi, Kurt Lin

From: Andrew Morton <akpm@linux-foundation.org>
Subject: fuse: let memory-failure remove poisoned page-cache folios
Date: Sun, 22 Nov 2026 14:45:24 -0800

fuse_file_aops has no ->error_remove_folio().  memory_failure() then
falls back to mapping_evict_folio(), which cannot remove a dirty folio.
So when a dirty FUSE page-cache page is hard-poisoned, recovery fails:

  Memory failure: 0x7ffce: Failed to invalidate
  Memory failure: 0x7ffce: dirty LRU page still referenced by 1 users
  Memory failure: 0x7ffce: recovery action for dirty LRU page: Failed

madvise(MADV_HWPOISON) returns -EBUSY.  The poisoned folio stays in the
page cache, and the kernel later reads it again to write it back to the
server.  With a real uncorrected memory error that is a second access to
bad memory.

The poisoned folio also outlives the last close() of an unlinked file by
however long the inode takes to be evicted.  The memory-failure selftest
unpoisons the page in its teardown and that failed with -EBUSY in 6 of 40
runs on FUSE.

Set ->error_remove_folio() to generic_error_remove_folio(), as ext4, xfs,
btrfs, NFS and others do.  The folio is then truncated at the time of the
error:

  Memory failure: 0x7dcf5: recovery action for dirty LRU page: Recovered

madvise() returns 0 and nothing is written back.  The -EIO which
memory_failure() records in the mapping is reported exactly as before:
by the first fsync(), or by close() if FOPEN_NOFLUSH is not in effect.

Tested on x86_64 under QEMU with a minimal /dev/fuse server and simulated
poison (MADV_HWPOISON), with and without the writeback cache and with
FOPEN_NOFLUSH.  The memory-failure selftest then passes 40 of 40 runs on
FUSE.  Not tested: virtiofs, DAX, a real memory error.

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Kurt Lin <lylin1023@gmail.com>

 fs/fuse/file.c |    1 +
 1 file changed, 1 insertion(+)

--- a/fs/fuse/file.c~fuse-let-memory-failure-remove-poisoned-page-cache-folios
+++ a/fs/fuse/file.c
@@ -3185,6 +3185,7 @@ static const struct address_space_operat
 	.readahead	= fuse_readahead,
 	.writepages	= fuse_writepages,
 	.launder_folio	= fuse_launder_folio,
+	.error_remove_folio = generic_error_remove_folio,
 	.dirty_folio	= iomap_dirty_folio,
 	.release_folio	= iomap_release_folio,
 	.invalidate_folio = iomap_invalidate_folio,
_

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-30  7:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28  6:30 [PATCH] fuse: let memory-failure remove poisoned page-cache folios Andrew Morton
2026-11-28 18:36 ` Kurt Lin
2026-11-30  7:00   ` Miaohe Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.