Skip to content

Commit d8a866c

Browse files
bjackmanakpm00
authored andcommitted
selftests/mm: add commentary about 9pfs bugs
As discussed here: https://lore.kernel.org/lkml/[email protected]/ This code could benefit from some more commentary. To avoid needing to comment the same thing in multiple places (I guess more of these SKIPs will need to be added over time, for now I am only like 20% of the way through Project Run run_vmtests.sh Successfully), add a dummy "skip tests for this specific reason" function that basically just serves as a hook to hang comments on. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Brendan Jackman <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent b25bcab commit d8a866c

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

tools/testing/selftests/mm/gup_longterm.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,7 @@ static void do_test(int fd, size_t size, enum test_type type, bool shared)
9797

9898
if (ftruncate(fd, size)) {
9999
if (errno == ENOENT) {
100-
/*
101-
* This can happen if the file has been unlinked and the
102-
* filesystem doesn't support truncating unlinked files.
103-
*/
104-
ksft_test_result_skip("ftruncate() failed with ENOENT\n");
100+
skip_test_dodgy_fs("ftruncate()");
105101
} else {
106102
ksft_test_result_fail("ftruncate() failed (%s)\n", strerror(errno));
107103
}

tools/testing/selftests/mm/map_populate.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <unistd.h>
1919
#include "../kselftest.h"
2020

21+
#include "vm_util.h"
22+
2123
#define MMAP_SZ 4096
2224

2325
#define BUG_ON(condition, description) \
@@ -88,11 +90,7 @@ int main(int argc, char **argv)
8890

8991
ret = ftruncate(fileno(ftmp), MMAP_SZ);
9092
if (ret < 0 && errno == ENOENT) {
91-
/*
92-
* This probably means tmpfile() made a file on a filesystem
93-
* that doesn't handle temporary files the way we want.
94-
*/
95-
ksft_exit_skip("ftruncate(fileno(tmpfile())) gave ENOENT, weird filesystem?\n");
93+
skip_test_dodgy_fs("ftruncate()");
9694
}
9795
BUG_ON(ret, "ftruncate()");
9896

tools/testing/selftests/mm/vm_util.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <err.h>
66
#include <strings.h> /* ffsl() */
77
#include <unistd.h> /* _SC_PAGESIZE */
8+
#include "../kselftest.h"
89

910
#define BIT_ULL(nr) (1ULL << (nr))
1011
#define PM_SOFT_DIRTY BIT_ULL(55)
@@ -32,6 +33,23 @@ static inline unsigned int pshift(void)
3233
return __page_shift;
3334
}
3435

36+
/*
37+
* Plan 9 FS has bugs (at least on QEMU) where certain operations fail with
38+
* ENOENT on unlinked files. See
39+
* https://gitlab.com/qemu-project/qemu/-/issues/103 for some info about such
40+
* bugs. There are rumours of NFS implementations with similar bugs.
41+
*
42+
* Ideally, tests should just detect filesystems known to have such issues and
43+
* bail early. But 9pfs has the additional "feature" that it causes fstatfs to
44+
* pass through the f_type field from the host filesystem. To avoid having to
45+
* scrape /proc/mounts or some other hackery, tests can call this function when
46+
* it seems such a bug might have been encountered.
47+
*/
48+
static inline void skip_test_dodgy_fs(const char *op_name)
49+
{
50+
ksft_test_result_skip("%s failed with ENOENT. Filesystem might be buggy (9pfs?)\n", op_name);
51+
}
52+
3553
uint64_t pagemap_get_entry(int fd, char *start);
3654
bool pagemap_is_softdirty(int fd, char *start);
3755
bool pagemap_is_swapped(int fd, char *start);

0 commit comments

Comments
 (0)