[LTP] [PATCH] refluxfs: Check kernel reflink support before mount

Andrea Cervesato andrea.cervesato@suse.com
Thu Aug 13 12:46:44 CEST 2026


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


More information about the ltp mailing list