From: Andrew Morton 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 Cc: Amir Goldstein Cc: David Hildenbrand Cc: Eugenio Pérez Cc: German Maglione Cc: Kurt Lin Cc: Liam R. Howlett Cc: Miaohe Lin Cc: Michal Hocko Cc: Mike Rapoport Cc: Miklos Szeredi Cc: Muhammad Usama Anjum Cc: Naoya Horiguchi Cc: Ryusuke Konishi Cc: Shuah Khan Cc: Stefan Hajnoczi Cc: Vivek Goyal Cc: Vlastimil Babka 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) _