Re: [PATCH RESEND v1 1/5] selftests/mm: skip COW tmpfile cases when fallocate() is unsupported
From: Sarthak Sharma
Date: Thu Jul 23 2026 - 02:29:27 EST
On 7/22/26 2:41 PM, Muhammad Usama Anjum wrote:
> The tmpfile-backed COW cases allocate a one-page file with fallocate()
> before exercising private and shared mappings. When the filesystem
> backing tmpfile() does not implement fallocate(), setup fails with
> EOPNOTSUPP and no COW behavior is exercised.
>
> This occurs when the temporary directory resides on a filesystem with
> limited allocation support, such as NFSv3. Reporting a failure adds
> noise because the test prerequisite is absent rather than the COW
> implementation being broken.
>
> Report EOPNOTSUPP as a skip. Continue treating every other fallocate()
> error as a failure so unexpected setup regressions remain visible.
>
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@xxxxxxx>
I've tested this patch on a QEMU with ramfs mounted over /tmp, which
does not support fallocate().
Before applying the patch, 3 tests (Basic COW with tmpfile, R/O longterm
GUP pin with tmpfile and R/O longterm GUP-fast pin with tmpfile) failed
with
# fallocate() failed: Operation not supported (95)
After applying the patch, these tests are skipped.
Tested-by: Sarthak Sharma <sarthak.sharma@xxxxxxx>
> ---
> tools/testing/selftests/mm/cow.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
> index 0c627ea89ff7b..c1b8920e29342 100644
> --- a/tools/testing/selftests/mm/cow.c
> +++ b/tools/testing/selftests/mm/cow.c
> @@ -1718,8 +1718,13 @@ static void run_with_tmpfile(non_anon_test_fn fn, const char *desc)
>
> /* File consists of a single page filled with zeroes. */
> if (fallocate(fd, 0, 0, pagesize)) {
> - ksft_perror("fallocate() failed");
> - log_test_result(KSFT_FAIL);
> + if (errno == EOPNOTSUPP) {
> + ksft_print_msg("fallocate() not supported by filesystem\n");
> + log_test_result(KSFT_SKIP);
> + } else {
> + ksft_perror("fallocate() failed");
> + log_test_result(KSFT_FAIL);
> + }
> goto close;
> }
>