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

Martin Doucha mdoucha@suse.cz
Wed Aug 12 17:22:57 CEST 2026


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



More information about the ltp mailing list