Add optional kernel support checks for filesystem features
cover Add optional kernel support checks for filesystem features
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(-)
Signature · 5 lines
2.54.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/3 struct tst_fs: Add flag for checking filesystem mount support in kernel
Add flag for skipping filesystem if mount() fails with EOPNOTSUPP. This error usually happens when special mkfs options are not supported by the kernel.
--- 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(-)
include/old/tso_safe_macros.h +1 -1
@@ -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))
include/safe_macros_fn.h +1 -1
@@ -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);
include/tst_safe_macros.h +4 -3
@@ -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))
include/tst_test.h +4 -0
@@ -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; };/**
lib/safe_macros.c +10 -4
@@ -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",
lib/tst_test.c +2 -1
@@ -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 ; } }
Signature · 5 lines
2.54.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] struct tst_fs: Add flag for checking filesystem mount support in kernel
Hi Martin,
Quoted 1 line · Martin Doucha
struct
tst_fs: Add flag for checking filesystem mount support in kernel
--- [PATCH 1/3] ---
include/safe_macros_fn.h int safe_rename(const char *file, const int lineno, void (*cleanup_fn)(void), · line 190
Quoted 2 lines
include/safe_macros_fn.h +1
-1- 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
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] struct tst_fs: Add flag for checking filesystem mount support in kernel
Hi Martin,
Quoted 5 lines
Hi Martin,
Quoted 1 line · Martin Doucha
struct
tst_fs: Add flag for checking filesystem mount support in kernel
Quoted 8 lines
--- [PATCH 1/3] ---
include/safe_macros_fn.h int safe_rename(const char *file, const int lineno, void (*cleanup_fn)(void), · line 190
Quoted 2 lines
include/safe_macros_fn.h +1
-1- const void *data, int *is_fuse); + const void *data, int *is_fuse, unsigned int check_support);Could
safe_mount()andSAFE_MOUNT2()gain kernel-doc comments that describe the newcheck_supportargument and the resulting TCONF behavior? These are modified public APIs ininclude/andlib/.
This is actually correct, rather than adding only docs in the struct, it would be good to add the doc also in the function documentation.
The rest LGTM
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] struct tst_fs: Add flag for checking filesystem mount support in kernel
Quoted 6 lines · Andrea Cervesato
Quoted 3 lines
Could
safe_mount()andSAFE_MOUNT2()gain kernel-doc comments that describe the newcheck_supportargument and the resulting TCONF behavior? These are modified public APIs ininclude/andlib/.This is actually correct, rather than adding only docs in the struct, it would be good to add the doc also in the function documentation.
SAFE_MOUNT2() is only used in lib/tst_test.c and LTP tests should probably not use it at all. We have no documentation for other SAFE_*() functions because they're sufficiently described by the relevant manpage. The two extra parameters in SAFE_MOUNT2() should be clear enough.
Signature · 10 lines
Martin Doucha [email protected] 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
Re: [LTP] [PATCH 1/3] struct tst_fs: Add flag for checking filesystem mount support in kernel
In reply to Martin Doucha--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/3] struct tst_fs: Add flag for checking filesystem mount support in kernel
In reply to Martin DouchaHi Martin,
Quoted 3 lines
Add flag for skipping filesystem if
mount()fails with EOPNOTSUPP. This error usually happens when special mkfs options are not supported by the kernel.
Whole patchset merged, thank you!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/3 refluxfs: Check kernel reflink support before mount
In reply to Martin DouchaOn 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.
---
Tested on kernel v4.12 without reflink support and v6.4 with reflink support.
testcases/cve/refluxfs.c | 1 + 1 file changed, 1 insertion(+)
testcases/cve/refluxfs.c +1 -0
@@ -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 []) {
Signature · 5 lines
2.54.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/3] refluxfs: Check kernel reflink support before mount
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 3/3 file_attr02: Simplify device mounting
In reply to Martin DouchaThe 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().
--- .../kernel/syscalls/file_attr/file_attr02.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
testcases/kernel/syscalls/file_attr/file_attr02.c +3 -14
@@ -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 },
Signature · 5 lines
2.54.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/3] file_attr02: Simplify device mounting
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp