All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Kurt Lin <lylin1023@gmail.com>
Cc: linux-mm@kvack.org, "Andrew Morton" <akpm@linux-foundation.org>,
	"Miaohe Lin" <linmiaohe@huawei.com>,
	"Naoya Horiguchi" <nao.horiguchi@gmail.com>,
	"David Hildenbrand" <david@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	"Vlastimil Babka" <vbabka@kernel.org>,
	"Mike Rapoport" <rppt@kernel.org>,
	"Michal Hocko" <mhocko@suse.com>, "Shuah Khan" <shuah@kernel.org>,
	"Muhammad Usama Anjum" <usama.anjum@arm.com>,
	"Amir Goldstein" <amir73il@gmail.com>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"German Maglione" <gmaglione@redhat.com>,
	"Miklos Szeredi" <miklos@szeredi.hu>,
	"Ryusuke Konishi" <konishi.ryusuke@gmail.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Vivek Goyal" <vgoyal@redhat.com>
Subject: [PATCH 4/9] selftest/mm/memory-failure: keep page-cache files linked until cleanup
Date: Fri, 27 Nov 2026 22:52:04 -0800	[thread overview]
Message-ID: <1c93b263b19d4465899bb81efd62bcb3.4@linux-foundation.org> (raw)
In-Reply-To: <1c93b263b19d4465899bb81efd62bcb3.1@linux-foundation.org>

[-- 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);
 }
 
_


  parent reply	other threads:[~2026-11-28  6:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-11-29  6:52   ` [PATCH 4/9] selftest/mm/memory-failure: keep page-cache files linked until cleanup sashiko-bot
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
2026-11-28 18:36 ` [PATCH 1/9] selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache Kurt Lin
2026-12-01  7:13   ` Miaohe Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1c93b263b19d4465899bb81efd62bcb3.4@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=amir73il@gmail.com \
    --cc=david@kernel.org \
    --cc=eperezma@redhat.com \
    --cc=gmaglione@redhat.com \
    --cc=konishi.ryusuke@gmail.com \
    --cc=liam@infradead.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-mm@kvack.org \
    --cc=lylin1023@gmail.com \
    --cc=mhocko@suse.com \
    --cc=miklos@szeredi.hu \
    --cc=nao.horiguchi@gmail.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=stefanha@redhat.com \
    --cc=usama.anjum@arm.com \
    --cc=vbabka@kernel.org \
    --cc=vgoyal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.