diff mbox series

[v2,8/9] selftests/mm: Skip map_populate on weird filesystems

Message ID 20250221-mm-selftests-v2-8-28c4d66383c5@google.com
State Superseded
Headers show
Series selftests/mm: Some cleanups from trying to run them | expand

Commit Message

Brendan Jackman Feb. 21, 2025, 6:25 p.m. UTC
It seems that 9pfs does not allow truncating unlinked files, Mark Brown
has noted that NFS may also behave this way.

It doesn't seem quite right to call this a "bug" but it's probably a
special enough case that it makes sense for the test to just SKIP if it
happens.

Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
 tools/testing/selftests/mm/map_populate.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Brendan Jackman Feb. 24, 2025, 10:25 a.m. UTC | #1
On Fri, 21 Feb 2025 at 19:26, Brendan Jackman <jackmanb@google.com> wrote:
>
> It seems that 9pfs does not allow truncating unlinked files, Mark Brown
> has noted that NFS may also behave this way.

I have not investigated at all but I _think_ over the weekend I saw
ftruncate() failure on a QEMU guest where /tmp was tmpfs.

Most likely explanation is user probably error (like /tmp wasn't
actually tmpfs or the tmpfile() did not actually come from /tmp). But
still, maybe just waving my hands and going "buggy filesystem, ignore"
wasn't so smart. I should actually understand the problem before
switching off tests.

So, I think this and the other "ignore on weird filesystem" patch 9/9
should be ignored for the moment.
Brendan Jackman Feb. 27, 2025, 12:58 p.m. UTC | #2
On Mon, 24 Feb 2025 at 11:25, Brendan Jackman <jackmanb@google.com> wrote:
>
> On Fri, 21 Feb 2025 at 19:26, Brendan Jackman <jackmanb@google.com> wrote:
> >
> > It seems that 9pfs does not allow truncating unlinked files, Mark Brown
> > has noted that NFS may also behave this way.
>
> I have not investigated at all but I _think_ over the weekend I saw
> ftruncate() failure on a QEMU guest where /tmp was tmpfs.
>
> Most likely explanation is user probably error (like /tmp wasn't
> actually tmpfs or the tmpfile() did not actually come from /tmp).

OK I double checked. It was in fact a 9p filesystem, turns out
virtme-ng uses that unconditionally for its --rwdir/--rodir mounts
even if the root is virtiofsd, and the tests operate on files in the
CWD as well as in /tmp.

I am still pondering ways to tackle this kinda problem more
systematically but for now I think just skipping these tests is fine.

> +               ksft_exit_skip("ftruncate(fileno(tmpfile())) gave ENOENT, weird filesystem?");

This is missing a newline though, ditto in the subsequent patch. I
will wait and see if any reviews come in before I send a fixup.
diff mbox series

Patch

diff --git a/tools/testing/selftests/mm/map_populate.c b/tools/testing/selftests/mm/map_populate.c
index 5c8a53869b1bd287b09a250edf628a66c25c2439..cdd88531dd9fe98f2d25edf4878659767c919e8e 100644
--- a/tools/testing/selftests/mm/map_populate.c
+++ b/tools/testing/selftests/mm/map_populate.c
@@ -87,6 +87,13 @@  int main(int argc, char **argv)
 	BUG_ON(!ftmp, "tmpfile()");
 
 	ret = ftruncate(fileno(ftmp), MMAP_SZ);
+	if (ret < 0 && errno == ENOENT) {
+		/*
+		 * This probably means tmpfile() made a file on a filesystem
+		 * that doesn't handle temporary files the way we want.
+		 */
+		ksft_exit_skip("ftruncate(fileno(tmpfile())) gave ENOENT, weird filesystem?");
+	}
 	BUG_ON(ret, "ftruncate()");
 
 	smap = mmap(0, MMAP_SZ, PROT_READ | PROT_WRITE,