All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] refluxfs: Check kernel reflink support before mount
@ 2026-08-12 15:22 Martin Doucha
  2026-08-12 15:49 ` Cyril Hrubis
  2026-08-12 16:02 ` [LTP] " linuxtestproject.agent
  0 siblings, 2 replies; 3+ 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] 3+ messages in thread

end of thread, other threads:[~2026-08-12 16:03 UTC | newest]

Thread overview: 3+ 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-12 16:02 ` [LTP] " linuxtestproject.agent

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.