* [LTP] [PATCH] refluxfs: Check kernel reflink support before mount
@ 2026-08-12 15:22 Martin Doucha
2026-08-12 15:49 ` Cyril Hrubis
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Martin Doucha @ 2026-08-12 15:22 UTC (permalink / raw)
To: ltp
On some systems, mkfs.xfs can format XFS partition with reflink support
but the kernel then cannot mount it. Check for kernel reflink support
in setup() before mount.
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
testcases/cve/refluxfs.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/testcases/cve/refluxfs.c b/testcases/cve/refluxfs.c
index e41f35c53..277d56bb7 100644
--- a/testcases/cve/refluxfs.c
+++ b/testcases/cve/refluxfs.c
@@ -38,6 +38,7 @@
*/
#include <pwd.h>
+#include <sys/mount.h>
#include "tst_test.h"
#include "tst_safe_prw.h"
@@ -94,6 +95,15 @@ static void setup(void)
int probe_fd, probe_dio_fd;
struct stat sb;
+ SAFE_MKDIR(MNTPOINT, 0755);
+ TEST(mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL));
+
+ if (TST_RET == -1 && TST_ERR == EOPNOTSUPP)
+ tst_brk(TCONF, "Kernel does not support XFS reflinks");
+
+ if (TST_RET)
+ tst_brk(TBROK | TTERRNO, "Mount failed");
+
SAFE_STAT(MNTPOINT, &sb);
blksize = sb.st_blksize;
@@ -197,6 +207,11 @@ static void cleanup(void)
free(tbuf);
free(wbuf);
free(rbuf);
+
+ SAFE_SETEUID(0);
+
+ if (tst_is_mounted(MNTPOINT))
+ SAFE_UMOUNT(MNTPOINT);
}
static struct tst_test test = {
@@ -205,8 +220,7 @@ static struct tst_test test = {
.cleanup = cleanup,
.runtime = 180,
.needs_root = 1,
- .mount_device = 1,
- .mntpoint = MNTPOINT,
+ .format_device = 1,
.filesystems = (struct tst_fs []) {
{
.type = "xfs",
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [LTP] [PATCH] refluxfs: Check kernel reflink support before mount 2026-08-12 15:22 [LTP] [PATCH] refluxfs: Check kernel reflink support before mount Martin Doucha @ 2026-08-12 15:49 ` Cyril Hrubis 2026-08-13 6:36 ` Andrea Cervesato via ltp 2026-08-12 16:02 ` [LTP] " linuxtestproject.agent 2026-08-13 6:29 ` [LTP] [PATCH] " Andrea Cervesato via ltp 2 siblings, 1 reply; 11+ messages in thread From: Cyril Hrubis @ 2026-08-12 15:49 UTC (permalink / raw) To: Martin Doucha; +Cc: ltp Hi! > + if (TST_RET == -1 && TST_ERR == EOPNOTSUPP) > + tst_brk(TCONF, "Kernel does not support XFS reflinks"); Wouldn't it make more sense to add the check for EOPNOTSUPP into the tst_test.c library? -- Cyril Hrubis chrubis@suse.cz -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] refluxfs: Check kernel reflink support before mount 2026-08-12 15:49 ` Cyril Hrubis @ 2026-08-13 6:36 ` Andrea Cervesato via ltp 2026-08-13 10:12 ` Cyril Hrubis 0 siblings, 1 reply; 11+ messages in thread From: Andrea Cervesato via ltp @ 2026-08-13 6:36 UTC (permalink / raw) To: Cyril Hrubis; +Cc: ltp Hi Cyril, > > + if (TST_RET == -1 && TST_ERR == EOPNOTSUPP) > > + tst_brk(TCONF, "Kernel does not support XFS reflinks"); > > Wouldn't it make more sense to add the check for EOPNOTSUPP into the > tst_test.c library? I don't know if we really need to add something in the LTP library, since we have this check only in file_attr02 -- Andrea Cervesato SUSE QE Automation Engineer Linux andrea.cervesato@suse.com -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] refluxfs: Check kernel reflink support before mount 2026-08-13 6:36 ` Andrea Cervesato via ltp @ 2026-08-13 10:12 ` Cyril Hrubis 2026-08-13 10:46 ` Andrea Cervesato via ltp 0 siblings, 1 reply; 11+ messages in thread From: Cyril Hrubis @ 2026-08-13 10:12 UTC (permalink / raw) To: Andrea Cervesato; +Cc: ltp Hi! > > > + if (TST_RET == -1 && TST_ERR == EOPNOTSUPP) > > > + tst_brk(TCONF, "Kernel does not support XFS reflinks"); > > > > Wouldn't it make more sense to add the check for EOPNOTSUPP into the > > tst_test.c library? > > I don't know if we really need to add something in the LTP library, > since we have this check only in file_attr02 I mean that we should rather than hacking around it in the tests handle EOPNOTSUPP properly in the test libray when mounting filesystems. We do enough magick in safe_mount() to support FUSE and handle other corner cases, checking for EOPNOTSUPP (possibly with non-standard mount flags) does sound like a reasonable extension. The main point of handling the filesystems in the test library is that cleanup (umounting) is handled properly even if the test crashes. If we move the code back to the tests like this we lose that. -- Cyril Hrubis chrubis@suse.cz -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] refluxfs: Check kernel reflink support before mount 2026-08-13 10:12 ` Cyril Hrubis @ 2026-08-13 10:46 ` Andrea Cervesato via ltp 2026-08-13 11:46 ` Cyril Hrubis 2026-08-13 13:49 ` Martin Doucha 0 siblings, 2 replies; 11+ messages in thread From: Andrea Cervesato via ltp @ 2026-08-13 10:46 UTC (permalink / raw) To: Cyril Hrubis; +Cc: ltp Hi Cyril, > Hi! > > > > + if (TST_RET == -1 && TST_ERR == EOPNOTSUPP) > > > > + tst_brk(TCONF, "Kernel does not support XFS reflinks"); > > > > > > Wouldn't it make more sense to add the check for EOPNOTSUPP into the > > > tst_test.c library? > > > > I don't know if we really need to add something in the LTP library, > > since we have this check only in file_attr02 > > I mean that we should rather than hacking around it in the tests handle > EOPNOTSUPP properly in the test libray when mounting filesystems. We do > enough magick in safe_mount() to support FUSE and handle other corner > cases, checking for EOPNOTSUPP (possibly with non-standard mount flags) > does sound like a reasonable extension. > > The main point of handling the filesystems in the test library is that > cleanup (umounting) is handled properly even if the test crashes. If we > move the code back to the tests like this we lose that. > > -- > Cyril Hrubis > chrubis@suse.cz Something like this? diff --git a/lib/safe_macros.c b/lib/safe_macros.c index f95c5fdc5..34430d018 100644 --- a/lib/safe_macros.c +++ b/lib/safe_macros.c @@ -993,9 +993,15 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void), "mount.%s failed with %i", filesystemtype, rval); return -1; } else if (rval == -1) { - tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn, - "mount(%s, %s, %s, %lu, %p) failed", source, target, - filesystemtype, mountflags, data); + if (errno == EOPNOTSUPP) { + tst_brkm_(file, lineno, TCONF | TERRNO, cleanup_fn, + "mount(%s, %s, %s, %lu, %p) failed with EOPNOTSUPP", source, target, + filesystemtype, mountflags, data); + } else { + tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn, + "mount(%s, %s, %s, %lu, %p) failed", source, target, + filesystemtype, mountflags, data); + } } else { tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn, "Invalid mount(%s, %s, %s, %lu, %p) return value %d", diff --git a/testcases/kernel/syscalls/file_attr/file_attr02.c b/testcases/kernel/syscalls/file_attr/file_attr02.c index f6625985a..28c1c7ca6 100644 --- a/testcases/kernel/syscalls/file_attr/file_attr02.c +++ b/testcases/kernel/syscalls/file_attr/file_attr02.c @@ -45,13 +45,7 @@ static void setup(void) struct stat statbuf; SAFE_MKDIR(MNTPOINT, 0755); - TEST(mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL)); - - if (TST_RET == -1 && TST_ERR == EOPNOTSUPP) - tst_brk(TCONF, "Kernel does not support XFS reflinks"); - - if (TST_RET) - tst_brk(TBROK | TTERRNO, "Mount failed"); + SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL); SAFE_STAT(MNTPOINT, &statbuf); -- Andrea Cervesato SUSE QE Automation Engineer Linux andrea.cervesato@suse.com -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] refluxfs: Check kernel reflink support before mount 2026-08-13 10:46 ` Andrea Cervesato via ltp @ 2026-08-13 11:46 ` Cyril Hrubis 2026-08-13 13:49 ` Martin Doucha 1 sibling, 0 replies; 11+ messages in thread From: Cyril Hrubis @ 2026-08-13 11:46 UTC (permalink / raw) To: Andrea Cervesato; +Cc: ltp Hi! > Something like this? > > diff --git a/lib/safe_macros.c b/lib/safe_macros.c > index f95c5fdc5..34430d018 100644 > --- a/lib/safe_macros.c > +++ b/lib/safe_macros.c > @@ -993,9 +993,15 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void), > "mount.%s failed with %i", filesystemtype, rval); > return -1; > } else if (rval == -1) { > - tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn, > - "mount(%s, %s, %s, %lu, %p) failed", source, target, > - filesystemtype, mountflags, data); > + if (errno == EOPNOTSUPP) { > + tst_brkm_(file, lineno, TCONF | TERRNO, cleanup_fn, > + "mount(%s, %s, %s, %lu, %p) failed with EOPNOTSUPP", source, target, > + filesystemtype, mountflags, data); > + } else { > + tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn, > + "mount(%s, %s, %s, %lu, %p) failed", source, target, > + filesystemtype, mountflags, data); > + } > } else { > tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn, > "Invalid mount(%s, %s, %s, %lu, %p) return value %d", > diff --git a/testcases/kernel/syscalls/file_attr/file_attr02.c b/testcases/kernel/syscalls/file_attr/file_attr02.c > index f6625985a..28c1c7ca6 100644 > --- a/testcases/kernel/syscalls/file_attr/file_attr02.c > +++ b/testcases/kernel/syscalls/file_attr/file_attr02.c > @@ -45,13 +45,7 @@ static void setup(void) > struct stat statbuf; > > SAFE_MKDIR(MNTPOINT, 0755); > - TEST(mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL)); > - > - if (TST_RET == -1 && TST_ERR == EOPNOTSUPP) > - tst_brk(TCONF, "Kernel does not support XFS reflinks"); > - > - if (TST_RET) > - tst_brk(TBROK | TTERRNO, "Mount failed"); > + SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL); > > SAFE_STAT(MNTPOINT, &statbuf); Yes. If we do not do this we are going to open code the check over and over. -- Cyril Hrubis chrubis@suse.cz -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] refluxfs: Check kernel reflink support before mount 2026-08-13 10:46 ` Andrea Cervesato via ltp 2026-08-13 11:46 ` Cyril Hrubis @ 2026-08-13 13:49 ` Martin Doucha 2026-08-13 14:15 ` Cyril Hrubis 1 sibling, 1 reply; 11+ messages in thread From: Martin Doucha @ 2026-08-13 13:49 UTC (permalink / raw) To: Andrea Cervesato, Cyril Hrubis; +Cc: ltp On 8/13/26 12:46, Andrea Cervesato wrote: > Hi Cyril, > > Something like this? > > diff --git a/lib/safe_macros.c b/lib/safe_macros.c > index f95c5fdc5..34430d018 100644 > --- a/lib/safe_macros.c > +++ b/lib/safe_macros.c > @@ -993,9 +993,15 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void), > "mount.%s failed with %i", filesystemtype, rval); > return -1; > } else if (rval == -1) { > - tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn, > - "mount(%s, %s, %s, %lu, %p) failed", source, target, > - filesystemtype, mountflags, data); > + if (errno == EOPNOTSUPP) { > + tst_brkm_(file, lineno, TCONF | TERRNO, cleanup_fn, > + "mount(%s, %s, %s, %lu, %p) failed with EOPNOTSUPP", source, target, > + filesystemtype, mountflags, data); > + } else { > + tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn, > + "mount(%s, %s, %s, %lu, %p) failed", source, target, > + filesystemtype, mountflags, data); > + } > } else { > tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn, > "Invalid mount(%s, %s, %s, %lu, %p) return value %d", Hi, yes, but I think it'd be better to add a setting to struct tst_test to enable this TCONF check only for specific tests. By default, EOPNOTSUPP should still trigger TBROK. Something like: .mount_check_support = 1 -- Martin Doucha mdoucha@suse.cz SW Quality Engineer SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] refluxfs: Check kernel reflink support before mount 2026-08-13 13:49 ` Martin Doucha @ 2026-08-13 14:15 ` Cyril Hrubis 2026-08-13 15:18 ` Martin Doucha 0 siblings, 1 reply; 11+ messages in thread From: Cyril Hrubis @ 2026-08-13 14:15 UTC (permalink / raw) To: Martin Doucha; +Cc: ltp Hi! > > @@ -993,9 +993,15 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void), > > "mount.%s failed with %i", filesystemtype, rval); > > return -1; > > } else if (rval == -1) { > > - tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn, > > - "mount(%s, %s, %s, %lu, %p) failed", source, target, > > - filesystemtype, mountflags, data); > > + if (errno == EOPNOTSUPP) { > > + tst_brkm_(file, lineno, TCONF | TERRNO, cleanup_fn, > > + "mount(%s, %s, %s, %lu, %p) failed with EOPNOTSUPP", source, target, > > + filesystemtype, mountflags, data); > > + } else { > > + tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn, > > + "mount(%s, %s, %s, %lu, %p) failed", source, target, > > + filesystemtype, mountflags, data); > > + } > > } else { > > tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn, > > "Invalid mount(%s, %s, %s, %lu, %p) return value %d", > > Hi, > yes, but I think it'd be better to add a setting to struct tst_test to > enable this TCONF check only for specific tests. By default, EOPNOTSUPP > should still trigger TBROK. > > Something like: > .mount_check_support = 1 Shoudn't that be per filesystem and live in tst_fs structure? Either way we will need a flag to the safe_mount() added first... -- Cyril Hrubis chrubis@suse.cz -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] refluxfs: Check kernel reflink support before mount 2026-08-13 14:15 ` Cyril Hrubis @ 2026-08-13 15:18 ` Martin Doucha 0 siblings, 0 replies; 11+ messages in thread From: Martin Doucha @ 2026-08-13 15:18 UTC (permalink / raw) To: Cyril Hrubis; +Cc: ltp On 8/13/26 16:15, Cyril Hrubis wrote: >> Hi, >> yes, but I think it'd be better to add a setting to struct tst_test to >> enable this TCONF check only for specific tests. By default, EOPNOTSUPP >> should still trigger TBROK. >> >> Something like: >> .mount_check_support = 1 > > Shoudn't that be per filesystem and live in tst_fs structure? > > Either way we will need a flag to the safe_mount() added first... That's a good point. I'll prepare a patch. -- Martin Doucha mdoucha@suse.cz SW Quality Engineer SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] refluxfs: Check kernel reflink support before mount 2026-08-12 15:22 [LTP] [PATCH] refluxfs: Check kernel reflink support before mount Martin Doucha 2026-08-12 15:49 ` Cyril Hrubis @ 2026-08-12 16:02 ` linuxtestproject.agent 2026-08-13 6:29 ` [LTP] [PATCH] " Andrea Cervesato via ltp 2 siblings, 0 replies; 11+ messages in thread From: linuxtestproject.agent @ 2026-08-12 16:02 UTC (permalink / raw) To: Martin Doucha; +Cc: ltp Hi Martin, On Aug 12, 2026, Martin Doucha wrote: > refluxfs: Check kernel reflink support before mount Verdict - Reviewed --- Note: The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions. Regards, LTP AI Reviewer -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] refluxfs: Check kernel reflink support before mount 2026-08-12 15:22 [LTP] [PATCH] refluxfs: Check kernel reflink support before mount Martin Doucha 2026-08-12 15:49 ` Cyril Hrubis 2026-08-12 16:02 ` [LTP] " linuxtestproject.agent @ 2026-08-13 6:29 ` Andrea Cervesato via ltp 2 siblings, 0 replies; 11+ messages in thread From: Andrea Cervesato via ltp @ 2026-08-13 6:29 UTC (permalink / raw) To: Martin Doucha; +Cc: ltp Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com> -- Andrea Cervesato SUSE QE Automation Engineer Linux andrea.cervesato@suse.com -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-08-13 15:18 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-08-12 15:22 [LTP] [PATCH] refluxfs: Check kernel reflink support before mount Martin Doucha 2026-08-12 15:49 ` Cyril Hrubis 2026-08-13 6:36 ` Andrea Cervesato via ltp 2026-08-13 10:12 ` Cyril Hrubis 2026-08-13 10:46 ` Andrea Cervesato via ltp 2026-08-13 11:46 ` Cyril Hrubis 2026-08-13 13:49 ` Martin Doucha 2026-08-13 14:15 ` Cyril Hrubis 2026-08-13 15:18 ` Martin Doucha 2026-08-12 16:02 ` [LTP] " linuxtestproject.agent 2026-08-13 6:29 ` [LTP] [PATCH] " Andrea Cervesato via ltp
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.