Skip to contentSkip to conversation

Fix ioctl_ficlone(range) failures on certain FS

PATCH Superseded Andrea Cervesato 3 participants 8 messages Oct 2, 2024 – Oct 8, 2024 Library code

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover Fix ioctl_ficlone(range) failures on certain FS

Filesystems implementing copy-on-write are usually supported by the kernel from a certain version. This is the case of XFS which carried an experimental support for CoW from 4.9 until 4.16.
At the same time, some mkfs tools might not support CoW before a certain version. This is the case of mkfs.xfs < 1.5.0.

For these reasons, this LTP patch series is meant to cover a particular scenario, where kernel and mkfs tools versions have to be cross-checked in order to run ioctl_ficlone(range) tests.

Two new flags have been added to the tst_fs struct:
- mkfs_ver: test the mkfs tool version before using it and eventually skip test if it's not satisfied
- min_kver: test the minimum kernel version and skip the test if running kernel is too old

---
Changes in v3:
- invert skip flag logic in check_kver and tst_check_cmd, so now it
TBROK if defined
- test skip if FS is not supported by kernel
- remove bcachefs version check
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- add mkfs_ver
- add min_kver
- fix mkfs.xfs version when using CoW
- fix bcachefs version
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Andrea Cervesato (3):
Filter mkfs version in tst_fs
Add minimum kernel requirement for FS setup Setup minimal kernel for ioctl_clone(range) tests

 include/tst_private.h                              |   6 +-
 include/tst_test.h                                 |   9 ++
 lib/tst_cmd.c                                      | 125 ++++++++++++++-------
 lib/tst_test.c                                     |  44 ++++++--
 testcases/kernel/syscalls/ioctl/ioctl_ficlone01.c  |   4 +-
 testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c  |   4 +-
 .../kernel/syscalls/ioctl/ioctl_ficlonerange01.c   |   4 +-
 .../kernel/syscalls/ioctl/ioctl_ficlonerange02.c   |   4 +-
 testcases/lib/tst_run_shell.c                      |  10 ++
 9 files changed, 154 insertions(+), 56 deletions(-)

---
base-commit: 701212f08d6e850457cc2b10238f28662ef48471
change-id: 20240924-ioctl_ficlone01_fix-88a17ef58543

Best regards,

