Skip to contentSkip to conversation

fuse: let memory-failure remove poisoned page-cache folios

PATCH In review Andrew Morton 2 participants 2 messages Nov 28 FUSE filesystem core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fuse: let memory-failure remove poisoned page-cache folios

From: Andrew Morton <[email protected]>
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.

Cc Miklos Szeredi <[email protected]>
Cc Miaohe Lin <[email protected]>
Cc Naoya Horiguchi <[email protected]>
Cc Kurt Lin <[email protected]>
 fs/fuse/file.c |    1 +
 1 file changed, 1 insertion(+)
fs/fuse/file.c renamed from fs/fuse/file.c~fuse-let-memory-failure-remove-poisoned-page-cache-folios +1 -0
@@ -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,

_

Tested-by on v1 1/1
#1 lore raw
Quoted 4 lines · Andrew Morton

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.

Tested on virtiofs, without DAX, in a virtme-ng guest, using the memory-failure selftest's hard dirty_pagecache case (MADV_HWPOISON). Both kernels are mm-new 87cdbd9bd631, one with only this patch reverted, 21 runs each:

  kernel                     recovery action for dirty LRU page
  87cdbd9bd631 + revert      Failed (after "Failed to invalidate")
  87cdbd9bd631               Recovered

On ext4 both kernels report Recovered. With the patch, the memory-failure selftest from mm-unstable also passes 50 of 50 runs from virtiofs. DAX and a real memory error are still not tested.

Tested with the help of an AI coding assistant.