The clean_pagecache and dirty_pagecache cases use shared file-backed
mappings to exercise page-cache memory-failure recovery.  These checks
assume local filesystem writeback and error-reporting semantics.

On NFS, the hard dirty-page case can complete hwpoison injection and
recovery, then report a delayed writeback error when the file is closed.
That failure reflects NFS writeback behavior rather than the page-cache
recovery path targeted by the test.

Extend the existing filesystem prerequisite check to reject NFS and
close the descriptor before skipping.  Other filesystem types retain the
existing injection and recovery checks.

Signed-off-by: Muhammad Usama Anjum <[email protected]>
---
 tools/testing/selftests/mm/memory-failure.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/mm/memory-failure.c 
b/tools/testing/selftests/mm/memory-failure.c
index 032ed952057c6..2e77f58406868 100644
--- a/tools/testing/selftests/mm/memory-failure.c
+++ b/tools/testing/selftests/mm/memory-failure.c
@@ -272,6 +272,11 @@ static int get_fs_type(int fd)
        return ret ? 0 : (int)fs.f_type;
 }
 
+static bool file_backed_test_supported(int fs_type)
+{
+       return fs_type && fs_type != TMPFS_MAGIC && fs_type != NFS_SUPER_MAGIC;
+}
+
 TEST_F(memory_failure, clean_pagecache)
 {
        int fd;
@@ -283,8 +288,10 @@ 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 (!file_backed_test_supported(fs_type)) {
+               close(fd);
                SKIP(return, "unsupported filesystem :%x\n", fs_type);
+       }
 
        addr = mmap(0, self->page_size, PROT_READ | PROT_WRITE,
                    MAP_SHARED, fd, 0);
@@ -325,8 +332,10 @@ TEST_F(memory_failure, dirty_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 (!file_backed_test_supported(fs_type)) {
+               close(fd);
                SKIP(return, "unsupported filesystem :%x\n", fs_type);
+       }
 
        addr = mmap(0, self->page_size, PROT_READ | PROT_WRITE,
                    MAP_SHARED, fd, 0);
-- 
2.47.3


Reply via email to