* [LTP] [PATCH 0/3] Add optional kernel support checks for filesystem features
@ 2026-08-14 12:49 Martin Doucha
2026-08-14 12:49 ` [LTP] [PATCH 1/3] struct tst_fs: Add flag for checking filesystem mount support in kernel Martin Doucha
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Martin Doucha @ 2026-08-14 12:49 UTC (permalink / raw)
To: ltp
Add optional checks to the LTP library whether the kernel supports mounting
a filesystem with special features. The check is enabled through the
.mount_check_support attribute in struct tst_fs.
Also use this check in the two tests which require XFS reflink support:
file_attr02 and refluxfs.
Martin Doucha (3):
struct tst_fs: Add flag for checking filesystem mount support in
kernel
refluxfs: Check kernel reflink support before mount
file_attr02: Simplify device mounting
include/old/tso_safe_macros.h | 2 +-
include/safe_macros_fn.h | 2 +-
include/tst_safe_macros.h | 7 ++++---
include/tst_test.h | 4 ++++
lib/safe_macros.c | 14 ++++++++++----
lib/tst_test.c | 3 ++-
testcases/cve/refluxfs.c | 1 +
.../kernel/syscalls/file_attr/file_attr02.c | 17 +++--------------
8 files changed, 26 insertions(+), 24 deletions(-)
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH 1/3] struct tst_fs: Add flag for checking filesystem mount support in kernel
2026-08-14 12:49 [LTP] [PATCH 0/3] Add optional kernel support checks for filesystem features Martin Doucha
@ 2026-08-14 12:49 ` Martin Doucha
2026-08-14 13:05 ` [LTP] " linuxtestproject.agent
2026-08-14 12:49 ` [LTP] [PATCH 2/3] refluxfs: Check kernel reflink support before mount Martin Doucha
2026-08-14 12:49 ` [LTP] [PATCH 3/3] file_attr02: Simplify device mounting Martin Doucha
2 siblings, 1 reply; 5+ messages in thread
From: Martin Doucha @ 2026-08-14 12:49 UTC (permalink / raw)
To: ltp
Add flag for skipping filesystem if mount() fails with EOPNOTSUPP. This
error usually happens when special mkfs options are not supported
by the kernel.
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
include/old/tso_safe_macros.h | 2 +-
include/safe_macros_fn.h | 2 +-
include/tst_safe_macros.h | 7 ++++---
include/tst_test.h | 4 ++++
lib/safe_macros.c | 14 ++++++++++----
lib/tst_test.c | 3 ++-
6 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/include/old/tso_safe_macros.h b/include/old/tso_safe_macros.h
index f3965cc68..fec31e666 100644
--- a/include/old/tso_safe_macros.h
+++ b/include/old/tso_safe_macros.h
@@ -154,7 +154,7 @@
#define SAFE_MOUNT(cleanup_fn, source, target, filesystemtype, \
mountflags, data) \
safe_mount(__FILE__, __LINE__, (cleanup_fn), (source), (target), \
- (filesystemtype), (mountflags), (data), NULL)
+ (filesystemtype), (mountflags), (data), NULL, 0)
#define SAFE_UMOUNT(cleanup_fn, target) \
safe_umount(__FILE__, __LINE__, (cleanup_fn), (target))
diff --git a/include/safe_macros_fn.h b/include/safe_macros_fn.h
index e8dc02539..f01378b0a 100644
--- a/include/safe_macros_fn.h
+++ b/include/safe_macros_fn.h
@@ -187,7 +187,7 @@ int safe_rename(const char *file, const int lineno, void (*cleanup_fn)(void),
int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
- const void *data, int *is_fuse);
+ const void *data, int *is_fuse, unsigned int check_support);
int safe_umount(const char *file, const int lineno, void (*cleanup_fn)(void),
const char *target);
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 91a130a48..55ca2bf8b 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -245,12 +245,13 @@ int safe_getgroups(const char *file, const int lineno, int size, gid_t list[]);
#define SAFE_MOUNT(source, target, filesystemtype, \
mountflags, data) \
safe_mount(__FILE__, __LINE__, NULL, (source), (target), \
- (filesystemtype), (mountflags), (data), NULL)
+ (filesystemtype), (mountflags), (data), NULL, 0)
#define SAFE_MOUNT2(source, target, filesystemtype, \
- mountflags, data, is_fuse) \
+ mountflags, data, is_fuse, check_support) \
safe_mount(__FILE__, __LINE__, NULL, (source), (target), \
- (filesystemtype), (mountflags), (data), (is_fuse))
+ (filesystemtype), (mountflags), (data), (is_fuse), \
+ (check_support))
#define SAFE_UMOUNT(target) \
safe_umount(__FILE__, __LINE__, NULL, (target))
diff --git a/include/tst_test.h b/include/tst_test.h
index c69362485..d3de042db 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -280,6 +280,8 @@ struct tst_ulimit_val {
*
* @min_kver: A minimum kernel version supporting the filesystem which has been
* created with mkfs.
+ *
+ * @mount_check_support: Skip this filesystem if mount() fails with EOPNOTSUPP.
*/
struct tst_fs {
const char *type;
@@ -292,6 +294,8 @@ struct tst_fs {
const void *mnt_data;
const char *min_kver;
+
+ unsigned int mount_check_support:1;
};
/**
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index f95c5fdc5..187550041 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -930,7 +930,7 @@ static int possibly_fuse(const char *fs_type)
int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
- const void *data, int *is_fuse)
+ const void *data, int *is_fuse, unsigned int check_support)
{
int rval = -1;
char mpath[PATH_MAX];
@@ -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 (check_support && errno == EOPNOTSUPP) {
+ tst_brkm_(file, lineno, TCONF | TERRNO, cleanup_fn,
+ "Kernel does not support required %s features",
+ filesystemtype);
+ } 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/lib/tst_test.c b/lib/tst_test.c
index 9c5f2617f..166e0f672 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1301,7 +1301,8 @@ static void prepare_device(struct tst_fs *fs)
buf, sizeof(buf), tdev.fs_type);
SAFE_MOUNT2(get_device_name(tdev.fs_type), tst_test->mntpoint,
- tdev.fs_type, fs->mnt_flags, mnt_data, &tdev.is_fuse);
+ tdev.fs_type, fs->mnt_flags, mnt_data,
+ &tdev.is_fuse, fs->mount_check_support);
context->mntpoint_mounted = 1;
}
}
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH 2/3] refluxfs: Check kernel reflink support before mount
2026-08-14 12:49 [LTP] [PATCH 0/3] Add optional kernel support checks for filesystem features Martin Doucha
2026-08-14 12:49 ` [LTP] [PATCH 1/3] struct tst_fs: Add flag for checking filesystem mount support in kernel Martin Doucha
@ 2026-08-14 12:49 ` Martin Doucha
2026-08-14 12:49 ` [LTP] [PATCH 3/3] file_attr02: Simplify device mounting Martin Doucha
2 siblings, 0 replies; 5+ messages in thread
From: Martin Doucha @ 2026-08-14 12:49 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
before mount.
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
Tested on kernel v4.12 without reflink support and v6.4 with reflink support.
testcases/cve/refluxfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/testcases/cve/refluxfs.c b/testcases/cve/refluxfs.c
index e41f35c53..bdf5d32c9 100644
--- a/testcases/cve/refluxfs.c
+++ b/testcases/cve/refluxfs.c
@@ -210,6 +210,7 @@ static struct tst_test test = {
.filesystems = (struct tst_fs []) {
{
.type = "xfs",
+ .mount_check_support = 1,
.min_kver = "4.11",
.mkfs_ver = "mkfs.xfs >= 1.5.0",
.mkfs_opts = (const char *const []) {
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH 3/3] file_attr02: Simplify device mounting
2026-08-14 12:49 [LTP] [PATCH 0/3] Add optional kernel support checks for filesystem features Martin Doucha
2026-08-14 12:49 ` [LTP] [PATCH 1/3] struct tst_fs: Add flag for checking filesystem mount support in kernel Martin Doucha
2026-08-14 12:49 ` [LTP] [PATCH 2/3] refluxfs: Check kernel reflink support before mount Martin Doucha
@ 2026-08-14 12:49 ` Martin Doucha
2 siblings, 0 replies; 5+ messages in thread
From: Martin Doucha @ 2026-08-14 12:49 UTC (permalink / raw)
To: ltp
The file_attr02 test creates an XFS partition with reflinks enabled.
However, some kernels cannot mount such partitions so the test
needs to check kernel support. The LTP library can now do the check
internally so use this feature instead of mounting explicitly in setup().
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
.../kernel/syscalls/file_attr/file_attr02.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/testcases/kernel/syscalls/file_attr/file_attr02.c b/testcases/kernel/syscalls/file_attr/file_attr02.c
index f6625985a..0adfa5f6e 100644
--- a/testcases/kernel/syscalls/file_attr/file_attr02.c
+++ b/testcases/kernel/syscalls/file_attr/file_attr02.c
@@ -9,7 +9,6 @@
* currently implementing the features we need.
*/
-#include <sys/mount.h>
#include "tst_test.h"
#include "lapi/fs.h"
@@ -44,15 +43,6 @@ 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_STAT(MNTPOINT, &statbuf);
dfd = SAFE_OPEN(MNTPOINT, O_RDONLY);
@@ -82,9 +72,6 @@ static void cleanup(void)
if (dfd != -1)
SAFE_CLOSE(dfd);
-
- if (tst_is_mounted(MNTPOINT))
- SAFE_UMOUNT(MNTPOINT);
}
static struct tst_test test = {
@@ -92,10 +79,12 @@ static struct tst_test test = {
.setup = setup,
.cleanup = cleanup,
.needs_root = 1,
- .format_device = 1,
+ .mount_device = 1,
+ .mntpoint = MNTPOINT,
.filesystems = (struct tst_fs []) {
{
.type = "xfs",
+ .mount_check_support = 1,
.mkfs_opts = (const char *const[]){
"-m", "reflink=1", NULL
},
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] struct tst_fs: Add flag for checking filesystem mount support in kernel
2026-08-14 12:49 ` [LTP] [PATCH 1/3] struct tst_fs: Add flag for checking filesystem mount support in kernel Martin Doucha
@ 2026-08-14 13:05 ` linuxtestproject.agent
0 siblings, 0 replies; 5+ messages in thread
From: linuxtestproject.agent @ 2026-08-14 13:05 UTC (permalink / raw)
To: Martin Doucha; +Cc: ltp
Hi Martin,
On Fri, 14 Aug 2026, Martin Doucha wrote:
> struct tst_fs: Add flag for checking filesystem mount support in kernel
--- [PATCH 1/3] ---
> - const void *data, int *is_fuse);
> + const void *data, int *is_fuse, unsigned int check_support);
Could safe_mount() and SAFE_MOUNT2() gain kernel-doc comments that describe
the new check_support argument and the resulting TCONF behavior? These are
modified public APIs in include/ and lib/.
Verdict - Needs revision
---
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] 5+ messages in thread
end of thread, other threads:[~2026-08-14 13:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 12:49 [LTP] [PATCH 0/3] Add optional kernel support checks for filesystem features Martin Doucha
2026-08-14 12:49 ` [LTP] [PATCH 1/3] struct tst_fs: Add flag for checking filesystem mount support in kernel Martin Doucha
2026-08-14 13:05 ` [LTP] " linuxtestproject.agent
2026-08-14 12:49 ` [LTP] [PATCH 2/3] refluxfs: Check kernel reflink support before mount Martin Doucha
2026-08-14 12:49 ` [LTP] [PATCH 3/3] file_attr02: Simplify device mounting Martin Doucha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).