* [PATCH 1/9] selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache
@ 2026-11-28 6:51 Andrew Morton
2026-11-28 6:51 ` [PATCH 2/9] selftests/mm/memory-failure: truncate poisoned FUSE page-cache before teardown Andrew Morton
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Andrew Morton @ 2026-11-28 6:51 UTC (permalink / raw)
To: Kurt Lin
Cc: linux-mm, Andrew Morton, Miaohe Lin, Naoya Horiguchi,
David Hildenbrand, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Michal Hocko, Shuah Khan, Muhammad Usama Anjum,
Amir Goldstein, Eugenio Pérez, German Maglione,
Miklos Szeredi, Ryusuke Konishi, Stefan Hajnoczi, Vivek Goyal
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4207 bytes --]
From: Andrew Morton <akpm@linux-foundation.org>
Subject: selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache
Date: Mon, 23 Nov 2026 23:18:44 -0800
MADV_HWPOISON on a dirty page-cache page records -EIO in the mapping. The
test currently requires close() to succeed but never checks whether the
error was reported. Filesystems with ->flush() may return EIO from
close(), while those without it can leave the error unnoticed.
Require fsync() to return EIO after hard poisoning. It consumes the
mapping error before close(), allowing the NFS skip to go. The clean and
dirty page-cache cases also skip tmpfs, ramfs and hugetlbfs because they
have no backing store from which to reread a poisoned clean page.
With the complete selftest patch stack under x86_64 QEMU, ext4, FUSE and
NFSv4.2 reported 10 passes; NILFS2 reported 9 passes and 1 skip. The FUSE
server used for this test was a minimal server, not virtiofs.
Fixes: d51b5076c746 ("selftests/mm: add memory failure dirty pagecache test")
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Kurt Lin <lylin1023@gmail.com>
Closes: https://lore.kernel.org/20261123-memory-failure-fuse-skip-v1-1-19dcbda6e2e8@gmail.com
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Muhammad Usama Anjum <usama.anjum@arm.com>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Eugenio Pérez <eperezma@redhat.com>
Cc: German Maglione <gmaglione@redhat.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
tools/testing/selftests/mm/memory-failure.c | 38 ++++++++++++++----
1 file changed, 30 insertions(+), 8 deletions(-)
--- a/tools/testing/selftests/mm/memory-failure.c~selftests-mm-check-that-fsync-reports-hard-poisoned-dirty-page-cache
+++ a/tools/testing/selftests/mm/memory-failure.c
@@ -300,6 +300,29 @@ static int get_fs_type(int fd)
return ret ? 0 : (int)fs.f_type;
}
+/*
+ * The page-cache tests need a filesystem which keeps its data on backing
+ * store. When a clean page is poisoned the kernel drops it and the data is
+ * read back in. When a dirty page is poisoned the data is lost, and the
+ * kernel records -EIO in the mapping for fsync() to report.
+ *
+ * tmpfs and ramfs keep their data only in the page cache. The poisoned
+ * page cannot be dropped and read back, and their fsync() does nothing, so
+ * neither expectation holds. hugetlbfs is the same, and it also poisons a
+ * whole huge page. shmem has its own tests below.
+ */
+static bool fs_has_backing_store(int fs_type)
+{
+ switch ((unsigned int)fs_type) {
+ case 0:
+ case TMPFS_MAGIC:
+ case RAMFS_MAGIC:
+ case HUGETLBFS_MAGIC:
+ return false;
+ }
+ return true;
+}
+
TEST_F(memory_failure, clean_pagecache)
{
int fd;
@@ -311,7 +334,7 @@ TEST_F(memory_failure, clean_pagecache)
if (fd < 0)
SKIP(return, "failed to open test file.\n");
fs_type = get_fs_type(fd);
- if (!fs_type || fs_type == TMPFS_MAGIC) {
+ if (!fs_has_backing_store(fs_type)) {
close(fd);
SKIP(return, "unsupported filesystem :%x\n", fs_type);
}
@@ -353,13 +376,7 @@ TEST_F(memory_failure, dirty_pagecache)
if (fd < 0)
SKIP(return, "failed to open test file.\n");
fs_type = get_fs_type(fd);
- /*
- * MADV_HARD poisoning of dirty page-cache data records an expected
- * -EIO in the file mapping. NFS reports this error on close(), so
- * skip this variant.
- */
- if (!fs_type || fs_type == TMPFS_MAGIC ||
- (fs_type == NFS_SUPER_MAGIC && variant->type == MADV_HARD)) {
+ if (!fs_has_backing_store(fs_type)) {
close(fd);
SKIP(return, "unsupported filesystem :%x\n", fs_type);
}
@@ -386,6 +403,11 @@ TEST_F(memory_failure, dirty_pagecache)
ASSERT_EQ(munmap(addr, self->page_size), 0);
+ if (variant->type == MADV_HARD) {
+ ASSERT_EQ(fsync(fd), -1);
+ ASSERT_EQ(errno, EIO);
+ }
+
ASSERT_EQ(close(fd), 0);
}
_
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/9] selftests/mm/memory-failure: truncate poisoned FUSE page-cache before teardown
2026-11-28 6:51 [PATCH 1/9] selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache Andrew Morton
@ 2026-11-28 6:51 ` Andrew Morton
2026-11-28 6:52 ` [PATCH 3/9] selftests/mm/memory-failure: skip poisoned dirty page-cache on NILFS2 Andrew Morton
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-11-28 6:51 UTC (permalink / raw)
To: Kurt Lin
Cc: linux-mm, Andrew Morton, Miaohe Lin, Naoya Horiguchi,
David Hildenbrand, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Michal Hocko, Shuah Khan, Muhammad Usama Anjum,
Miklos Szeredi, Amir Goldstein, Eugenio Pérez,
German Maglione, Ryusuke Konishi, Stefan Hajnoczi, Vivek Goyal
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2098 bytes --]
From: Andrew Morton <akpm@linux-foundation.org>
Subject: selftests/mm/memory-failure: truncate poisoned FUSE page-cache before teardown
Date: Mon, 23 Nov 2026 23:18:44 -0800
FUSE has no ->error_remove_folio(), so memory_failure() cannot evict a
poisoned dirty page-cache page. The folio may remain after close() and
unpoison_memory() can then return -EBUSY during selftest teardown. In
tests with a minimal FUSE server, this happened in 6 of 40 runs.
After checking that fsync() reports EIO, truncate the file so teardown can
unpoison the page. Remove this cleanup when FUSE can evict the poisoned
folio.
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Muhammad Usama Anjum <usama.anjum@arm.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Eugenio Pérez <eperezma@redhat.com>
Cc: German Maglione <gmaglione@redhat.com>
Cc: Kurt Lin <lylin1023@gmail.com>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
tools/testing/selftests/mm/memory-failure.c | 7 +++++++
1 file changed, 7 insertions(+)
--- a/tools/testing/selftests/mm/memory-failure.c~selftests-mm-check-that-fsync-reports-hard-poisoned-dirty-page-cache-fix-0
+++ a/tools/testing/selftests/mm/memory-failure.c
@@ -406,6 +406,13 @@ TEST_F(memory_failure, dirty_pagecache)
if (variant->type == MADV_HARD) {
ASSERT_EQ(fsync(fd), -1);
ASSERT_EQ(errno, EIO);
+ /*
+ * A filesystem which could not remove the poisoned page from
+ * its page cache (FUSE, for one) keeps it until the inode is
+ * evicted, which can be after close() returns. Remove it now
+ * so that teardown can unpoison the page.
+ */
+ ASSERT_EQ(ftruncate(fd, 0), 0);
}
ASSERT_EQ(close(fd), 0);
_
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/9] selftests/mm/memory-failure: skip poisoned dirty page-cache on NILFS2
2026-11-28 6:51 [PATCH 1/9] selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache Andrew Morton
2026-11-28 6:51 ` [PATCH 2/9] selftests/mm/memory-failure: truncate poisoned FUSE page-cache before teardown Andrew Morton
@ 2026-11-28 6:52 ` Andrew Morton
2026-11-28 6:52 ` [PATCH 4/9] selftest/mm/memory-failure: keep page-cache files linked until cleanup Andrew Morton
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-11-28 6:52 UTC (permalink / raw)
To: Kurt Lin
Cc: linux-mm, Andrew Morton, Miaohe Lin, Naoya Horiguchi,
David Hildenbrand, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Michal Hocko, Shuah Khan, Muhammad Usama Anjum,
Ryusuke Konishi, Amir Goldstein, Eugenio Pérez,
German Maglione, Miklos Szeredi, Stefan Hajnoczi, Vivek Goyal
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2021 bytes --]
From: Andrew Morton <akpm@linux-foundation.org>
Subject: selftests/mm/memory-failure: skip poisoned dirty page-cache on NILFS2
Date: Mon, 23 Nov 2026 23:18:44 -0800
nilfs_sync_file() does not check the mapping error recorded when a dirty
page-cache page is hard-poisoned, so fsync() returns 0. Skip only this
NILFS2 case until fsync() reports EIO. The other NILFS2 page-cache tests
still run. On NILFS2 under x86_64 QEMU, the combined selftest reported 9
passes and 1 skip.
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Muhammad Usama Anjum <usama.anjum@arm.com>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Eugenio Pérez <eperezma@redhat.com>
Cc: German Maglione <gmaglione@redhat.com>
Cc: Kurt Lin <lylin1023@gmail.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
tools/testing/selftests/mm/memory-failure.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/tools/testing/selftests/mm/memory-failure.c~selftests-mm-check-that-fsync-reports-hard-poisoned-dirty-page-cache-fix-1
+++ a/tools/testing/selftests/mm/memory-failure.c
@@ -380,6 +380,14 @@ TEST_F(memory_failure, dirty_pagecache)
close(fd);
SKIP(return, "unsupported filesystem :%x\n", fs_type);
}
+ /*
+ * nilfs2 does not check the mapping error in nilfs_sync_file().
+ * Remove this skip when its fsync() reports poisoned dirty data.
+ */
+ if (fs_type == NILFS_SUPER_MAGIC && variant->type == MADV_HARD) {
+ close(fd);
+ SKIP(return, "nilfs2 fsync() does not report poisoned dirty data\n");
+ }
addr = mmap(0, self->page_size, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
_
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/9] selftest/mm/memory-failure: keep page-cache files linked until cleanup
2026-11-28 6:51 [PATCH 1/9] selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache Andrew Morton
2026-11-28 6:51 ` [PATCH 2/9] selftests/mm/memory-failure: truncate poisoned FUSE page-cache before teardown Andrew Morton
2026-11-28 6:52 ` [PATCH 3/9] selftests/mm/memory-failure: skip poisoned dirty page-cache on NILFS2 Andrew Morton
@ 2026-11-28 6:52 ` Andrew Morton
2026-11-28 6:52 ` [PATCH 5/9] selftests/mm/memory-failure: skip hard dirty page-cache test on CephFS Andrew Morton
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-11-28 6:52 UTC (permalink / raw)
To: Kurt Lin
Cc: linux-mm, Andrew Morton, Miaohe Lin, Naoya Horiguchi,
David Hildenbrand, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Michal Hocko, Shuah Khan, Muhammad Usama Anjum,
Amir Goldstein, Eugenio Pérez, German Maglione,
Miklos Szeredi, Ryusuke Konishi, Stefan Hajnoczi, Vivek Goyal
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4213 bytes --]
From: Andrew Morton <akpm@linux-foundation.org>
Subject: selftest/mm/memory-failure: keep page-cache files linked until cleanup
Date: Sun, 22 Nov 2026 20:36:33 -0800
The page-cache tests unlink their files immediately after open. On CIFS
and 9p, fstatfs() on the resulting descriptor fails with ENOENT, so all
four page-cache cases skip without testing the filesystem. Keeping the
file linked only through fstatfs() is insufficient: 9p also rejects the
ftruncate() after hard poisoning if the file has already been unlinked.
Keep each file linked until the test completes. Unlink it before close()
so a failed close assertion cannot leave the name for a later case. Also
remove it on the unsupported-filesystem, NILFS2 and mmap() skip paths.
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Kurt Lin <lylin1023@gmail.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Muhammad Usama Anjum <usama.anjum@arm.com>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Eugenio Pérez <eperezma@redhat.com>
Cc: German Maglione <gmaglione@redhat.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
tools/testing/selftests/mm/memory-failure.c | 25 ++++++++++++------
1 file changed, 18 insertions(+), 7 deletions(-)
--- a/tools/testing/selftests/mm/memory-failure.c~selftests-mm-check-that-fsync-reports-hard-poisoned-dirty-page-cache-fix-2
+++ a/tools/testing/selftests/mm/memory-failure.c
@@ -266,10 +266,8 @@ static int prepare_file(const char *fnam
int fd;
fd = open(fname, O_RDWR | O_CREAT, 0664);
- if (fd >= 0) {
- unlink(fname);
+ if (fd >= 0)
ftruncate(fd, size);
- }
return fd;
}
@@ -329,20 +327,25 @@ TEST_F(memory_failure, clean_pagecache)
char *addr;
int ret;
int fs_type;
+ const char *fname = "./clean-page-cache-test-file";
- fd = prepare_file("./clean-page-cache-test-file", self->page_size);
+ fd = prepare_file(fname, self->page_size);
if (fd < 0)
SKIP(return, "failed to open test file.\n");
fs_type = get_fs_type(fd);
if (!fs_has_backing_store(fs_type)) {
+ unlink(fname);
close(fd);
SKIP(return, "unsupported filesystem :%x\n", fs_type);
}
addr = mmap(0, self->page_size, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
- if (addr == MAP_FAILED)
+ if (addr == MAP_FAILED) {
+ unlink(fname);
+ close(fd);
SKIP(return, "mmap failed, not enough memory.\n");
+ }
memset(addr, 0xce, self->page_size);
fsync(fd);
@@ -362,6 +365,7 @@ TEST_F(memory_failure, clean_pagecache)
ASSERT_EQ(munmap(addr, self->page_size), 0);
+ unlink(fname);
ASSERT_EQ(close(fd), 0);
}
@@ -371,12 +375,14 @@ TEST_F(memory_failure, dirty_pagecache)
char *addr;
int ret;
int fs_type;
+ const char *fname = "./dirty-page-cache-test-file";
- fd = prepare_file("./dirty-page-cache-test-file", self->page_size);
+ fd = prepare_file(fname, self->page_size);
if (fd < 0)
SKIP(return, "failed to open test file.\n");
fs_type = get_fs_type(fd);
if (!fs_has_backing_store(fs_type)) {
+ unlink(fname);
close(fd);
SKIP(return, "unsupported filesystem :%x\n", fs_type);
}
@@ -385,14 +391,18 @@ TEST_F(memory_failure, dirty_pagecache)
* Remove this skip when its fsync() reports poisoned dirty data.
*/
if (fs_type == NILFS_SUPER_MAGIC && variant->type == MADV_HARD) {
+ unlink(fname);
close(fd);
SKIP(return, "nilfs2 fsync() does not report poisoned dirty data\n");
}
addr = mmap(0, self->page_size, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
- if (addr == MAP_FAILED)
+ if (addr == MAP_FAILED) {
+ unlink(fname);
+ close(fd);
SKIP(return, "mmap failed, not enough memory.\n");
+ }
memset(addr, 0xce, self->page_size);
prepare(_metadata, self, addr);
@@ -423,6 +433,7 @@ TEST_F(memory_failure, dirty_pagecache)
ASSERT_EQ(ftruncate(fd, 0), 0);
}
+ unlink(fname);
ASSERT_EQ(close(fd), 0);
}
_
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/9] selftests/mm/memory-failure: skip hard dirty page-cache test on CephFS
2026-11-28 6:51 [PATCH 1/9] selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache Andrew Morton
` (2 preceding siblings ...)
2026-11-28 6:52 ` [PATCH 4/9] selftest/mm/memory-failure: keep page-cache files linked until cleanup Andrew Morton
@ 2026-11-28 6:52 ` Andrew Morton
2026-11-28 6:52 ` [PATCH 6/9] selftests/mm/memory-failure: close dirty page-cache files before unlinking them Andrew Morton
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-11-28 6:52 UTC (permalink / raw)
To: Kurt Lin
Cc: linux-mm, Andrew Morton, Amir Goldstein, David Hildenbrand,
Eugenio Pérez, German Maglione, Liam R. Howlett, Miaohe Lin,
Michal Hocko, Mike Rapoport, Miklos Szeredi, Muhammad Usama Anjum,
Naoya Horiguchi, Ryusuke Konishi, Shuah Khan, Stefan Hajnoczi,
Vivek Goyal, Vlastimil Babka
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2486 bytes --]
From: Andrew Morton <akpm@linux-foundation.org>
Subject: selftests/mm/memory-failure: skip hard dirty page-cache test on CephFS
Date: Mon, 23 Nov 2026 08:29:47 -0800
CephFS loses the mapping error from a hard-poisoned dirty page:
file_write_and_wait_range() returns -EIO and advances the file's
writeback-error cursor, but ceph_fsync() overwrites that return value
with a successful ceph_wait_on_async_create(). Its later error check
finds nothing, so fsync() returns zero.
In a CephFS QEMU guest, the hard-dirty selftest then failed its fsync()
assertion. The page remained poisoned, teardown returned -EBUSY, and
the following soft-dirty test died on the file left behind by the
failed hard-dirty test. The soft-dirty test passed on a fresh file.
Skip only the CephFS hard-dirty case before poisoning the page. The
other CephFS tests still run. Remove the skip when ceph_fsync() reports
the writeback error.
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Eugenio Pérez <eperezma@redhat.com>
Cc: German Maglione <gmaglione@redhat.com>
Cc: Kurt Lin <lylin1023@gmail.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Muhammad Usama Anjum <usama.anjum@arm.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
tools/testing/selftests/mm/memory-failure.c | 9 +++++++++
1 file changed, 9 insertions(+)
--- a/tools/testing/selftests/mm/memory-failure.c~selftests-mm-check-that-fsync-reports-hard-poisoned-dirty-page-cache-fix-3
+++ a/tools/testing/selftests/mm/memory-failure.c
@@ -395,6 +395,15 @@ TEST_F(memory_failure, dirty_pagecache)
close(fd);
SKIP(return, "nilfs2 fsync() does not report poisoned dirty data\n");
}
+ /*
+ * ceph_fsync() loses the writeback error recorded for a poisoned
+ * dirty page. Remove this skip when it preserves that error.
+ */
+ if (fs_type == CEPH_SUPER_MAGIC && variant->type == MADV_HARD) {
+ unlink(fname);
+ close(fd);
+ SKIP(return, "cephfs fsync() does not report poisoned dirty data\n");
+ }
addr = mmap(0, self->page_size, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
_
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 6/9] selftests/mm/memory-failure: close dirty page-cache files before unlinking them
2026-11-28 6:51 [PATCH 1/9] selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache Andrew Morton
` (3 preceding siblings ...)
2026-11-28 6:52 ` [PATCH 5/9] selftests/mm/memory-failure: skip hard dirty page-cache test on CephFS Andrew Morton
@ 2026-11-28 6:52 ` Andrew Morton
2026-11-28 6:52 ` [PATCH 7/9] selftests/mm/memory-failure: extend page-cache test files with pwrite() Andrew Morton
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-11-28 6:52 UTC (permalink / raw)
To: Kurt Lin
Cc: linux-mm, Andrew Morton, Amir Goldstein, David Hildenbrand,
Eugenio Pérez, German Maglione, Liam R. Howlett, Miaohe Lin,
Michal Hocko, Mike Rapoport, Miklos Szeredi, Muhammad Usama Anjum,
Naoya Horiguchi, Ryusuke Konishi, Shuah Khan, Stefan Hajnoczi,
Vivek Goyal, Vlastimil Babka
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2236 bytes --]
From: Andrew Morton <akpm@linux-foundation.org>
Subject: selftests/mm/memory-failure: close dirty page-cache files before unlinking them
Date: Mon, 23 Nov 2026 08:50:00 -0800
OrangeFS writes dirty page-cache data from close(). In the soft-offline
case, unlinking the file first removes its server-side handle. Writeback
then returns -ENOENT, which makes close() fail even though soft offlining
itself succeeded. The hard-poison case avoids this because it truncates
the file before closing it.
Close the file while it is still linked. Save the close() return value
and unlink before asserting so a failed close does not leave the file
behind for the next test.
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Eugenio Pérez <eperezma@redhat.com>
Cc: German Maglione <gmaglione@redhat.com>
Cc: Kurt Lin <lylin1023@gmail.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Muhammad Usama Anjum <usama.anjum@arm.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
tools/testing/selftests/mm/memory-failure.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
--- a/tools/testing/selftests/mm/memory-failure.c~selftests-mm-check-that-fsync-reports-hard-poisoned-dirty-page-cache-fix-4
+++ a/tools/testing/selftests/mm/memory-failure.c
@@ -442,8 +442,16 @@ TEST_F(memory_failure, dirty_pagecache)
ASSERT_EQ(ftruncate(fd, 0), 0);
}
+ /*
+ * OrangeFS writes dirty pages from close(). Unlinking first removes
+ * the server's file handle, so writeback returns -ENOENT and close()
+ * fails. Close while the file is still linked. Remove the name
+ * before checking the result so a failed close cannot leave a file
+ * for the next test.
+ */
+ ret = close(fd);
unlink(fname);
- ASSERT_EQ(close(fd), 0);
+ ASSERT_EQ(ret, 0);
}
TEST_F(memory_failure, dirty_shmem)
_
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 7/9] selftests/mm/memory-failure: extend page-cache test files with pwrite()
2026-11-28 6:51 [PATCH 1/9] selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache Andrew Morton
` (4 preceding siblings ...)
2026-11-28 6:52 ` [PATCH 6/9] selftests/mm/memory-failure: close dirty page-cache files before unlinking them Andrew Morton
@ 2026-11-28 6:52 ` Andrew Morton
2026-11-28 6:52 ` [PATCH 8/9] selftests/mm/memory-failure: write the whole page-cache test file for OMFS Andrew Morton
2026-11-28 6:52 ` [PATCH 9/9] selftests/mm/memory-failure: accept EIO from close after poisoning dirty data Andrew Morton
7 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-11-28 6:52 UTC (permalink / raw)
To: Kurt Lin
Cc: linux-mm, Andrew Morton, Amir Goldstein, David Hildenbrand,
Eugenio Pérez, German Maglione, Liam R. Howlett, Miaohe Lin,
Michal Hocko, Mike Rapoport, Miklos Szeredi, Muhammad Usama Anjum,
Naoya Horiguchi, Ryusuke Konishi, Shuah Khan, Stefan Hajnoczi,
Vivek Goyal, Vlastimil Babka
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2235 bytes --]
From: Andrew Morton <akpm@linux-foundation.org>
Subject: selftests/mm/memory-failure: extend page-cache test files with pwrite()
Date: Mon, 23 Nov 2026 09:58:07 -0800
HPFS does not allow ftruncate() to grow a file. prepare_file() ignores
the failure, so the page-cache tests mmap an empty file and die before
they can inject a memory failure or check fsync().
Write a zero byte at the end of the requested size instead. This grows
the file on HPFS and leaves zero-filled data for the existing tests.
Open with O_TRUNC so a file left by an interrupted test starts empty,
and check the write result before returning the descriptor.
On an HPFS image, the existing test passed 6 of 10 cases. With this
change, a diagnostic build passed all 10, including the hard-poisoned
dirty page-cache case.
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Eugenio Pérez <eperezma@redhat.com>
Cc: German Maglione <gmaglione@redhat.com>
Cc: Kurt Lin <lylin1023@gmail.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Muhammad Usama Anjum <usama.anjum@arm.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
tools/testing/selftests/mm/memory-failure.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
--- a/tools/testing/selftests/mm/memory-failure.c~selftests-mm-check-that-fsync-reports-hard-poisoned-dirty-page-cache-fix-5
+++ a/tools/testing/selftests/mm/memory-failure.c
@@ -265,9 +265,16 @@ static int prepare_file(const char *fnam
{
int fd;
- fd = open(fname, O_RDWR | O_CREAT, 0664);
- if (fd >= 0)
- ftruncate(fd, size);
+ fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, 0664);
+ if (fd < 0)
+ return fd;
+
+ /* HPFS cannot grow files with ftruncate(). */
+ if (pwrite(fd, "\0", 1, size - 1) != 1) {
+ close(fd);
+ unlink(fname);
+ return -1;
+ }
return fd;
}
_
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 8/9] selftests/mm/memory-failure: write the whole page-cache test file for OMFS
2026-11-28 6:51 [PATCH 1/9] selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache Andrew Morton
` (5 preceding siblings ...)
2026-11-28 6:52 ` [PATCH 7/9] selftests/mm/memory-failure: extend page-cache test files with pwrite() Andrew Morton
@ 2026-11-28 6:52 ` Andrew Morton
2026-11-28 6:52 ` [PATCH 9/9] selftests/mm/memory-failure: accept EIO from close after poisoning dirty data Andrew Morton
7 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-11-28 6:52 UTC (permalink / raw)
To: Kurt Lin
Cc: linux-mm, Andrew Morton, Amir Goldstein, David Hildenbrand,
Eugenio Pérez, German Maglione, Liam R. Howlett, Miaohe Lin,
Michal Hocko, Mike Rapoport, Miklos Szeredi, Muhammad Usama Anjum,
Naoya Horiguchi, Ryusuke Konishi, Shuah Khan, Stefan Hajnoczi,
Vivek Goyal, Vlastimil Babka
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3017 bytes --]
From: Andrew Morton <akpm@linux-foundation.org>
Subject: selftests/mm/memory-failure: write the whole page-cache test file for OMFS
Date: Mon, 23 Nov 2026 10:46:15 -0800
"selftests/mm/memory-failure: extend page-cache test files with pwrite()"
grows the page-cache test file by writing one byte at the end. That works
on HPFS, but leaves a hole on OMFS, whose extent allocation does not
support holes. After a mapped write and fsync(), the file still has the
expected contents in cache. On remount, 2048 of its 4096 bytes have
changed, so the hard-clean-page test fails when poisoning drops the cached
page and rereads the file.
Write a full page of zeroes from offset zero. This still grows the file
on HPFS and allocates all its blocks on OMFS before the test maps it.
Check the write and clean up on failure as before. In a diagnostic OMFS
guest, the test passed 9 of 10 cases with fix-5 and 10 of 10 with the
full-page write.
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Eugenio Pérez <eperezma@redhat.com>
Cc: German Maglione <gmaglione@redhat.com>
Cc: Kurt Lin <lylin1023@gmail.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Muhammad Usama Anjum <usama.anjum@arm.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
tools/testing/selftests/mm/memory-failure.c | 25 +++++++++++++-----
1 file changed, 19 insertions(+), 6 deletions(-)
--- a/tools/testing/selftests/mm/memory-failure.c~selftests-mm-check-that-fsync-reports-hard-poisoned-dirty-page-cache-fix-6
+++ a/tools/testing/selftests/mm/memory-failure.c
@@ -17,6 +17,7 @@
#include <sys/vfs.h>
#include <linux/magic.h>
#include <errno.h>
+#include <stdlib.h>
#include "vm_util.h"
@@ -264,18 +265,30 @@ TEST_F(memory_failure, anon)
static int prepare_file(const char *fname, unsigned long size)
{
int fd;
+ char *zeros;
+ ssize_t written;
fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, 0664);
if (fd < 0)
return fd;
- /* HPFS cannot grow files with ftruncate(). */
- if (pwrite(fd, "\0", 1, size - 1) != 1) {
- close(fd);
- unlink(fname);
- return -1;
- }
+ /*
+ * HPFS cannot grow files with ftruncate(), and OMFS does not support
+ * holes. Write the whole page so OMFS allocates its blocks before
+ * mmap(). A write of only the last byte loses data after eviction.
+ */
+ zeros = calloc(size, 1);
+ if (!zeros)
+ goto failed;
+ written = pwrite(fd, zeros, size, 0);
+ free(zeros);
+ if (written != (ssize_t)size)
+ goto failed;
return fd;
+failed:
+ close(fd);
+ unlink(fname);
+ return -1;
}
static int prepare_shmem(const char *fname, unsigned long size)
_
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 9/9] selftests/mm/memory-failure: accept EIO from close after poisoning dirty data
2026-11-28 6:51 [PATCH 1/9] selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache Andrew Morton
` (6 preceding siblings ...)
2026-11-28 6:52 ` [PATCH 8/9] selftests/mm/memory-failure: write the whole page-cache test file for OMFS Andrew Morton
@ 2026-11-28 6:52 ` Andrew Morton
7 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-11-28 6:52 UTC (permalink / raw)
To: Kurt Lin
Cc: linux-mm, Andrew Morton, Miaohe Lin, Naoya Horiguchi,
David Hildenbrand, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Michal Hocko, Shuah Khan, Miklos Szeredi,
Amir Goldstein, German Maglione, Vivek Goyal, Stefan Hajnoczi,
Eugenio Pérez, Muhammad Usama Anjum, Ryusuke Konishi
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2387 bytes --]
From: Andrew Morton <akpm@linux-foundation.org>
Subject: selftests/mm/memory-failure: accept EIO from close after poisoning dirty data
Date: Mon, 23 Nov 2026 19:38:37 -0800
On overlayfs with a virtiofs upper, poisoning a dirty page makes fsync()
return -EIO as expected. close() can return -EIO again after ftruncate()
removes the poisoned page. The selftest currently fails because it requires
close() to return zero after fsync() has reported the error.
Accept a second -EIO from close() only in the hard-poison dirty-page test,
where fsync() has already been checked for -EIO. Continue to reject other
close() errors. With the virtiofs export owned by the daemon's UID and GID,
all ten overlayfs tests pass with no skips; before this change the dirty
hard-poison case failed at close().
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: German Maglione <gmaglione@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Eugenio Pérez <eperezma@redhat.com>
Cc: Kurt Lin <lylin1023@gmail.com>
Cc: Muhammad Usama Anjum <usama.anjum@arm.com>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
tools/testing/selftests/mm/memory-failure.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/tools/testing/selftests/mm/memory-failure.c~selftests-mm-check-that-fsync-reports-hard-poisoned-dirty-page-cache-fix-7
+++ a/tools/testing/selftests/mm/memory-failure.c
@@ -468,8 +468,14 @@ TEST_F(memory_failure, dirty_pagecache)
* fails. Close while the file is still linked. Remove the name
* before checking the result so a failed close cannot leave a file
* for the next test.
+ *
+ * With a virtiofs upper, overlayfs can also report -EIO from close()
+ * after fsync() has reported the poisoned dirty page. Accept this
+ * second error only for the hard-poison test and only if it is -EIO.
*/
ret = close(fd);
+ if (ret < 0 && variant->type == MADV_HARD)
+ ret = errno == EIO ? 0 : ret;
unlink(fname);
ASSERT_EQ(ret, 0);
}
_
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-11-28 6:52 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 6:51 [PATCH 1/9] selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache Andrew Morton
2026-11-28 6:51 ` [PATCH 2/9] selftests/mm/memory-failure: truncate poisoned FUSE page-cache before teardown Andrew Morton
2026-11-28 6:52 ` [PATCH 3/9] selftests/mm/memory-failure: skip poisoned dirty page-cache on NILFS2 Andrew Morton
2026-11-28 6:52 ` [PATCH 4/9] selftest/mm/memory-failure: keep page-cache files linked until cleanup Andrew Morton
2026-11-28 6:52 ` [PATCH 5/9] selftests/mm/memory-failure: skip hard dirty page-cache test on CephFS Andrew Morton
2026-11-28 6:52 ` [PATCH 6/9] selftests/mm/memory-failure: close dirty page-cache files before unlinking them Andrew Morton
2026-11-28 6:52 ` [PATCH 7/9] selftests/mm/memory-failure: extend page-cache test files with pwrite() Andrew Morton
2026-11-28 6:52 ` [PATCH 8/9] selftests/mm/memory-failure: write the whole page-cache test file for OMFS Andrew Morton
2026-11-28 6:52 ` [PATCH 9/9] selftests/mm/memory-failure: accept EIO from close after poisoning dirty data Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox