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