Signature · 5 lines
Andrea Cervesato <[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH v3 1/3 Filter mkfs version in tst_fs

From: Andrea Cervesato <[email protected]>

Introduce mkfs_ver attribute in the tst_fs declaration, in order to filter specific mkfs.* tools versions.

---
 include/tst_private.h         |   6 +-
 include/tst_test.h            |   4 ++
 lib/tst_cmd.c                 | 125 ++++++++++++++++++++++++++++--------------
 lib/tst_test.c                |  17 +++++-
 testcases/lib/tst_run_shell.c |   5 ++
 5 files changed, 111 insertions(+), 46 deletions(-)
include/tst_private.h +3 -3
index 6f4f39b15..4c6479f4b 100644
@@ -40,11 +40,11 @@ char tst_kconfig_get(const char *confname);
 
 /*
  * If cmd argument is a single command, this function just checks command
- * whether exists. If not, case skips.
+ * whether exists. If not, case breaks if brk_nosupp is defined.
  * If cmd argument is a complex string ie 'mkfs.ext4 >= 1.43.0', this
  * function checks command version whether meets this requirement.
- * If not, case skips.
+ * If not, case breaks if brk_nosupp is defined.
  */
-void tst_check_cmd(const char *cmd);
+int tst_check_cmd(const char *cmd, const int brk_nosupp);
 
 #endif
include/tst_test.h +4 -0
index d0fa84a71..38d24f48c 100644
@@ -262,6 +262,9 @@ struct tst_ulimit_val {
  *                 passed to mkfs after the device path and can be used to
  *                 limit the file system not to use the whole block device.
  *
+ * @mkfs_ver: mkfs tool version. The string format supports relational
+ *            operators such as < > <= >= ==.
+ *
  * @mnt_flags: MS_* flags passed to mount(2) when the test library mounts a
  *             device in the case of 'tst_test.mount_device'.
  *
@@ -273,6 +276,7 @@ struct tst_fs {
 
 	const char *const *mkfs_opts;
 	const char *mkfs_size_opt;
+	const char *mkfs_ver;
 
 	unsigned int mnt_flags;
 	const void *mnt_data;
lib/tst_cmd.c +85 -40

164 lines not on this page · raw message

lib/tst_test.c +14 -3
index d226157e0..192fee309 100644
@@ -1250,6 +1250,7 @@ static const char *default_fs_type(void)
 static void do_setup(int argc, char *argv[])
 {
 	char *tdebug_env = getenv("LTP_ENABLE_DEBUG");
+	int ret = 0;
 
 	if (!tst_test)
 		tst_brk(TBROK, "No tests to run");
@@ -1310,7 +1311,7 @@ static void do_setup(int argc, char *argv[])
 		int i;
 
 		for (i = 0; (cmd = tst_test->needs_cmds[i]); ++i)
-			tst_check_cmd(cmd);
+			tst_check_cmd(cmd, 1);
 	}
 
 	if (tst_test->needs_drivers) {
@@ -1415,8 +1416,15 @@ static void do_setup(int argc, char *argv[])
 
 		tdev.fs_type = default_fs_type();
 
-		if (!tst_test->all_filesystems && count_fs_descs() <= 1)
+		if (!tst_test->all_filesystems && count_fs_descs() <= 1) {
+			if (tst_test->filesystems->mkfs_ver)
+				ret = tst_check_cmd(tst_test->filesystems->mkfs_ver, 0);
+
+			if (ret)
+				return;
+
 			prepare_device(tst_test->filesystems);
+		}
 	}
 
 	if (tst_test->needs_overlay && !tst_test->mount_device)
@@ -1805,6 +1813,9 @@ static int run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
 	tst_res(TINFO, "=== Testing on %s ===", fs_type);
 	tdev.fs_type = fs_type;
 
+	if (fs->mkfs_ver && tst_check_cmd(fs->mkfs_ver, 0))
+		return TCONF;
+
 	prepare_device(fs);
 
 	ret = fork_testrun();
@@ -1832,7 +1843,7 @@ static int run_tcases_per_fs(void)
 		if (!fs)
 			continue;
 
-		run_tcase_on_fs(fs, filesystems[i]);
+		ret = run_tcase_on_fs(fs, filesystems[i]);
 
 		if (ret == TCONF)
 			continue;
testcases/lib/tst_run_shell.c +5 -0
index 8ed0f21b6..ee029b666 100644
@@ -153,6 +153,7 @@ static const char *const *parse_strarr(ujson_reader *reader, ujson_val *val)
 enum fs_ids {
 	MKFS_OPTS,
 	MKFS_SIZE_OPT,
+	MKFS_VER,
 	MNT_FLAGS,
 	TYPE,
 };
@@ -160,6 +161,7 @@ enum fs_ids {
 static ujson_obj_attr fs_attrs[] = {
 	UJSON_OBJ_ATTR_IDX(MKFS_OPTS, "mkfs_opts", UJSON_ARR),
 	UJSON_OBJ_ATTR_IDX(MKFS_SIZE_OPT, "mkfs_size_opt", UJSON_STR),
+	UJSON_OBJ_ATTR_IDX(MKFS_VER, "mkfs_ver", UJSON_STR),
 	UJSON_OBJ_ATTR_IDX(MNT_FLAGS, "mnt_flags", UJSON_ARR),
 	UJSON_OBJ_ATTR_IDX(TYPE, "type", UJSON_STR),
 };
@@ -224,6 +226,9 @@ static struct tst_fs *parse_filesystems(ujson_reader *reader, ujson_val *val)
 			case MKFS_SIZE_OPT:
 				ret[i].mkfs_size_opt = strdup(val->val_str);
 			break;
+			case MKFS_VER:
+				ret[i].mkfs_ver = strdup(val->val_str);
+			break;
 			case MNT_FLAGS:
 				ret[i].mnt_flags = parse_mnt_flags(reader, val);
 			break;
Signature · 5 lines
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Re: [LTP] [PATCH v3 1/3] Filter mkfs version in tst_fs

Hi!

lib/tst_cmd.c void tst_check_cmd(const char *cmd) · line 332

Quoted 5 lines
lib/tst_cmd.c +5 -0
+		if (ver_parser >= ver_get)
+			break;
+
+		check_msg = "%s required >= %d, but got %d, "
+			"the version is required in order run the test.";

I would drop the "the version is required in order to run the test." part from these messages, since it does not add any more value on the top of the first part of the meassage.

Quoted 22 lines
lib/tst_test.c +2 -1
index d226157e0..192fee309 100644
@@ -1250,6 +1250,7 @@ static const char *default_fs_type(void)
 static void do_setup(int argc, char *argv[])
 {
 	char *tdebug_env = getenv("LTP_ENABLE_DEBUG");
+	int ret = 0;
 
 	if (!tst_test)
 		tst_brk(TBROK, "No tests to run");
@@ -1310,7 +1311,7 @@ static void do_setup(int argc, char *argv[])
 		int i;
 
 		for (i = 0; (cmd = tst_test->needs_cmds[i]); ++i)
-			tst_check_cmd(cmd);
+			tst_check_cmd(cmd, 1);
 	}
 
 	if (tst_test->needs_drivers) {

lib/tst_test.c static void do_setup(int argc, char *argv[]) · line 1424

Quoted 10 lines
lib/tst_test.c +6 -1
@@ -1415,8 +1416,15 @@ static void do_setup(int argc, char *argv[])
 
 		tdev.fs_type = default_fs_type();
 
-		if (!tst_test->all_filesystems && count_fs_descs() <= 1)
+		if (!tst_test->all_filesystems && count_fs_descs() <= 1) {
+			if (tst_test->filesystems->mkfs_ver)
+				ret = tst_check_cmd(tst_test->filesystems->mkfs_ver, 0);
+
+			if (ret)
+				return;

And if we are here, it means that the test runs only for a single filesystem, so we should instead do:

			if (tst_test->filesystem->mkfs_ver)
				tst_check_mcd(tst_test->filesystems->mkfs_ver, 1);

The rest looks good.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

PATCH v3 2/3 Add minimum kernel requirement for FS setup

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

In some cases, a filesystem that is going to be created and mounted by LTP can't be supported by certain kernel versions. This is the case of the CoW support: mkfs creates a CoW filesystem, while underlying kernel can't mount it.

To cover this scenario, a new flag called .min_kver has been introduced in the tst_fs structure, giving the user a possibility to filter out certain kernels not supporting certain FS features.

---
 include/tst_test.h            |  5 +++++
 lib/tst_test.c                | 27 +++++++++++++++++++++------
 testcases/lib/tst_run_shell.c |  5 +++++
 3 files changed, 31 insertions(+), 6 deletions(-)
include/tst_test.h +5 -0
index 38d24f48c..8d1819f74 100644
@@ -270,6 +270,9 @@ struct tst_ulimit_val {
  *
  * @mnt_data: The data passed to mount(2) when the test library mounts a device
  *            in the case of 'tst_test.mount_device'.
+ *
+ * @min_kver: A minimum kernel version supporting the filesystem which has been
+ *            created with mkfs.
  */
 struct tst_fs {
 	const char *type;
@@ -280,6 +283,8 @@ struct tst_fs {
 
 	unsigned int mnt_flags;
 	const void *mnt_data;
+
+	const char *min_kver;
 };
 
 /**
lib/tst_test.c +21 -6
index 192fee309..fe07c4d98 100644
@@ -950,20 +950,29 @@ static void do_exit(int ret)
 	exit(ret);
 }
 
-void check_kver(void)
+int check_kver(const char *min_kver, const int brk_nosupp)
 {
+	char *msg;
 	int v1, v2, v3;
 
-	if (tst_parse_kver(tst_test->min_kver, &v1, &v2, &v3)) {
+	if (tst_parse_kver(min_kver, &v1, &v2, &v3)) {
 		tst_res(TWARN,
 			"Invalid kernel version %s, expected %%d.%%d.%%d",
-			tst_test->min_kver);
+			min_kver);
 	}
 
 	if (tst_kvercmp(v1, v2, v3) < 0) {
-		tst_brk(TCONF, "The test requires kernel %s or newer",
-			tst_test->min_kver);
+		msg = "The test requires kernel %s or newer";
+
+		if (brk_nosupp)
+			tst_brk(TCONF, msg, min_kver);
+		else
+			tst_res(TCONF, msg, min_kver);
+
+		return 1;
 	}
+
+	return 0;
 }
 
 static int results_equal(struct results *a, struct results *b)
@@ -1289,7 +1298,7 @@ static void do_setup(int argc, char *argv[])
 		tst_brk(TCONF, "Test needs to be run as root");
 
 	if (tst_test->min_kver)
-		check_kver();
+		check_kver(tst_test->min_kver, 1);
 
 	if (tst_test->supported_archs && !tst_is_on_arch(tst_test->supported_archs))
 		tst_brk(TCONF, "This arch '%s' is not supported for test!", tst_arch.name);
@@ -1420,6 +1429,9 @@ static void do_setup(int argc, char *argv[])
 			if (tst_test->filesystems->mkfs_ver)
 				ret = tst_check_cmd(tst_test->filesystems->mkfs_ver, 0);
 
+			if (tst_test->filesystems->min_kver)
+				ret = check_kver(tst_test->filesystems->min_kver, 0);
+
 			if (ret)
 				return;
 
@@ -1816,6 +1828,9 @@ static int run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
 	if (fs->mkfs_ver && tst_check_cmd(fs->mkfs_ver, 0))
 		return TCONF;
 
+	if (fs->min_kver && check_kver(fs->min_kver, 0))
+		return TCONF;
+
 	prepare_device(fs);
 
 	ret = fork_testrun();
testcases/lib/tst_run_shell.c +5 -0
index ee029b666..6b714c51c 100644
@@ -156,6 +156,7 @@ enum fs_ids {
 	MKFS_VER,
 	MNT_FLAGS,
 	TYPE,
+	FS_MIN_KVER,
 };
 
 static ujson_obj_attr fs_attrs[] = {
@@ -164,6 +165,7 @@ static ujson_obj_attr fs_attrs[] = {
 	UJSON_OBJ_ATTR_IDX(MKFS_VER, "mkfs_ver", UJSON_STR),
 	UJSON_OBJ_ATTR_IDX(MNT_FLAGS, "mnt_flags", UJSON_ARR),
 	UJSON_OBJ_ATTR_IDX(TYPE, "type", UJSON_STR),
+	UJSON_OBJ_ATTR_IDX(FS_MIN_KVER, "min_kver", UJSON_STR),
 };
 
 static ujson_obj fs_obj = {
@@ -235,6 +237,9 @@ static struct tst_fs *parse_filesystems(ujson_reader *reader, ujson_val *val)
 			case TYPE:
 				ret[i].type = strdup(val->val_str);
 			break;
+			case FS_MIN_KVER:
+				ret[i].min_kver = strdup(val->val_str);
+			break;
 			}
 
 		}
Signature · 5 lines
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Re: [LTP] [PATCH v3 2/3] Add minimum kernel requirement for FS setup

Hi!

Quoted 88 lines

In some cases, a filesystem that is going to be created and mounted by LTP can't be supported by certain kernel versions. This is the case of the CoW support: mkfs creates a CoW filesystem, while underlying kernel can't mount it.

To cover this scenario, a new flag called .min_kver has been introduced in the tst_fs structure, giving the user a possibility to filter out certain kernels not supporting certain FS features.

---
 include/tst_test.h            |  5 +++++
 lib/tst_test.c                | 27 +++++++++++++++++++++------
 testcases/lib/tst_run_shell.c |  5 +++++
 3 files changed, 31 insertions(+), 6 deletions(-)
include/tst_test.h +5 -0
index 38d24f48c..8d1819f74 100644
@@ -270,6 +270,9 @@ struct tst_ulimit_val {
  *
  * @mnt_data: The data passed to mount(2) when the test library mounts a device
  *            in the case of 'tst_test.mount_device'.
+ *
+ * @min_kver: A minimum kernel version supporting the filesystem which has been
+ *            created with mkfs.
  */
 struct tst_fs {
 	const char *type;
@@ -280,6 +283,8 @@ struct tst_fs {
 
 	unsigned int mnt_flags;
 	const void *mnt_data;
+
+	const char *min_kver;
 };
 
 /**
lib/tst_test.c +15 -6
index 192fee309..fe07c4d98 100644
@@ -950,20 +950,29 @@ static void do_exit(int ret)
 	exit(ret);
 }
 
-void check_kver(void)
+int check_kver(const char *min_kver, const int brk_nosupp)
 {
+	char *msg;
 	int v1, v2, v3;
 
-	if (tst_parse_kver(tst_test->min_kver, &v1, &v2, &v3)) {
+	if (tst_parse_kver(min_kver, &v1, &v2, &v3)) {
 		tst_res(TWARN,
 			"Invalid kernel version %s, expected %%d.%%d.%%d",
-			tst_test->min_kver);
+			min_kver);
 	}
 
 	if (tst_kvercmp(v1, v2, v3) < 0) {
-		tst_brk(TCONF, "The test requires kernel %s or newer",
-			tst_test->min_kver);
+		msg = "The test requires kernel %s or newer";
+
+		if (brk_nosupp)
+			tst_brk(TCONF, msg, min_kver);
+		else
+			tst_res(TCONF, msg, min_kver);
+
+		return 1;
 	}
+
+	return 0;
 }
 
 static int results_equal(struct results *a, struct results *b)
@@ -1289,7 +1298,7 @@ static void do_setup(int argc, char *argv[])
 		tst_brk(TCONF, "Test needs to be run as root");
 
 	if (tst_test->min_kver)
-		check_kver();
+		check_kver(tst_test->min_kver, 1);
 
 	if (tst_test->supported_archs && !tst_is_on_arch(tst_test->supported_archs))
 		tst_brk(TCONF, "This arch '%s' is not supported for test!", tst_arch.name);

lib/tst_test.c static void do_setup(int argc, char *argv[]) · line 1433

Quoted 5 lines
lib/tst_test.c +2 -0
@@ -1420,6 +1429,9 @@ static void do_setup(int argc, char *argv[])
 			if (tst_test->filesystems->mkfs_ver)
 				ret = tst_check_cmd(tst_test->filesystems->mkfs_ver, 0);
 
+			if (tst_test->filesystems->min_kver)
+				ret = check_kver(tst_test->filesystems->min_kver, 0);

Here as well, we should pass 1 as the last argument.

Quoted 26 lines
lib/tst_test.c +3 -0
 			if (ret)
 				return;
 
@@ -1816,6 +1828,9 @@ static int run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
 	if (fs->mkfs_ver && tst_check_cmd(fs->mkfs_ver, 0))
 		return TCONF;
 
+	if (fs->min_kver && check_kver(fs->min_kver, 0))
+		return TCONF;
+
 	prepare_device(fs);
 
 	ret = fork_testrun();
testcases/lib/tst_run_shell.c +1 -0
index ee029b666..6b714c51c 100644
@@ -156,6 +156,7 @@ enum fs_ids {
 	MKFS_VER,
 	MNT_FLAGS,
 	TYPE,
+	FS_MIN_KVER,
 };
 
 static ujson_obj_attr fs_attrs[] = {

testcases/lib/tst_run_shell.c static ujson_obj_attr fs_attrs[] = { · line 168

Quoted 4 lines
testcases/lib/tst_run_shell.c +1 -0
@@ -164,6 +165,7 @@ static ujson_obj_attr fs_attrs[] = {
 	UJSON_OBJ_ATTR_IDX(MKFS_VER, "mkfs_ver", UJSON_STR),
 	UJSON_OBJ_ATTR_IDX(MNT_FLAGS, "mnt_flags", UJSON_ARR),
 	UJSON_OBJ_ATTR_IDX(TYPE, "type", UJSON_STR),
+	UJSON_OBJ_ATTR_IDX(FS_MIN_KVER, "min_kver", UJSON_STR),

This is stil not sorted properly, the min_kver should go before the mkfs_ver.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

Re: [LTP] [PATCH v3 2/3] Add minimum kernel requirement for FS setup

Hi,

Quoted 120 lines · Cyril Hrubis

Hi!

Quoted 88 lines

In some cases, a filesystem that is going to be created and mounted by LTP can't be supported by certain kernel versions. This is the case of the CoW support: mkfs creates a CoW filesystem, while underlying kernel can't mount it.

To cover this scenario, a new flag called .min_kver has been introduced in the tst_fs structure, giving the user a possibility to filter out certain kernels not supporting certain FS features.

---
  include/tst_test.h            |  5 +++++
  lib/tst_test.c                | 27 +++++++++++++++++++++------
  testcases/lib/tst_run_shell.c |  5 +++++
  3 files changed, 31 insertions(+), 6 deletions(-)
include/tst_test.h +5 -0
index 38d24f48c..8d1819f74 100644
@@ -270,6 +270,9 @@ struct tst_ulimit_val {
   *
   * @mnt_data: The data passed to mount(2) when the test library mounts a device
   *            in the case of 'tst_test.mount_device'.
+ *
+ * @min_kver: A minimum kernel version supporting the filesystem which has been
+ *            created with mkfs.
   */
  struct tst_fs {
  	const char *type;
@@ -280,6 +283,8 @@ struct tst_fs {
 
  	unsigned int mnt_flags;
  	const void *mnt_data;
+
+	const char *min_kver;
  };
 
  /**
lib/tst_test.c +15 -6
index 192fee309..fe07c4d98 100644
@@ -950,20 +950,29 @@ static void do_exit(int ret)
  	exit(ret);
  }
 
-void check_kver(void)
+int check_kver(const char *min_kver, const int brk_nosupp)
  {
+	char *msg;
  	int v1, v2, v3;
 
-	if (tst_parse_kver(tst_test->min_kver, &v1, &v2, &v3)) {
+	if (tst_parse_kver(min_kver, &v1, &v2, &v3)) {
  		tst_res(TWARN,
  			"Invalid kernel version %s, expected %%d.%%d.%%d",
-			tst_test->min_kver);
+			min_kver);
  	}
 
  	if (tst_kvercmp(v1, v2, v3) < 0) {
-		tst_brk(TCONF, "The test requires kernel %s or newer",
-			tst_test->min_kver);
+		msg = "The test requires kernel %s or newer";
+
+		if (brk_nosupp)
+			tst_brk(TCONF, msg, min_kver);
+		else
+			tst_res(TCONF, msg, min_kver);
+
+		return 1;
  	}
+
+	return 0;
  }
 
  static int results_equal(struct results *a, struct results *b)
@@ -1289,7 +1298,7 @@ static void do_setup(int argc, char *argv[])
  		tst_brk(TCONF, "Test needs to be run as root");
 
  	if (tst_test->min_kver)
-		check_kver();
+		check_kver(tst_test->min_kver, 1);
 
  	if (tst_test->supported_archs && !tst_is_on_arch(tst_test->supported_archs))
  		tst_brk(TCONF, "This arch '%s' is not supported for test!", tst_arch.name);

lib/tst_test.c static void do_setup(int argc, char *argv[]) · line 1433

Quoted 5 lines
lib/tst_test.c +2 -0
@@ -1420,6 +1429,9 @@ static void do_setup(int argc, char *argv[])
  			if (tst_test->filesystems->mkfs_ver)
  				ret = tst_check_cmd(tst_test->filesystems->mkfs_ver, 0);
 
+			if (tst_test->filesystems->min_kver)
+				ret = check_kver(tst_test->filesystems->min_kver, 0);

Here as well, we should pass 1 as the last argument.

Quoted 24 lines
lib/tst_test.c +3 -0
  			if (ret)
  				return;
 
@@ -1816,6 +1828,9 @@ static int run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
  	if (fs->mkfs_ver && tst_check_cmd(fs->mkfs_ver, 0))
  		return TCONF;
 
+	if (fs->min_kver && check_kver(fs->min_kver, 0))
+		return TCONF;
+
  	prepare_device(fs);
 
  	ret = fork_testrun();
testcases/lib/tst_run_shell.c +1 -0
index ee029b666..6b714c51c 100644
@@ -156,6 +156,7 @@ enum fs_ids {
  	MKFS_VER,
  	MNT_FLAGS,
  	TYPE,
+	FS_MIN_KVER,
  };
 
Quoted 9 lines

testcases/lib/tst_run_shell.c static ujson_obj_attr fs_attrs[] = { · line 168

Quoted 6 lines
testcases/lib/tst_run_shell.c +1 -0
  static ujson_obj_attr fs_attrs[] = {
@@ -164,6 +165,7 @@ static ujson_obj_attr fs_attrs[] = {
  	UJSON_OBJ_ATTR_IDX(MKFS_VER, "mkfs_ver", UJSON_STR),
  	UJSON_OBJ_ATTR_IDX(MNT_FLAGS, "mnt_flags", UJSON_ARR),
  	UJSON_OBJ_ATTR_IDX(TYPE, "type", UJSON_STR),
+	UJSON_OBJ_ATTR_IDX(FS_MIN_KVER, "min_kver", UJSON_STR),

This is stil not sorted properly, the min_kver should go before the mkfs_ver.

This is not clear to me. The objects are sorted mirroring the tst_fs struct. Can you explain it better please?

Andrea

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Re: [LTP] [PATCH v3 2/3] Add minimum kernel requirement for FS setup

Hi!

Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
testcases/lib/tst_run_shell.c +1 -0
index ee029b666..6b714c51c 100644
@@ -156,6 +156,7 @@ enum fs_ids {
  	MKFS_VER,
  	MNT_FLAGS,
  	TYPE,
+	FS_MIN_KVER,
  };
 
Quoted 9 lines

testcases/lib/tst_run_shell.c static ujson_obj_attr fs_attrs[] = { · line 168

Quoted 6 lines
testcases/lib/tst_run_shell.c +1 -0
  static ujson_obj_attr fs_attrs[] = {
@@ -164,6 +165,7 @@ static ujson_obj_attr fs_attrs[] = {
  	UJSON_OBJ_ATTR_IDX(MKFS_VER, "mkfs_ver", UJSON_STR),
  	UJSON_OBJ_ATTR_IDX(MNT_FLAGS, "mnt_flags", UJSON_ARR),
  	UJSON_OBJ_ATTR_IDX(TYPE, "type", UJSON_STR),
+	UJSON_OBJ_ATTR_IDX(FS_MIN_KVER, "min_kver", UJSON_STR),

This is stil not sorted properly, the min_kver should go before the mkfs_ver.

Quoted 2 lines

This is not clear to me. The objects are sorted mirroring the tst_fs struct. Can you explain it better please?

This is a lookup table that has to be sorted by the string ID we are looking up. Well technically the fs_ids enum has to be sorted so that the string ids are sorted and the order of this array does not matter, but it's easier to keep them both sorted alphabetically by the ID.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

PATCH v3 3/3 Setup minimal kernel for ioctl_clone(range) tests

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

Some linux kernels don't support copy-on-write feature for the filesystems we are going to use during ioctl_ficlone and ioctl_ficlonerange tests. For this reason, fix the minimal kernel version required in order to skip test when it's needed.

---
 testcases/kernel/syscalls/ioctl/ioctl_ficlone01.c      | 4 +++-
 testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c      | 4 +++-
 testcases/kernel/syscalls/ioctl/ioctl_ficlonerange01.c | 4 +++-
 testcases/kernel/syscalls/ioctl/ioctl_ficlonerange02.c | 4 +++-
 4 files changed, 12 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/ioctl/ioctl_ficlone01.c +3 -1
index f5407f789..2574bb6a2 100644
@@ -112,10 +112,12 @@ static struct tst_test test = {
 	.mount_device = 1,
 	.mntpoint = MNTPOINT,
 	.filesystems = (struct tst_fs []) {
-		{.type = "bcachefs"},
 		{.type = "btrfs"},
+		{.type = "bcachefs"},
 		{
 			.type = "xfs",
+			.min_kver = "4.16",
+			.mkfs_ver = "mkfs.xfs >= 1.5.0",
 			.mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL},
 		},
 		{}
testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c +3 -1
index 3cc386c59..f12c4e7fd 100644
@@ -110,10 +110,12 @@ static struct tst_test test = {
 	.mount_device = 1,
 	.mntpoint = MNTPOINT,
 	.filesystems = (struct tst_fs []) {
-		{.type = "bcachefs"},
 		{.type = "btrfs"},
+		{.type = "bcachefs"},
 		{
 			.type = "xfs",
+			.min_kver = "4.16",
+			.mkfs_ver = "mkfs.xfs >= 1.5.0",
 			.mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL},
 		},
 		{}
testcases/kernel/syscalls/ioctl/ioctl_ficlonerange01.c +3 -1
index e352c513b..8fd1d299a 100644
@@ -145,10 +145,12 @@ static struct tst_test test = {
 	.mount_device = 1,
 	.mntpoint = MNTPOINT,
 	.filesystems = (struct tst_fs []) {
-		{.type = "bcachefs"},
 		{.type = "btrfs"},
+		{.type = "bcachefs"},
 		{
 			.type = "xfs",
+			.min_kver = "4.16",
+			.mkfs_ver = "mkfs.xfs >= 1.5.0",
 			.mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL},
 		},
 		{}
testcases/kernel/syscalls/ioctl/ioctl_ficlonerange02.c +3 -1
index ad36df162..eb941c3fc 100644
@@ -82,10 +82,12 @@ static struct tst_test test = {
 	.mount_device = 1,
 	.mntpoint = MNTPOINT,
 	.filesystems = (struct tst_fs []) {
-		{.type = "bcachefs"},
 		{.type = "btrfs"},
+		{.type = "bcachefs"},
 		{
 			.type = "xfs",
+			.min_kver = "4.16",
+			.mkfs_ver = "mkfs.xfs >= 1.5.0",
 			.mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL},
 		},
 		{}
Signature · 5 lines
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp