Skip to contentSkip to conversation

fsconfig04.c: Check FSCONFIG_SET_PATH

PATCH Superseded Wei Gao via ltp 4 participants 62 messages May 16, 2025 – Oct 23

v1 of 19 Superseded Latest is v19 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fsconfig04.c: Check FSCONFIG_SET_PATH

Fixes 1169

The fsconfig01.c does not test if FSCONFIG_SET_PATH have any effect, most of the calls there just set dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of ext3 or ext4 filesystem.

---
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 169 ++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index e369536ea..658ab24c4 100644
@@ -410,6 +410,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +169 -0

169 lines not on this page · raw message

Signature · 5 lines
2.49.0


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

Hi Wei,

I'm sorry not a real review, just point out obvious API errors.

Quoted 1 line
Fixes 1169
Fixes #1169
Quoted 5 lines

The fsconfig01.c does not test if FSCONFIG_SET_PATH have any effect, most of the calls there just set dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of ext3 or ext4 filesystem.

...

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 4

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +4 -0
new file mode 100644
index 000000000..119b8b175
@@ -0,0 +1,169 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Wei Gao <[email protected]>
+ *

This '*' should be '/*\' to be docparse.

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 13

Quoted 9 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +9 -0
+ * This test aims to validate the functionality of fsconfig(FSCONFIG_SET_PATH) in
+ * dynamically altering the external journal device of a ext3 or ext4 filesystem.
+ * Case acquires three loop devices (dev0, dev1, dev2), it formats dev1 and dev2
+ * as external journal devices using the -O journal_dev option and assigns them
+ * the same UUID. Then formats dev0 (the main filesystem) multiple times, first
+ * associating it with dev1, then change to dev2, finally back to dev1 again as
+ * an external journal using the -J device= option.
+ *
+ * 2 workarounds in this case need mention:

And here should be new line, right?

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 24

Quoted 12 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +11 -0
+ * - To avoid "journal UUID does not match" error when switch external journal device
+ *   we have to assign same UUID to dev1/dev2
+ * - Before fsconfig test we have to formats dev0 associating to dev1->dev2->dev1,
+ *   this will make sure both dev1/2's supper block contain correct content. Otherwise
+ *   you will encounter error such as "EXT4-fs (loop0): External journal has more than
+ *   one user (unsupported) - 0" when switch external journal device using fsconfig.
+ */
+
+#include "tst_test.h"
+#include "lapi/fsmount.h"
 
+#include "old/old_device.h"

Why this?

Quoted 16 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +16 -0
+
+#define MNTPOINT	"mntpoint"
+#define LOOP_DEV_SIZE 10
+#define UUID "d73c9e5e-97e4-4a9c-b17e-75a931b02660"
+
+static int fd;
+static const char *dev;
+static char dev0[NAME_MAX];
+static char dev1[NAME_MAX];
+static char dev2[NAME_MAX];
+
+static void cleanup(void)
+{
+	if (fd != -1)
+		SAFE_CLOSE(fd);
+

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 50

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +10 -0
+	TST_EXP_PASS_SILENT(tst_detach_device(dev1));
+	TST_EXP_PASS_SILENT(tst_detach_device(dev2));
+}
+
+static void setup(void)
+{
+	int ret = tst_system("tune2fs");
+
+	if (WEXITSTATUS(ret) == 127)
+		tst_brk(TCONF, "tune2fs does not exist");

We have .needs_cmds

Quoted 13 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +13 -0
+
+	strcpy(dev0, tst_device->dev);
+	dev = tst_acquire_loop_device(LOOP_DEV_SIZE, "dev1_file");
+	if (!dev)
+		tst_brk(TBROK, "acquire loop dev1 failed");
+
+	strcpy(dev1, dev);
+	dev = NULL;
+
+	dev = tst_acquire_loop_device(LOOP_DEV_SIZE, "dev2_file");
+	if (!dev)
+		tst_brk(TBROK, "acquire loop dev2 failed");
+	strcpy(dev2, dev);

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 73

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +10 -0
+
+	const char *const *mkfs_opts_set_UUID;
+	const char *const *mkfs_opts_set_journal_dev1;
+	const char *const *mkfs_opts_set_journal_dev2;
+
+	mkfs_opts_set_UUID = (const char *const []) {"-F",
+		"-U",
+		UUID,
+		"-O journal_dev",
+		NULL};

very nit: why the args cannot be on a single line?

Quoted 68 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +68 -0
+
+	char device_option_dev1[PATH_MAX];
+	char device_option_dev2[PATH_MAX];
+
+	sprintf(device_option_dev1, "device=%s", dev1);
+	sprintf(device_option_dev2, "device=%s", dev2);
+
+	mkfs_opts_set_journal_dev1 = (const char *const []) {"-F",
+		"-J",
+		device_option_dev1,
+		NULL};
+
+	mkfs_opts_set_journal_dev2 = (const char *const []) {"-F",
+		"-J",
+		device_option_dev2,
+		NULL};
+
+	SAFE_MKFS(dev1, tst_device->fs_type, mkfs_opts_set_UUID, NULL);
+	SAFE_MKFS(dev2, tst_device->fs_type, mkfs_opts_set_UUID, NULL);
+	SAFE_MKFS(dev0, tst_device->fs_type, mkfs_opts_set_journal_dev1, NULL);
+	SAFE_MKFS(dev0, tst_device->fs_type, mkfs_opts_set_journal_dev2, NULL);
+	SAFE_MKFS(dev0, tst_device->fs_type, mkfs_opts_set_journal_dev1, NULL);
+
+}
+
+static void run(void)
+{
+	TEST(fd = fsopen(tst_device->fs_type, 0));
+	if (fd == -1)
+		tst_brk(TBROK | TTERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", dev0, 0));
+	if (TST_RET == -1)
+		tst_brk(TFAIL | TTERRNO, "fsconfig(FSCONFIG_SET_STRING) failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_PATH, "journal_path", dev2, 0));
+	if (TST_RET == -1) {
+		if (TST_ERR == EOPNOTSUPP)
+			tst_brk(TCONF, "fsconfig(FSCONFIG_SET_PATH) not supported");
+		else
+			tst_brk(TFAIL | TTERRNO, "fsconfig(FSCONFIG_SET_PATH) failed");
+	}
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1)
+		tst_brk(TFAIL | TTERRNO, "fsconfig(FSCONFIG_CMD_CREATE) failed");
+
+	char loop_name[NAME_MAX];
+	char path[PATH_MAX];
+	char device_str[NAME_MAX];
+	unsigned int major, minor, device_num;
+	unsigned int found = 0;
+
+	int ret = sscanf(dev2, "/dev/%s", loop_name);
+
+	if (ret != 1)
+		tst_brk(TFAIL | TTERRNO, "can not parse loop_name");
+
+	sprintf(path, "/sys/block/%s/dev", loop_name);
+	SAFE_FILE_SCANF(path, "%u:%u", &major, &minor);
+	device_num = (major << 8) | minor;
+	sprintf(device_str, "0x%04X", device_num);
+
+	char line[PATH_MAX];
+	FILE *tune2fs;
+
+	sprintf(path, "tune2fs -l %s 2>&1", dev0);
+	tune2fs = popen(path, "r");

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 151

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +10 -0
+
+	while (fgets(line, PATH_MAX, tune2fs)) {
+		if (*line && strstr(line, "Journal device:") && strstr(line, device_str)) {
+			found = 1;
+			break;
+		}
+	}
+
+	if (found == 1)
+		tst_res(TPASS, "Journal device set pass");

Maybe "Device found in journal" ?

testcases/kernel/syscalls/fsconfig/fsconfig04.c

Quoted 2 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +2 -0
+	else
+		tst_res(TFAIL, "Journal device set failed");

Maybe "Device not found in journal" ?

Quoted 5 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +5 -0
+
+	pclose(tune2fs);
+	SAFE_CLOSE(fd);
+}
+

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 168

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +10 -0
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+	.all_filesystems = 1,
+	.skip_filesystems = (const char *const []){"ntfs", "vfat", "exfat",
+		"ext2", "tmpfs", "xfs", "btrfs", NULL},

So you skip nearly everything, right?
Why not use .mount_device = 1 ? That would mount the default filesystem.

Kind regards,
Petr

Quoted 1 line

+};

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
Quoted 3 lines · Petr Vorel

Hi Wei,

I'm sorry not a real review, just point out obvious API errors.

Thanks for pointing that out :)

Quoted 5 lines

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 24

Quoted 4 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +2 -0
+#include "lapi/fsmount.h"
 
+#include "old/old_device.h"

Why this?

tst_acquire_loop_device is needed in this case, and i saw following test case using old_device.h, so i just copy it into current case. testcases/lib/tst_device.c

Quoted 7 lines

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 168

Quoted 6 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +5 -0
+
+
+	.all_filesystems = 1,
+	.skip_filesystems = (const char *const []){"ntfs", "vfat", "exfat",
+		"ext2", "tmpfs", "xfs", "btrfs", NULL},

So you skip nearly everything, right?

Yes, ONLY ext3 and ext4 support journal setup

Quoted 1 line

Why not use .mount_device = 1 ? That would mount the default filesystem.

This case need format default device with ext3 opts='-F -J device=/dev/loop1' firstly, so the device can not be mounted before format.

Quoted 5 lines

Kind regards,
Petr

Quoted 1 line

+};

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

Hi Wei,

Quoted 7 lines · Petr Vorel
Quoted 3 lines

Hi Wei,

I'm sorry not a real review, just point out obvious API errors.

Thanks for pointing that out :)

Quoted 7 lines
Quoted 4 lines

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 24

Quoted 3 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +2 -0
+#include "lapi/fsmount.h"
 
+#include "old/old_device.h"

Why this?

tst_acquire_loop_device is needed in this case, and i saw following test case using old_device.h, so i just copy it into current case. testcases/lib/tst_device.c

Indeed it also uses it, maybe there is really no other alternative for new API.

Quoted 11 lines
Quoted 6 lines

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 168

Quoted 5 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +5 -0
+
+
+	.all_filesystems = 1,
+	.skip_filesystems = (const char *const []){"ntfs", "vfat", "exfat",
+		"ext2", "tmpfs", "xfs", "btrfs", NULL},

So you skip nearly everything, right?

Yes, ONLY ext3 and ext4 support journal setup

Quoted 1 line

Why not use .mount_device = 1 ? That would mount the default filesystem.

This case need format default device with ext3 opts='-F -J device=/dev/loop1' firstly, so the device can not be mounted before format.

Thanks for info.

Kind regards,
Petr

Quoted 2 lines
Quoted 2 lines

Kind regards,
Petr

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

PATCH v2 1/1 fsconfig04.c: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp
Fixes #1169

The fsconfig01.c does not test if FSCONFIG_SET_PATH have any effect, most of the calls there just set dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of ext3 or ext4 filesystem.

---
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 163 ++++++++++++++++++
 3 files changed, 165 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index e369536ea..658ab24c4 100644
@@ -410,6 +410,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +163 -0

163 lines not on this page · raw message

Signature · 5 lines
2.49.0


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

Hi Wei,

Quoted 7 lines
Fixes #1169

The fsconfig01.c does not test if FSCONFIG_SET_PATH have any effect, most of the calls there just set dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of ext3 or ext4 filesystem.

Again, I just pointed out common errors (need more time for a proper feature review). But on the first look LGTM.

...

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 7

Quoted 13 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +7 -0
new file mode 100644
index 000000000..0df16f0ed
@@ -0,0 +1,163 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Wei Gao <[email protected]>
+ */
+
+/*\ This test aims to validate the functionality of fsconfig(FSCONFIG_SET_PATH) in
+ * dynamically altering the external journal device of a ext3 or ext4 filesystem.

/*\
* This test aims to validate the functionality of fsconfig(FSCONFIG_SET_PATH) in
* dynamically altering the external journal device of a ext3 or ext4 filesystem.
...

Quoted 3 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +3 -0
+
+static void setup(void)
+{

...

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 86

Quoted 6 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +6 -0
+	SAFE_MKFS(dev1, tst_device->fs_type, mkfs_opts_set_UUID, NULL);
+	SAFE_MKFS(dev2, tst_device->fs_type, mkfs_opts_set_UUID, NULL);
+	SAFE_MKFS(dev0, tst_device->fs_type, mkfs_opts_set_journal_dev1, NULL);
+	SAFE_MKFS(dev0, tst_device->fs_type, mkfs_opts_set_journal_dev2, NULL);
+	SAFE_MKFS(dev0, tst_device->fs_type, mkfs_opts_set_journal_dev1, NULL);
+

Please remove this empty line.

Quoted 24 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +24 -0
+}
+
+static void run(void)
+{
+	TEST(fd = fsopen(tst_device->fs_type, 0));
+	if (fd == -1)
+		tst_brk(TBROK | TTERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", dev0, 0));
+	if (TST_RET == -1)
+		tst_brk(TFAIL | TTERRNO, "fsconfig(FSCONFIG_SET_STRING) failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_PATH, "journal_path", dev2, 0));
+	if (TST_RET == -1) {
+		if (TST_ERR == EOPNOTSUPP)
+			tst_brk(TCONF, "fsconfig(FSCONFIG_SET_PATH) not supported");
+		else
+			tst_brk(TFAIL | TTERRNO, "fsconfig(FSCONFIG_SET_PATH) failed");
+	}
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1)
+		tst_brk(TFAIL | TTERRNO, "fsconfig(FSCONFIG_CMD_CREATE) failed");
+

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 120

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +10 -0
+	char loop_name[NAME_MAX];
+	char path[PATH_MAX];
+	char device_str[NAME_MAX];
+	unsigned int major, minor, device_num;
+	unsigned int found = 0;
+
+	int ret = sscanf(dev2, "/dev/%s", loop_name);
+
+	if (ret != 1)
+		tst_brk(TFAIL | TTERRNO, "can not parse loop_name");

Using SAFE_SSCANF() is enough (it checks number of found items), please use it:

	SAFE_SSCANF(dev2, "/dev/%s", loop_name);

testcases/kernel/syscalls/fsconfig/fsconfig04.c

Quoted 2 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +2 -0
+
+	sprintf(path, "/sys/block/%s/dev", loop_name);

snprintf() is safer.

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 125

Quoted 3 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +3 -0
+	SAFE_FILE_SCANF(path, "%u:%u", &major, &minor);
+	device_num = (major << 8) | minor;
+	sprintf(device_str, "0x%04X", device_num);

And here as well.

Quoted 27 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +27 -0
+
+	char line[PATH_MAX];
+	FILE *tune2fs;
+
+	sprintf(path, "tune2fs -l %s 2>&1", dev0);
+	tune2fs = popen(path, "r");
+
+	while (fgets(line, PATH_MAX, tune2fs)) {
+		if (*line && strstr(line, "Journal device:") && strstr(line, device_str)) {
+			found = 1;
+			break;
+		}
+	}
+
+	if (found == 1)
+		tst_res(TPASS, "Device found in journal");
+	else
+		tst_res(TFAIL, "Device not found in journal");
+
+	pclose(tune2fs);
+	SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 162

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +10 -0
+	.needs_root = 1,
+	.format_device = 1,
+	.mntpoint = MNTPOINT,
+	.all_filesystems = 1,
+	.needs_cmds = (const char *[]) {
+		"tune2fs",
+		NULL
+	},
+	.skip_filesystems = (const char *const []){"ntfs", "vfat", "exfat",
+		"ext2", "tmpfs", "xfs", "btrfs", NULL},

You need to skip also bcachefs:

mkfs.bcachefs: invalid option -- 'F' fsconfig04.c:82: TBROK: mkfs.bcachefs failed with exit code 1

Having a way to specify just ext3 and ext4 would be better, IMHO we don't have way to do it.

Kind regards,
Petr

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

Hi!

Quoted 5 lines

mkfs.bcachefs: invalid option -- 'F' fsconfig04.c:82: TBROK: mkfs.bcachefs failed with exit code 1

Having a way to specify just ext3 and ext4 would be better, IMHO we don't have way to do it.

Of course we do, that's what we do for subset of statx tests:

	.filesystems = (struct tst_fs []) {
		{.type = "ext3"},
		{.type = "ext4"},
		{}
	};
Signature · 5 lines
Cyril Hrubis
[email protected]

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

Hi!

Quoted 5 lines

mkfs.bcachefs: invalid option -- 'F' fsconfig04.c:82: TBROK: mkfs.bcachefs failed with exit code 1

Having a way to specify just ext3 and ext4 would be better, IMHO we don't have way to do it.

Quoted 7 lines

Of course we do, that's what we do for subset of statx tests:

	.filesystems = (struct tst_fs []) {
		{.type = "ext3"},
		{.type = "ext4"},
		{}
	};

Thanks! I forget the rewrite allows this nice syntax.

We should have (after the release) some examples somewhere (not sure if the docs in @filesystems in include/tst_test.h could be extended or we can dare to have static page with examples as we had in the old API - might be easier to search).

And/or C API tests in lib/newlib_tests/.

Kind regards,
Petr

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

Hi!

Quoted 6 lines

Thanks! I forget the rewrite allows this nice syntax.

We should have (after the release) some examples somewhere (not sure if the docs in @filesystems in include/tst_test.h could be extended or we can dare to have static page with examples as we had in the old API - might be easier to search).

I would say that the documentation for the tst_test structure is already too long.

Quoted 1 line

And/or C API tests in lib/newlib_tests/.

Having small C examples in newlib_tests and then rendering them into examples section into the documentation would be awesome.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

[LTP] LTP doc: test examples [was: Re: [PATCH v2] fsconfig04.c: Check FSCONFIG_SET_PATH]

Hi all,

Quoted 8 lines

Hi!

Quoted 6 lines

Thanks! I forget the rewrite allows this nice syntax.

We should have (after the release) some examples somewhere (not sure if the docs in @filesystems in include/tst_test.h could be extended or we can dare to have static page with examples as we had in the old API - might be easier to search).

Quoted 6 lines

I would say that the documentation for the tst_test structure is already too long.

Quoted 1 line

And/or C API tests in lib/newlib_tests/.

Having small C examples in newlib_tests

Add test for .filesystems
https://github.com/linux-test-project/ltp/issues/1243

Quoted 2 lines

and then rendering them into
examples section into the documentation would be awesome.

Render examples from newlib_tests into docs
https://github.com/linux-test-project/ltp/issues/1244

Feel free to modify them both.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw
In reply to Wei Gao via ltp

Hi!

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 162

Quoted 2 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +2 -0
+	.skip_filesystems = (const char *const []){"ntfs", "vfat", "exfat",
+		"ext2", "tmpfs", "xfs", "btrfs", NULL},

This should be .filesystems = ... as I wrote in earlier email.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

PATCH v3 1/1 fsconfig04.c: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp
Fixes #1169

The fsconfig01.c does not test if FSCONFIG_SET_PATH have any effect, most of the calls there just set dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of ext3 or ext4 filesystem.

---
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 162 ++++++++++++++++++
 3 files changed, 164 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index e369536ea..658ab24c4 100644
@@ -410,6 +410,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +162 -0

162 lines not on this page · raw message

Signature · 5 lines
2.49.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#14 lore raw
Quoted 5 lines · Andrea Cervesato

Hi!

please, re-read the previous reviews before submitting a new version, because there are still some issues not achieved.

Thanks for take a look.
I think Cyril comments should be fixed in current version after recheck, so i move patch into Needs Review in patchwork again.

Quoted 5 lines
Signature · 3 lines
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#15 lore raw

Hi Andrea, Wei,

Quoted 5 lines · Andrea Cervesato
Quoted 4 lines

Hi!

please, re-read the previous reviews before submitting a new version, because there are still some issues not achieved.

If you *were* a concrete what is wrong, you'd have saved Wei's and my time :).

Quoted 3 lines

Thanks for take a look.
I think Cyril comments should be fixed in current version after recheck, so i move patch into Needs Review in patchwork again.

I'd also say all issues has been fixed. What exactly do you mean?

Also, test needs rebase after Wei's and Li's changes to fix compilation.

Kind regards,
Petr

+++ testcases/kernel/syscalls/fsconfig/fsconfig04.c @@ -24,7 +24,7 @@

#include "tst_test.h"
#include "lapi/fsmount.h"
-#include "old/old_device.h"
+#include "old/tso_device.h"

#define MNTPOINT "mntpoint"
#define LOOP_DEV_SIZE 10
@@ -150,9 +150,9 @@ static struct tst_test test = {
.needs_root = 1,
.format_device = 1,
.mntpoint = MNTPOINT,
- .needs_cmds = (const char *[]) {
- "tune2fs",
- NULL
+ .needs_cmds = (struct tst_cmd[]) {
+ {.cmd = "tune2fs"},
+ {}
},
.filesystems = (struct tst_fs []) {
{.type = "ext3"},

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#16 lore raw
Quoted 8 lines · Petr Vorel

Hi Andrea, Wei,

Quoted 5 lines · Andrea Cervesato
Quoted 4 lines

Hi!

please, re-read the previous reviews before submitting a new version, because there are still some issues not achieved.

Quoted 7 lines

If you *were* a concrete what is wrong, you'd have saved Wei's and my time :).

Quoted 3 lines

Thanks for take a look.
I think Cyril comments should be fixed in current version after recheck, so i move patch into Needs Review in patchwork again.

I'd also say all issues has been fixed. What exactly do you mean?

I found patch in Changes Requested state so i change it to Needs Review in patchwork(Since i think this patch already fix all old comments).Then others can continue review it and give new comments.
Correct me if this action is wrong :).

Quoted 29 lines

Also, test needs rebase after Wei's and Li's changes to fix compilation.

Kind regards,
Petr

+++ testcases/kernel/syscalls/fsconfig/fsconfig04.c

(quoted diff) +4 -4
@@ -24,7 +24,7 @@
 
 #include "tst_test.h"
 #include "lapi/fsmount.h"
-#include "old/old_device.h"
+#include "old/tso_device.h"
 
 #define MNTPOINT	"mntpoint"
 #define LOOP_DEV_SIZE 10
@@ -150,9 +150,9 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.format_device = 1,
 	.mntpoint = MNTPOINT,
-	.needs_cmds = (const char *[]) {
-		"tune2fs",
-		NULL
+	.needs_cmds = (struct tst_cmd[]) {
+		{.cmd = "tune2fs"},
+		{}
 	},
 	.filesystems = (struct tst_fs []) {
 		{.type = "ext3"},
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#17 lore raw
In reply to Petr Vorel

Hi Wei,

Quoted 1 line

+ tune2fs = popen(path, "r");

Could you please use SAFE_POPEN() ?

Maybe if you don't get any feedback could you please send v4
- rebased v3 with the changes below?

Kind regards,
Petr

Quoted 23 lines

+++ testcases/kernel/syscalls/fsconfig/fsconfig04.c

(quoted diff) +4 -4
@@ -24,7 +24,7 @@
 
 #include "tst_test.h"
 #include "lapi/fsmount.h"
-#include "old/old_device.h"
+#include "old/tso_device.h"
 
 #define MNTPOINT	"mntpoint"
 #define LOOP_DEV_SIZE 10
@@ -150,9 +150,9 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.format_device = 1,
 	.mntpoint = MNTPOINT,
-	.needs_cmds = (const char *[]) {
-		"tune2fs",
-		NULL
+	.needs_cmds = (struct tst_cmd[]) {
+		{.cmd = "tune2fs"},
+		{}
 	},
 	.filesystems = (struct tst_fs []) {
 		{.type = "ext3"},
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#18 lore raw

PATCH v4 1/1 fsconfig04.c: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH have any effect, most of the calls there just set dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of ext3 or ext4 filesystem.

---
v3->v4:
- Replace popen to SAFE_POPEN

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 163 ++++++++++++++++++
 3 files changed, 165 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index d72fceb5e..49ba7d845 100644
@@ -422,6 +422,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +163 -0

163 lines not on this page · raw message

Signature · 5 lines
2.52.0


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

PATCH v5 1/1 fsconfig04: Check FSCONFIG_SET_PATH

The fsconfig01.c does not test if FSCONFIG_SET_PATH have any effect, most of the calls there just set dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of ext3 or ext4 filesystem.

---
v4->v5:
1. Fixed lowercase hex issue in device_str to match tune2fs output.
2. Initialized fd = -1 and improved cleanup() with safety guards.
3. Used PATH_MAX and snprintf() for safe path handling.
4. Updated needs_cmds to the modern struct tst_cmd format.
5. Restored TST_EXP_PASS_SILENT for device detachment.
6. Renamed "workarounds" to "Implementation notes".

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 168 ++++++++++++++++++
 3 files changed, 170 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index 5025b259f..84adf4fad 100644
@@ -422,6 +422,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +168 -0

168 lines not on this page · raw message

Signature · 5 lines
2.52.0


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

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

Quoted 3 lines · Wei Gao

fsconfig04: Check FSCONFIG_SET_PATH

+#include "old/tso_device.h"

tst_acquire_loop_device() is not part of the new API (tst_device.h). Please use tst_find_free_loopdev() + tst_attach_device() from tst_device.h instead of pulling in a legacy header.

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 154

Quoted 4 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +4 -0
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,

The patch has a Fixes: link to GitHub issue #1169, making this a regression test. Add a .tags field:

	.tags = (const struct tst_tag[]) {
		{"github", "1169"},
		{}
	},

---
Note:

Our agent completed the review of the patch. 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
#21 lore raw

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

Quoted 7 lines

The patch has a Fixes: link to GitHub issue #1169, making this a regression test. Add a .tags field:

	.tags = (const struct tst_tag[]) {
		{"github", "1169"},
		{}
	},

Please ignore this, I will add a rule so this won't happen, we dont want to have github fixes inside the tst_test struct :-)

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

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

PATCH v6 1/1 fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH have any effect, most of the calls there just set dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of ext3 or ext4 filesystem.

---
v5->v6:
- use tst_find_free_loopdev() + tst_attach_device() from tst_device.h instead of pulling in a legacy header.

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 172 ++++++++++++++++++
 3 files changed, 174 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index 5025b259f..84adf4fad 100644
@@ -422,6 +422,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +172 -0

172 lines not on this page · raw message

Signature · 5 lines
2.52.0


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

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

Review

Quoted 3 lines · Wei Gao

fsconfig04: Check FSCONFIG_SET_PATH

(quoted diff) +1 -0
+	Fixes: https://github.com/linux-test-project/ltp/issues/1169

Fixes: must reference a git commit SHA. Use Closes: for GitHub issue URLs.

Quoted 3 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +3 -0
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1)
+		tst_brk(TFAIL | TTERRNO, "fsconfig(FSCONFIG_CMD_CREATE) failed");

[...]

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 140

Quoted 5 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +5 -0
+	snprintf(path, sizeof(path), "tune2fs -l %s 2>&1", dev0);
+	tune2fs = SAFE_POPEN(path, "r");
+
+	while (fgets(line, PATH_MAX, tune2fs)) {
+		if (*line && strstr(line, "Journal device:") && strstr(line, device_str)) {

FSCONFIG_CMD_CREATE instantiates the filesystem context in kernel memory but does not update the on-disk superblock. tune2fs -l dev0 will still show dev1 as the journal device (from the last mkfs), not dev2 — so found will always be 0 and the test always reports TFAIL. Either complete the mount with fsmount()/move_mount() and verify the active journal via runtime state, or confirm whether ext4's FSCONFIG_CMD_CREATE with journal_path actually persists the binding to the superblock (and document it if so).

---
Note:

Our agent completed the review of the patch. 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
#24 lore raw

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Quoted 15 lines · On Thu, Apr 30, 2026 at 06:34:58AM +0000, [email protected]…

Hi Wei,

Review

Quoted 3 lines · Wei Gao

fsconfig04: Check FSCONFIG_SET_PATH

(quoted diff) +1 -0
+	Fixes: https://github.com/linux-test-project/ltp/issues/1169

Fixes: must reference a git commit SHA. Use Closes: for GitHub issue URLs.

Quoted 3 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +3 -0
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1)
+		tst_brk(TFAIL | TTERRNO, "fsconfig(FSCONFIG_CMD_CREATE) failed");

[...]

Quoted 13 lines

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 140

Quoted 5 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +5 -0
+	snprintf(path, sizeof(path), "tune2fs -l %s 2>&1", dev0);
+	tune2fs = SAFE_POPEN(path, "r");
+
+	while (fgets(line, PATH_MAX, tune2fs)) {
+		if (*line && strstr(line, "Journal device:") && strstr(line, device_str)) {

FSCONFIG_CMD_CREATE instantiates the filesystem context in kernel memory but does not update the on-disk superblock. tune2fs -l dev0 will still show dev1 as the journal device (from the last mkfs), not dev2 — so found will always be 0 and the test always reports TFAIL. Either complete the mount with fsmount()/move_mount() and verify the active journal via runtime state, or confirm whether ext4's FSCONFIG_CMD_CREATE with journal_path actually persists the binding to the superblock (and document it if so).

Ran fsconfig04.c on a Linux 6.17 kernel. The test passed with TPASS: Device found in journal.

Quoted 10 lines

---
Note:

Our agent completed the review of the patch. 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
#25 lore raw

Re: [LTP] [PATCH v6] fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

Hi Wei,

Quoted 7 lines

The fsconfig01.c does not test if FSCONFIG_SET_PATH have any effect, most of the calls there just set dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of ext3 or ext4 filesystem.

This should be Closes:

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 7

Quoted 3 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +3 -0
+
+/*\
+ * This test aims to validate the functionality of fsconfig(FSCONFIG_SET_PATH) in

We need man syntax here, so we can have manual link in the test catalog. :manpage:fsconfig(2)

Review

Quoted 2 lines
(quoted diff) +2 -0
+static void setup(void)
+{

We neeed fsopen_supported_by_kernel() here.

Review

Quoted 2 lines
(quoted diff) +2 -0
+	strcpy(dev0, tst_device->dev);
+

I think we are mixing too many things here. tst_brk() should be used with TBROK and TFAIL should be followed by a return. Use TFAIL for the tested feature and TBROK for everything else.

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

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

PATCH v7 1/1 fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
v6->v7:
* Doc Comment: Rewrapped introduction & added Sphinx :manpage:fsconfig(2)`` link.
* Setup: Added fsopen_supported_by_kernel() check.
* Logic & Results: Replaced tst_brk(TFAIL) with tst_res(TFAIL) + return.

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 184 ++++++++++++++++++
 3 files changed, 186 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index 5025b259f..84adf4fad 100644
@@ -422,6 +422,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +184 -0

184 lines not on this page · raw message

Signature · 5 lines
2.54.0


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

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 112

Quoted 8 lines · Wei Gao

fsconfig04: Check FSCONFIG_SET_PATH

testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +6 -0
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", dev0, 0));
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TTERRNO, "fsconfig(FSCONFIG_SET_STRING) failed");
+		SAFE_CLOSE(fd);
+		return;
+	}

FSCONFIG_SET_STRING is not the subject of this test -- it is infrastructure needed before the FSCONFIG_SET_PATH call under test. If it fails, the test cannot proceed, so it should be reported as TBROK, not TFAIL.

Using tst_brk(TBROK | TTERRNO, ...) would also simplify this block because cleanup() already closes fd, making the explicit SAFE_CLOSE unnecessary:

	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", dev0, 0));
	if (TST_RET == -1)
		tst_brk(TBROK | TTERRNO, "fsconfig(FSCONFIG_SET_STRING) failed");

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 143

Quoted 9 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +9 -0
+	unsigned int major, minor, device_num;
+	unsigned int found = 0;
+
+	SAFE_SSCANF(dev2, "/dev/%s", loop_name);
+
+	snprintf(path, sizeof(path), "/sys/block/%s/dev", loop_name);
+	SAFE_FILE_SCANF(path, "%u:%u", &major, &minor);
+	device_num = (major << 8) | minor;
+	snprintf(device_str, sizeof(device_str), "0x%04x", device_num);

The encoding (major << 8) | minor only matches the kernel's new_encode_dev() when minor < 256. For minor >= 256 the kernel stores (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12), which is what tune2fs prints.

On a system with many loop devices in use the test could get a loop device with minor >= 256, causing the computed string to differ from tune2fs output and producing a false TFAIL.

Consider something like:

	device_num = (minor & 0xff) | (major << 8)
		| ((minor & ~0xff) << 12);

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
#28 lore raw

PATCH v8 1/1 fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
v7->v8:
1. Converted setup-level fsconfig(FSCONFIG_SET_STRING) failure from TFAIL to TBROK to clean up execution flow.
2. Fixed device number encoding to (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12) to properly support loop device minor numbers ≥ 256.

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 181 ++++++++++++++++++
 3 files changed, 183 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index a021c79da..a7a9cf638 100644
@@ -422,6 +422,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +181 -0

181 lines not on this page · raw message

Signature · 5 lines
2.54.0


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

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 117

Quoted 9 lines · Wei Gao

fsconfig04: Check FSCONFIG_SET_PATH

testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +7 -0
+	TEST(fsconfig(fd, FSCONFIG_SET_PATH, "journal_path", dev2, 0));
+	if (TST_RET == -1) {
+		if (TST_ERR == EOPNOTSUPP) {
+			tst_res(TCONF, "fsconfig(FSCONFIG_SET_PATH) not supported");
+		} else {
+			tst_res(TFAIL | TTERRNO, "fsconfig(FSCONFIG_SET_PATH) failed");
+		}

Minor: the inner if/else branches are single-statement bodies, so braces should be dropped per kernel coding style.

Verdict - Reviewed

---
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
#30 lore raw

PATCH v9 1/1 fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
v8->v9:
- Drop braces for single-statement inner branches

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 180 ++++++++++++++++++
 3 files changed, 182 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index a021c79da..a7a9cf638 100644
@@ -422,6 +422,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +180 -0

180 lines not on this page · raw message

Signature · 5 lines
2.54.0


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

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

Quoted 1 line · Wei Gao

fsconfig04: Check FSCONFIG_SET_PATH

Verdict - Reviewed

---
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
#32 lore raw

Re: [LTP] [PATCH v9] fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

Hi Wei,

Quoted 49 lines

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
v8->v9:
- Drop braces for single-statement inner branches

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 180 ++++++++++++++++++
 3 files changed, 182 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index a021c79da..a7a9cf638 100644
@@ -422,6 +422,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +4 -0
new file mode 100644
index 000000000..ce6c8fd01
@@ -0,0 +1,180 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2026 Wei Gao <[email protected]>
+ */

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 14

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +10 -0
+
+/*\
+ * This test aims to validate :manpage:`fsconfig(2)` with the
+ * FSCONFIG_SET_PATH operation in dynamically altering the external
+ * journal device of an ext3 or ext4 filesystem. Case acquires three
+ * loop devices (dev0, dev1, dev2), it formats dev1 and dev2 as
+ * external journal devices using the -O journal_dev option and assigns
+ * them the same UUID. Then formats dev0 (the main filesystem) multiple
+ * times, first associating it with dev1, then change to dev2, finally
+ * back to dev1 again as an external journal using the -J device= option.

This is not a description but the Description + Algorithm section. Please split them so we understand what the test aims for + algorithm that is used.

Quoted 49 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +49 -0
+ *
+ * 2 Implementation notes in this case need mention:
+ *
+ * - To avoid "journal UUID does not match" error when switch external journal device
+ *   we have to assign same UUID to dev1/dev2
+ * - Before fsconfig test we have to format dev0 associating to dev1->dev2->dev1,
+ *   this will make sure both dev1/2's super block contain correct content. Otherwise
+ *   you will encounter error such as "EXT4-fs (loop0): External journal has more than
+ *   one user (unsupported) - 0" when switch external journal device using fsconfig.
+ */
+
+#include "tst_test.h"
+#include "tst_safe_stdio.h"
+#include "lapi/fsmount.h"
+
+#define MNTPOINT	"mntpoint"
+#define LOOP_DEV_SIZE 10
+#define UUID "d73c9e5e-97e4-4a9c-b17e-75a931b02660"
+
+static int fd = -1;
+static char dev0[PATH_MAX];
+static char dev1[PATH_MAX];
+static char dev2[PATH_MAX];
+
+static void cleanup(void)
+{
+	if (fd != -1)
+		SAFE_CLOSE(fd);
+
+	if (dev1[0])
+		tst_detach_device(dev1);
+
+	if (dev2[0])
+		tst_detach_device(dev2);
+}
+
+static void setup(void)
+{
+	fsopen_supported_by_kernel();
+
+	strcpy(dev0, tst_device->dev);
+
+	if (tst_prealloc_file("dev1_file", 1024 * 1024, LOOP_DEV_SIZE))
+		tst_brk(TBROK, "Failed to create dev1_file");
+
+	if (tst_find_free_loopdev(dev1, sizeof(dev1)) == -1)
+		tst_brk(TBROK, "No free loop device found for dev1");
+
+	if (tst_attach_device(dev1, "dev1_file"))

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 73

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +10 -0
+		tst_brk(TBROK, "Failed to attach dev1_file to %s", dev1);
+
+	if (tst_prealloc_file("dev2_file", 1024 * 1024, LOOP_DEV_SIZE))
+		tst_brk(TBROK, "Failed to create dev2_file");
+
+	if (tst_find_free_loopdev(dev2, sizeof(dev2)) == -1)
+		tst_brk(TBROK, "No free loop device found for dev2");
+
+	if (tst_attach_device(dev2, "dev2_file"))
+		tst_brk(TBROK, "Failed to attach dev2_file to %s", dev2);

This code is duplicated. We should create a helper that prealloc and attach the device.

Quoted 86 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +86 -0
+
+	const char *const *mkfs_opts_set_UUID;
+	const char *const *mkfs_opts_set_journal_dev1;
+	const char *const *mkfs_opts_set_journal_dev2;
+
+	mkfs_opts_set_UUID = (const char *const []) {"-F", "-U", UUID,
+		"-O", "journal_dev", NULL};
+
+	char device_option_dev1[PATH_MAX];
+	char device_option_dev2[PATH_MAX];
+
+	snprintf(device_option_dev1, sizeof(device_option_dev1), "device=%s", dev1);
+	snprintf(device_option_dev2, sizeof(device_option_dev2), "device=%s", dev2);
+
+	mkfs_opts_set_journal_dev1 = (const char *const []) {"-F", "-J",
+		device_option_dev1, NULL};
+
+	mkfs_opts_set_journal_dev2 = (const char *const []) {"-F", "-J",
+		device_option_dev2, NULL};
+
+	SAFE_MKFS(dev1, tst_device->fs_type, mkfs_opts_set_UUID, NULL);
+	SAFE_MKFS(dev2, tst_device->fs_type, mkfs_opts_set_UUID, NULL);
+	SAFE_MKFS(dev0, tst_device->fs_type, mkfs_opts_set_journal_dev1, NULL);
+	SAFE_MKFS(dev0, tst_device->fs_type, mkfs_opts_set_journal_dev2, NULL);
+	SAFE_MKFS(dev0, tst_device->fs_type, mkfs_opts_set_journal_dev1, NULL);
+}
+
+static void run(void)
+{
+	TEST(fd = fsopen(tst_device->fs_type, 0));
+	if (fd == -1)
+		tst_brk(TBROK | TTERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", dev0, 0));
+	if (TST_RET == -1)
+		tst_brk(TBROK | TTERRNO, "fsconfig(FSCONFIG_SET_STRING) failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_PATH, "journal_path", dev2, 0));
+	if (TST_RET == -1) {
+		if (TST_ERR == EOPNOTSUPP)
+			tst_res(TCONF, "fsconfig(FSCONFIG_SET_PATH) not supported");
+		else
+			tst_res(TFAIL | TTERRNO, "fsconfig(FSCONFIG_SET_PATH) failed");
+		SAFE_CLOSE(fd);
+		return;
+	}
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TTERRNO, "fsconfig(FSCONFIG_CMD_CREATE) failed");
+		SAFE_CLOSE(fd);
+		return;
+	}
+
+	char loop_name[NAME_MAX];
+	char path[PATH_MAX];
+	char device_str[NAME_MAX];
+	unsigned int major, minor, device_num;
+	unsigned int found = 0;
+
+	SAFE_SSCANF(dev2, "/dev/%s", loop_name);
+
+	snprintf(path, sizeof(path), "/sys/block/%s/dev", loop_name);
+	SAFE_FILE_SCANF(path, "%u:%u", &major, &minor);
+	device_num = (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12);
+	snprintf(device_str, sizeof(device_str), "0x%04x", device_num);
+
+	char line[PATH_MAX];
+	FILE *tune2fs;
+
+	snprintf(path, sizeof(path), "tune2fs -l %s 2>&1", dev0);
+	tune2fs = SAFE_POPEN(path, "r");
+
+	while (fgets(line, PATH_MAX, tune2fs)) {
+		if (*line && strstr(line, "Journal device:") && strstr(line, device_str)) {
+			found = 1;
+			break;
+		}
+	}
+
+	if (found == 1)
+		tst_res(TPASS, "Device found in journal");
+	else
+		tst_res(TFAIL, "Device not found in journal");
+
+	pclose(tune2fs);

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 169

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +10 -0
+	SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.format_device = 1,

we already format the device manually.

Quoted 14 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +11 -0
+	.mntpoint = MNTPOINT,
+	.needs_cmds = (struct tst_cmd []) {
+		{.cmd = "tune2fs"},
+		{}
+	},
+	.filesystems = (struct tst_fs []) {
+		{.type = "ext3"},
+		{.type = "ext4"},
+		{}
+	},
+};
Signature · 1 line
2.54.0

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

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

PATCH v10 1/1 fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
v9->v10:
- Split the test doc block into clear [Description] and [Algorithm] sections.
- Refactor loop device creation and attachment into a create_and_attach_loopdev() helper to eliminate duplicate code.
- Replace redundant .format_device = 1 with .needs_device = 1 in the tst_test structure since the device is formatted manually in setup().

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 190 ++++++++++++++++++
 3 files changed, 192 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index a021c79da..a7a9cf638 100644
@@ -422,6 +422,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +190 -0

190 lines not on this page · raw message

Signature · 5 lines
2.54.0


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

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

Quoted 12 lines · Wei Gao

fsconfig04: Check FSCONFIG_SET_PATH

+ * [Algorithm]
+ *
+ * Case acquires three loop devices (dev0, dev1, dev2).
+ * It formats dev1 and dev2 as external journal devices using the
+ * "-O journal_dev" option and assigns them the same UUID.
+ *
+ * Then, it formats dev0 (the main filesystem) multiple times,
+ * first associating it with dev1, then dev2, and finally back to
+ * dev1 again as an external journal using the "-J device=" option.
+ *

Quoted 8 lines

+ * Next, it calls fsopen() and configures the filesystem using
+ * fsconfig(FSCONFIG_SET_STRING, "source", dev0) and
+ * fsconfig(FSCONFIG_SET_PATH, "journal_path", dev2) to dynamically
+ * alter the external journal device.
+ *
+ * After applying FSCONFIG_CMD_CREATE, it verifies using tune2fs
+ * if the external journal device of dev0 has been successfully
+ * and dynamically switched to dev2.

The [Algorithm] section must be a bulleted list using '-', not prose paragraphs. See documentation.md Section 4.

Something like:

* [Algorithm]
*
* - Acquire three loop devices (dev0 from framework, dev1, dev2).
* - Format dev1 and dev2 as external journal devices with the same UUID
* ("-O journal_dev -U <uuid>").
* - Format dev0 three times to cycle journal associations:
* dev1 -> dev2 -> dev1, so both journal superblocks are consistent.
* - Open dev0 via fsopen(2) and set the source and journal_path using
* fsconfig(FSCONFIG_SET_STRING) and fsconfig(FSCONFIG_SET_PATH).
* - Apply FSCONFIG_CMD_CREATE and verify with tune2fs that dev0's
* journal device is now dev2.

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
#35 lore raw

PATCH v11 1/1 fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 183 ++++++++++++++++++
 3 files changed, 185 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index 65fb4d1ce..13bb59cde 100644
@@ -437,6 +437,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +183 -0

183 lines not on this page · raw message

Signature · 5 lines
2.54.0


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

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

Quoted 8 lines · Wei Gao

fsconfig04: Check FSCONFIG_SET_PATH

+ * - Format dev1 and dev2 as external journal devices with the same UUID
+ * ("-O journal_dev -U <uuid>").
+ * - Format dev0 three times to cycle journal associations:
+ * dev1 -> dev2 -> dev1, so both journal superblocks are consistent.
+ * - Open dev0 via fsopen(2) and set the source and journal_path using
+ * fsconfig(FSCONFIG_SET_STRING) and fsconfig(FSCONFIG_SET_PATH).

Could the syscall references use the required :manpage:fsopen(2) and :manpage:fsconfig(2) roles, and could identifiers and command-line arguments use reStructuredText inline literals (for example, ``FSCONFIG_SET_PATH`` and ``-O journal_dev -U <uuid>``)? This block is exported to the test catalog, where these roles and literals provide the expected links and formatting.

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
#37 lore raw

PATCH v12 1/1 fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
v11-v12:
- Use :manpage: roles for fsopen(2) and fsconfig(2).
- Use reStructuredText double backticks for inline literals.

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 184 ++++++++++++++++++
 3 files changed, 186 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index 65fb4d1ce..13bb59cde 100644
@@ -437,6 +437,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +184 -0

184 lines not on this page · raw message

Signature · 5 lines
2.54.0


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

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 126

Quoted 9 lines · Wei Gao

fsconfig04: Check FSCONFIG_SET_PATH

testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +7 -0
+	TEST(fsconfig(fd, FSCONFIG_SET_PATH, "journal_path", dev2, 0));
+	if (TST_RET == -1) {
+		if (TST_ERR == EOPNOTSUPP)
+			tst_brk(TCONF, "fsconfig(FSCONFIG_SET_PATH) not supported");
+		else
+			tst_brk(TFAIL | TTERRNO, "fsconfig(FSCONFIG_SET_PATH) failed");
+	}

Could this test be gated with .min_kver = "7.2"?

Before Linux 7.2, ext4 declared journal_path as a string parameter, so FSCONFIG_SET_PATH is rejected with EINVAL rather than EOPNOTSUPP. Since fsopen_supported_by_kernel() only gates fsopen at Linux 5.2, those kernels reach the else branch and report TFAIL instead of TCONF.

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 141

Quoted 4 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +4 -0
+	SAFE_SSCANF(dev2, "/dev/%s", loop_name);
+
+	snprintf(path, sizeof(path), "/sys/block/%s/dev", loop_name);
+	SAFE_FILE_SCANF(path, "%u:%u", &major, &minor);

Could the device number be obtained from stat(dev2).st_rdev instead?

tst_find_free_loopdev() also supports /dev/loop/N and /dev/block/loopN. Those paths produce loop/N or block/loopN here, causing the test to read a nonexistent sysfs path and terminate with TBROK.

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 120

Quoted 7 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +7 -0
+	SAFE_MKFS(dev0, tst_device->fs_type, mkfs_opts_set_journal_dev1, NULL);
+}
+
+static void run(void)
+{
+	...
+	TEST(fsconfig(fd, FSCONFIG_SET_PATH, "journal_path", dev2, 0));

Could each iteration reset dev0 to dev1 or alternate the source and target journal devices?

The first iteration persists dev2 in dev0's superblock. Every subsequent -i iteration requests dev2 again, so it no longer exercises a dynamic journal-device change.

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
#39 lore raw

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Quoted 15 lines · On Tue, Aug 04, 2026 at 04:17:51AM +0000, [email protected]…

Hi Wei,

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 126

Quoted 9 lines · Wei Gao

fsconfig04: Check FSCONFIG_SET_PATH

testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +7 -0
+	TEST(fsconfig(fd, FSCONFIG_SET_PATH, "journal_path", dev2, 0));
+	if (TST_RET == -1) {
+		if (TST_ERR == EOPNOTSUPP)
+			tst_brk(TCONF, "fsconfig(FSCONFIG_SET_PATH) not supported");
+		else
+			tst_brk(TFAIL | TTERRNO, "fsconfig(FSCONFIG_SET_PATH) failed");
+	}

Could this test be gated with .min_kver = "7.2"?

Quoted 4 lines

Before Linux 7.2, ext4 declared journal_path as a string parameter, so FSCONFIG_SET_PATH is rejected with EINVAL rather than EOPNOTSUPP. Since fsopen_supported_by_kernel() only gates fsopen at Linux 5.2, those kernels reach the else branch and report TFAIL instead of TCONF.

If fsconfig parameter is correct, return EINVAL should be an kernel bug. Current logic is correct.
I guess AI mix wtih some old code with new API. But how to fix AI's rule is a question.

Quoted 38 lines

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 141

Quoted 5 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +4 -0
+	SAFE_SSCANF(dev2, "/dev/%s", loop_name);
+
+	snprintf(path, sizeof(path), "/sys/block/%s/dev", loop_name);
+	SAFE_FILE_SCANF(path, "%u:%u", &major, &minor);

Could the device number be obtained from stat(dev2).st_rdev instead?

tst_find_free_loopdev() also supports /dev/loop/N and /dev/block/loopN. Those paths produce loop/N or block/loopN here, causing the test to read a nonexistent sysfs path and terminate with TBROK.

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 120

Quoted 7 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +7 -0
+	SAFE_MKFS(dev0, tst_device->fs_type, mkfs_opts_set_journal_dev1, NULL);
+}
+
+static void run(void)
+{
+	...
+	TEST(fsconfig(fd, FSCONFIG_SET_PATH, "journal_path", dev2, 0));

Could each iteration reset dev0 to dev1 or alternate the source and target journal devices?

The first iteration persists dev2 in dev0's superblock. Every subsequent -i iteration requests dev2 again, so it no longer exercises a dynamic journal-device change.

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
#40 lore raw

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

Quoted 10 lines
Quoted 10 lines

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 126

Quoted 7 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +7 -0
+	TEST(fsconfig(fd, FSCONFIG_SET_PATH, "journal_path", dev2, 0));
+	if (TST_RET == -1) {
+		if (TST_ERR == EOPNOTSUPP)
+			tst_brk(TCONF, "fsconfig(FSCONFIG_SET_PATH) not supported");
+		else
+			tst_brk(TFAIL | TTERRNO, "fsconfig(FSCONFIG_SET_PATH) failed");
+	}

Could this test be gated with .min_kver = "7.2"?

Quoted 8 lines
Quoted 4 lines

Before Linux 7.2, ext4 declared journal_path as a string parameter, so FSCONFIG_SET_PATH is rejected with EINVAL rather than EOPNOTSUPP. Since fsopen_supported_by_kernel() only gates fsopen at Linux 5.2, those kernels reach the else branch and report TFAIL instead of TCONF.

If fsconfig parameter is correct, return EINVAL should be an kernel bug. Current logic is correct.
I guess AI mix wtih some old code with new API. But how to fix AI's rule is a question.

yeah, agent is wrong.

Quoted 7 lines
Quoted 7 lines

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 141

Quoted 5 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +4 -0
+	SAFE_SSCANF(dev2, "/dev/%s", loop_name);
+
+	snprintf(path, sizeof(path), "/sys/block/%s/dev", loop_name);
+	SAFE_FILE_SCANF(path, "%u:%u", &major, &minor);

Could the device number be obtained from stat(dev2).st_rdev instead?

what about this?

Quoted 16 lines
Quoted 16 lines

tst_find_free_loopdev() also supports /dev/loop/N and /dev/block/loopN. Those paths produce loop/N or block/loopN here, causing the test to read a nonexistent sysfs path and terminate with TBROK.

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 120

Quoted 7 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +7 -0
+	SAFE_MKFS(dev0, tst_device->fs_type, mkfs_opts_set_journal_dev1, NULL);
+}
+
+static void run(void)
+{
+	...
+	TEST(fsconfig(fd, FSCONFIG_SET_PATH, "journal_path", dev2, 0));

Could each iteration reset dev0 to dev1 or alternate the source and target journal devices?

Quoted 3 lines
Quoted 3 lines

The first iteration persists dev2 in dev0's superblock. Every subsequent -i iteration requests dev2 again, so it no longer exercises a dynamic journal-device change.

and this?

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v12 1/1
#41 lore raw

Re: [LTP] [PATCH v12] fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

Hi Wei,

Quoted 5 lines

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

LGTM, thanks!

...

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 136

Quoted 5 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +5 -0
+	char loop_name[NAME_MAX];
+	char path[PATH_MAX + 32];
+	char device_str[NAME_MAX];
+	unsigned int major, minor, device_num;
+	unsigned int found = 0;

very nit: I'd use bool for found (but of course it can stay as int).

Quoted 26 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +26 -0
+
+	SAFE_SSCANF(dev2, "/dev/%s", loop_name);
+
+	snprintf(path, sizeof(path), "/sys/block/%s/dev", loop_name);
+	SAFE_FILE_SCANF(path, "%u:%u", &major, &minor);
+	device_num = (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12);
+	snprintf(device_str, sizeof(device_str), "0x%04x", device_num);
+
+	char line[PATH_MAX];
+	FILE *tune2fs;
+
+	snprintf(path, sizeof(path), "tune2fs -l %s 2>&1", dev0);
+	tune2fs = SAFE_POPEN(path, "r");
+
+	while (fgets(line, PATH_MAX, tune2fs)) {
+		if (*line && strstr(line, "Journal device:") && strstr(line, device_str)) {
+			found = 1;
+			break;
+		}
+	}
+
+	if (found == 1)
+		tst_res(TPASS, "Device found in journal");
+	else
+		tst_res(TFAIL, "Device not found in journal");
+

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 172

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +10 -0
+	pclose(tune2fs);
+	SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_tmpdir = 1,

.needs_tmpdir is probably useless (run: 'cd doc/ && make clean && make' to see the errors) => I can delete it before merge.

Kind regards,
Petr

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

PATCH v13 1/1 fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
v12-v13:
- Uses bool found with standard false/true logic.
- Resolves device node numbers portably using standard SAFE_STAT and major/minor macros on st_rdev.
- Fixes dangling stack pointer bugs across loop runs.
- Moves formatting of all loop devices into run() to guarantee full test idempotency.
- Removes redundant .needs_tmpdir = 1.

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 174 ++++++++++++++++++
 3 files changed, 176 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index 65fb4d1ce..13bb59cde 100644
@@ -437,6 +437,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +174 -0

174 lines not on this page · raw message

Signature · 5 lines
2.54.0


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

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

Quoted 1 line · Wei Gao

fsconfig04: Check FSCONFIG_SET_PATH

Verdict - Reviewed

---
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
#44 lore raw

Re: [LTP] [PATCH v13] fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

Hi Wei,

Quoted 1 line

+#define MNTPOINT "mntpoint"

this is never used

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 50

Quoted 5 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +5 -0
+#define LOOP_DEV_SIZE 10
+#define UUID "d73c9e5e-97e4-4a9c-b17e-75a931b02660"
+
+static int fd = -1;
+static char dev0[PATH_MAX];

the static dev0 buffer and strcpy() are redundant since tst_device->dev is already available

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 58

Quoted 8 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +8 -0
+static char dev1[PATH_MAX];
+static char dev2[PATH_MAX];
+
+static char device_option_dev1[PATH_MAX + 16];
+static char device_option_dev2[PATH_MAX + 16];
+static const char *const mkfs_opts_journal_dev1[] = {"-F", "-J", device_option_dev1, NULL};
+static const char *const mkfs_opts_journal_dev2[] = {"-F", "-J", device_option_dev2, NULL};
+static const char *const mkfs_opts_set_UUID[] = {"-F", "-U", UUID, "-O", "journal_dev", NULL};

these static buffers and option arrays can be replaced with a small helper function that formats -J device=%s locally, eliminating global mutable state and setup() string formatting.

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 152

Quoted 4 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +4 -0
+	if (found)
+		tst_res(TPASS, "Device found in journal");
+	else
+		tst_res(TFAIL, "Device not found in journal");

the manual if/else result reporting can also be simplified with TST_EXP_EXPR(found, ...)

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 155

Quoted 3 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +3 -0
+
+	pclose(tune2fs);
+	SAFE_CLOSE(fd);

SAFE_CLOSE(fd) can be called immediately after FSCONFIG_CMD_CREATE, freeing the kernel filesystem context before invoking tune2fs

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

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

Re: [LTP] [PATCH v13] fsconfig04: Check FSCONFIG_SET_PATH

Quoted 5 lines · Andrea Cervesato

Hi Wei,

Quoted 1 line

+#define MNTPOINT "mntpoint"

this is never used

This used in following code:

static struct tst_test test = {
.test_all = run,
.setup = setup,
.cleanup = cleanup,
.needs_root = 1,
.needs_device = 1,
.mntpoint = MNTPOINT, <<<<<<<

Quoted 42 lines

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 50

Quoted 6 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +5 -0
+#define LOOP_DEV_SIZE 10
+#define UUID "d73c9e5e-97e4-4a9c-b17e-75a931b02660"
+
+static int fd = -1;
+static char dev0[PATH_MAX];

the static dev0 buffer and strcpy() are redundant since tst_device->dev is already available

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 58

Quoted 8 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +8 -0
+static char dev1[PATH_MAX];
+static char dev2[PATH_MAX];
+
+static char device_option_dev1[PATH_MAX + 16];
+static char device_option_dev2[PATH_MAX + 16];
+static const char *const mkfs_opts_journal_dev1[] = {"-F", "-J", device_option_dev1, NULL};
+static const char *const mkfs_opts_journal_dev2[] = {"-F", "-J", device_option_dev2, NULL};
+static const char *const mkfs_opts_set_UUID[] = {"-F", "-U", UUID, "-O", "journal_dev", NULL};

these static buffers and option arrays can be replaced with a small helper function that formats -J device=%s locally, eliminating global mutable state and setup() string formatting.

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 152

Quoted 4 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +4 -0
+	if (found)
+		tst_res(TPASS, "Device found in journal");
+	else
+		tst_res(TFAIL, "Device not found in journal");

the manual if/else result reporting can also be simplified with TST_EXP_EXPR(found, ...)

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 155

Quoted 3 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +3 -0
+
+	pclose(tune2fs);
+	SAFE_CLOSE(fd);

SAFE_CLOSE(fd) can be called immediately after FSCONFIG_CMD_CREATE, freeing the kernel filesystem context before invoking tune2fs

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

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

PATCH v14 1/1 fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
v13->v14:
- Eliminated redundant static 'dev0' buffer and strcpy() by directly using 'tst_device->dev' from the framework.
- Removed global mutable option-formatting buffers and arrays, replacing them with a local stack-based helper function 'format_journal_device()'.
- Replaced manual if-else results reporting with the standard LTP 'TST_EXP_EXPR()' macro.
- Relocated 'SAFE_CLOSE(fd)' to execute immediately after 'FSCONFIG_CMD_CREATE' succeeds to free the kernel filesystem context early.

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 171 ++++++++++++++++++
 3 files changed, 173 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index 65fb4d1ce..13bb59cde 100644
@@ -437,6 +437,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +171 -0

171 lines not on this page · raw message

Signature · 5 lines
2.55.0


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

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

Quoted 3 lines · Wei Gao via ltp

fsconfig04: Check FSCONFIG_SET_PATH

+#define MNTPOINT "mntpoint"

The test does not mount a filesystem. Remove MNTPOINT and .mntpoint.

Quoted 7 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +7 -0
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_device = 1,
+	.mntpoint = MNTPOINT,

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 171

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +10 -0
+	.needs_cmds = (struct tst_cmd []) {
+		{.cmd = "tune2fs"},
+		{}
+	},
+	.filesystems = (struct tst_fs []) {
+		{.type = "ext3"},
+		{.type = "ext4"},
+		{}
+	},
+};

Add .needs_tmpdir = 1 since setup() creates backing files for the loop devices via tst_prealloc_file(). Also remove .mntpoint = MNTPOINT.

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
#48 lore raw

PATCH v15 1/1 fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
v14->v15:
- Remove .mntpoint and MNTPOINT

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 169 ++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index 65fb4d1ce..13bb59cde 100644
@@ -437,6 +437,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +169 -0

169 lines not on this page · raw message

Signature · 5 lines
2.55.0


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

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 112

Quoted 3 lines · Wei Gao

fsconfig04: Check FSCONFIG_SET_PATH

testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +1 -0
+	TEST(fsconfig(fd, FSCONFIG_SET_PATH, "journal_path", dev2, 0));

Pass AT_FDCWD instead of 0 for the aux argument, as aux represents the dirfd parameter for openat-style path resolution.

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
#50 lore raw

PATCH v16 1/1 fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
v15->v16:
- Pass AT_FDCWD instead of 0 for the aux argument of fsconfig

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 169 ++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index 65fb4d1ce..13bb59cde 100644
@@ -437,6 +437,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +169 -0

169 lines not on this page · raw message

Signature · 5 lines
2.55.0


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

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

Quoted 8 lines · Wei Gao

fsconfig04: Check FSCONFIG_SET_PATH

testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +6 -0
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_device = 1,

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 169

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +10 -0
+	.needs_cmds = (struct tst_cmd []) {
+		{.cmd = "tune2fs"},
+		{}
+	},
+	.filesystems = (struct tst_fs []) {
+		{.type = "ext3"},
+		{.type = "ext4"},
+		{}
+	},
+};

The test creates backing files "dev1_file" and "dev2_file" in setup(), but .needs_tmpdir = 1 is missing. Set .needs_tmpdir = 1 so these files are created in a temporary directory and cleaned up properly.

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
#52 lore raw

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Quoted 26 lines · On Wed, Sep 16, 2026 at 01:28:35PM +0000, [email protected]…

Hi Wei,

Quoted 8 lines · Wei Gao

fsconfig04: Check FSCONFIG_SET_PATH

testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +6 -0
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_device = 1,

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 169

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +10 -0
+	.needs_cmds = (struct tst_cmd []) {
+		{.cmd = "tune2fs"},
+		{}
+	},
+	.filesystems = (struct tst_fs []) {
+		{.type = "ext3"},
+		{.type = "ext4"},
+		{}
+	},
+};

The test creates backing files "dev1_file" and "dev2_file" in setup(), but .needs_tmpdir = 1 is missing. Set .needs_tmpdir = 1 so these files are created in a temporary directory and cleaned up properly.

Quoted 1 line

Verdict - Needs revision

.needs_tmpdir = 1 isn't required here because setting .needs_device = 1 already creates the temporary directory automatically in the LTP framework.

Quoted 10 lines

---
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
#53 lore raw

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

In reply to [email protected]

...

Quoted 3 lines

The test creates backing files "dev1_file" and "dev2_file" in setup(), but .needs_tmpdir = 1 is missing. Set .needs_tmpdir = 1 so these files are created in a temporary directory and cleaned up properly.

False positive => should be fixed
https://github.com/linux-test-project/ltp-agent/issues/10

Kind regards,
Petr

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

Re: [LTP] [PATCH v16] fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp
Quoted 218 lines · Wei Gao

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
v15->v16:
- Pass AT_FDCWD instead of 0 for the aux argument of fsconfig

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 169 ++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index 65fb4d1ce..13bb59cde 100644
@@ -437,6 +437,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +169 -0
new file mode 100644
index 000000000..edbdc55c6
@@ -0,0 +1,169 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2026 Wei Gao <[email protected]>
+ */
+
+/*\
+ * This test aims to validate :manpage:`fsconfig(2)` with the
+ * ``FSCONFIG_SET_PATH`` operation in dynamically altering the external
+ * journal device of an ext3 or ext4 filesystem.
+ *
+ * Root privileges are required because the test creates and formats loop
+ * devices, and configures filesystems.
+ *
+ * [Algorithm]
+ *
+ * - Acquire three loop devices (``tst_device->dev`` from framework, ``dev1``, ``dev2``).
+ * - Format ``dev1`` and ``dev2`` as external journal devices with the same UUID
+ *   (``-O journal_dev -U <uuid>``).
+ * - Format ``tst_device->dev`` three times to cycle journal associations:
+ *   ``dev1`` -> ``dev2`` -> ``dev1``, so both journal superblocks are consistent.
+ * - Open ``tst_device->dev`` via :manpage:`fsopen(2)` and set the source and journal_path using
+ *   :manpage:`fsconfig(2)` (``FSCONFIG_SET_STRING``) and
+ *   :manpage:`fsconfig(2)` (``FSCONFIG_SET_PATH``).
+ * - Apply ``FSCONFIG_CMD_CREATE`` and verify with ``tune2fs`` that ``tst_device->dev``'s
+ *   journal device is now ``dev2``.
+ *
+ * Implementation notes:
+ *
+ * - To avoid ``journal UUID does not match`` error when switching external
+ *   journal device, we have to assign the same UUID to ``dev1``/``dev2``.
+ * - Before the :manpage:`fsconfig(2)` test, we have to format ``tst_device->dev`` associating to
+ *   ``dev1`` -> ``dev2`` -> ``dev1``. This ensures that both ``dev1``/``dev2`` superblocks contain
+ *   correct content. Otherwise, you will encounter errors such as
+ *   ``EXT4-fs (loop0): External journal has more than one user (unsupported)``
+ *   when switching the external journal device using :manpage:`fsconfig(2)`.
+ */
+
+#include <stdbool.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#include "tst_test.h"
+#include "tst_safe_stdio.h"
+#include "lapi/fsmount.h"
+
+#define LOOP_DEV_SIZE 10
+#define UUID "d73c9e5e-97e4-4a9c-b17e-75a931b02660"
+
+static int fd = -1;
+static char dev1[PATH_MAX];
+static char dev2[PATH_MAX];
+
+static const char *const mkfs_opts_set_UUID[] = {"-F", "-U", UUID, "-O", "journal_dev", NULL};
+
+static void cleanup(void)
+{
+	if (fd != -1)
+		SAFE_CLOSE(fd);
+
+	if (dev1[0])
+		tst_detach_device(dev1);
+
+	if (dev2[0])
+		tst_detach_device(dev2);
+}
+
+static void create_and_attach_loopdev(const char *filename, char *dev_path, size_t dev_path_len)
+{
+	if (tst_prealloc_file(filename, 1024 * 1024, LOOP_DEV_SIZE))
+		tst_brk(TBROK, "Failed to create %s", filename);
+
+	if (tst_find_free_loopdev(dev_path, dev_path_len) == -1)
+		tst_brk(TBROK, "No free loop device found for %s", filename);
+
+	if (tst_attach_device(dev_path, filename))
+		tst_brk(TBROK, "Failed to attach %s to %s", filename, dev_path);
+}
+
+static void format_journal_device(const char *dev, const char *journal)
+{
+	char journal_opt[PATH_MAX + 16];
+	const char *const opts[] = {"-F", "-J", journal_opt, NULL};
+
+	snprintf(journal_opt, sizeof(journal_opt), "device=%s", journal);
+	SAFE_MKFS(dev, tst_device->fs_type, opts, NULL);
+}
+
+static void setup(void)
+{
+	fsopen_supported_by_kernel();
+
+	create_and_attach_loopdev("dev1_file", dev1, sizeof(dev1));
+	create_and_attach_loopdev("dev2_file", dev2, sizeof(dev2));
+}
+
+static void run(void)
+{
+	/* Reset dev1, dev2 and tst_device->dev superblocks before each test run iteration */
+	SAFE_MKFS(dev1, tst_device->fs_type, mkfs_opts_set_UUID, NULL);
+	SAFE_MKFS(dev2, tst_device->fs_type, mkfs_opts_set_UUID, NULL);
+	format_journal_device(tst_device->dev, dev1);
+	format_journal_device(tst_device->dev, dev2);
+	format_journal_device(tst_device->dev, dev1);
+
+	TEST(fd = fsopen(tst_device->fs_type, 0));
+	if (fd == -1)
+		tst_brk(TBROK | TTERRNO, "fsopen() failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0));
+	if (TST_RET == -1)
+		tst_brk(TBROK | TTERRNO, "fsconfig(FSCONFIG_SET_STRING) failed");
+
+	TEST(fsconfig(fd, FSCONFIG_SET_PATH, "journal_path", dev2, 0));
+	if (TST_RET == -1) {
+		if (TST_ERR == EOPNOTSUPP)
+			tst_brk(TCONF, "fsconfig(FSCONFIG_SET_PATH) not supported");
+		else
+			tst_brk(TFAIL | TTERRNO, "fsconfig(FSCONFIG_SET_PATH) failed");
+	}
+
+	TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0));
+	if (TST_RET == -1)
+		tst_brk(TFAIL | TTERRNO, "fsconfig(FSCONFIG_CMD_CREATE) failed");
+
+	SAFE_CLOSE(fd);
+
+	char path[PATH_MAX + 32];
+	char device_str[NAME_MAX];
+	bool found = false;
+	struct stat st;
+
+	SAFE_STAT(dev2, &st);
+	unsigned int device_num = (minor(st.st_rdev) & 0xff) | (major(st.st_rdev) << 8) |
+				  ((minor(st.st_rdev) & ~0xff) << 12);
+	snprintf(device_str, sizeof(device_str), "0x%04x", device_num);
+
+	char line[PATH_MAX];
+	FILE *tune2fs;
+
+	snprintf(path, sizeof(path), "tune2fs -l %s 2>&1", tst_device->dev);
+	tune2fs = SAFE_POPEN(path, "r");
+
+	while (fgets(line, PATH_MAX, tune2fs)) {
+		if (*line && strstr(line, "Journal device:") && strstr(line, device_str)) {
+			found = true;
+			break;
+		}
+	}
+
+	TST_EXP_EXPR(found, "Device found in journal");
+
+	pclose(tune2fs);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_device = 1,
+	.needs_cmds = (struct tst_cmd []) {
+		{.cmd = "tune2fs"},
+		{}
+	},
+	.filesystems = (struct tst_fs []) {
+		{.type = "ext3"},
+		{.type = "ext4"},
+		{}
+	},
+};
Signature · 1 line
2.55.0

Sorry please SKIP above one. I will resent patch v16, this is not correct one with s/0/AT_FDCWD fix.

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

PATCH v16 1/1 fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
v15->v16:
- Pass AT_FDCWD instead of 0 for the aux argument of fsconfig

 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 169 ++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index 65fb4d1ce..13bb59cde 100644
@@ -437,6 +437,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +169 -0

169 lines not on this page · raw message

Signature · 5 lines
2.55.0


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

PATCH v17 1/1 fsconfig04: Check FSCONFIG_SET_PATH

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 169 ++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index 2bdb4a9a2..1903f1ac6 100644
@@ -452,6 +452,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +169 -0

169 lines not on this page · raw message

Signature · 5 lines
2.55.0


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

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Hi Wei,

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 63

Quoted 7 lines · Wei Gao via ltp

fsconfig04: Check FSCONFIG_SET_PATH

testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +5 -0
+	if (dev1[0])
+		tst_detach_device(dev1);
+
+	if (dev2[0])
+		tst_detach_device(dev2);

High severity: If another process claims a loop device between tst_find_free_loopdev() and LOOP_SET_FD, attachment fails with EBUSY but leaves dev1/dev2 populated, so tst_brk() runs this cleanup against the other process's device. Track attachment ownership, including partial-attachment failures, and detach only associations created by this test.

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 140

Quoted 2 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +2 -0
+	snprintf(path, sizeof(path), "tune2fs -l %s 2>&1", tst_device->dev);
+	tune2fs = SAFE_POPEN(path, "r");

Medium severity: LTP_DEV can name a valid device alias containing spaces; the preceding calls preserve that path, but popen() splits it into multiple arguments and tune2fs exits with usage, producing a false TFAIL. Use tst_cmd() with an argv array and captured output instead of a shell.

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
#58 lore raw

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

Quoted 25 lines · On Wed, Oct 21, 2026 at 01:34:46PM +0000, [email protected]…

Hi Wei,

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 63

Quoted 7 lines · Wei Gao via ltp

fsconfig04: Check FSCONFIG_SET_PATH

testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +5 -0
+	if (dev1[0])
+		tst_detach_device(dev1);
+
+	if (dev2[0])
+		tst_detach_device(dev2);

High severity: If another process claims a loop device between tst_find_free_loopdev() and LOOP_SET_FD, attachment fails with EBUSY but leaves dev1/dev2 populated, so tst_brk() runs this cleanup against the other process's device. Track attachment ownership, including partial-attachment failures, and detach only associations created by this test.

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 140

Quoted 2 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +2 -0
+	snprintf(path, sizeof(path), "tune2fs -l %s 2>&1", tst_device->dev);
+	tune2fs = SAFE_POPEN(path, "r");

Medium severity: LTP_DEV can name a valid device alias containing spaces; the preceding calls preserve that path, but popen() splits it into multiple arguments and tune2fs exits with usage, producing a false TFAIL. Use tst_cmd() with an argv array and captured output instead of a shell.

Quoted 1 line

Verdict - Needs revision

Above comments looks like over-engineering to me. If anyone think change is needed, I can send a follow-up patch.

Quoted 10 lines

---
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
#59 lore raw

Re: [LTP] fsconfig04: Check FSCONFIG_SET_PATH

In reply to [email protected]

Hi!

Quoted 11 lines

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 63

Quoted 5 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +5 -0
+	if (dev1[0])
+		tst_detach_device(dev1);
+
+	if (dev2[0])
+		tst_detach_device(dev2);

High severity: If another process claims a loop device between tst_find_free_loopdev() and LOOP_SET_FD, attachment fails with EBUSY but leaves dev1/dev2 populated, so tst_brk() runs this cleanup against the other process's device. Track attachment ownership, including partial-attachment failures, and detach only associations created by this test.

This should be probably solved in the test library, we would need a tst_attach_loopdev() function that would retry the lookup for a free device on EBUSY.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH v17] fsconfig04: Check FSCONFIG_SET_PATH

In reply to Wei Gao via ltp
Quoted 135 lines · Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 169 ++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index 2bdb4a9a2..1903f1ac6 100644
@@ -452,6 +452,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +92 -0
new file mode 100644
index 000000000..bd649717e
@@ -0,0 +1,169 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2026 Wei Gao <[email protected]>
+ */
+
+/*\
+ * This test aims to validate :manpage:`fsconfig(2)` with the
+ * ``FSCONFIG_SET_PATH`` operation in dynamically altering the external
+ * journal device of an ext3 or ext4 filesystem.
+ *
+ * Root privileges are required because the test creates and formats loop
+ * devices, and configures filesystems.
+ *
+ * [Algorithm]
+ *
+ * - Acquire three loop devices (``tst_device->dev`` from framework, ``dev1``, ``dev2``).
+ * - Format ``dev1`` and ``dev2`` as external journal devices with the same UUID
+ *   (``-O journal_dev -U <uuid>``).
+ * - Format ``tst_device->dev`` three times to cycle journal associations:
+ *   ``dev1`` -> ``dev2`` -> ``dev1``, so both journal superblocks are consistent.
+ * - Open ``tst_device->dev`` via :manpage:`fsopen(2)` and set the source and journal_path using
+ *   :manpage:`fsconfig(2)` (``FSCONFIG_SET_STRING``) and
+ *   :manpage:`fsconfig(2)` (``FSCONFIG_SET_PATH``).
+ * - Apply ``FSCONFIG_CMD_CREATE`` and verify with ``tune2fs`` that ``tst_device->dev``'s
+ *   journal device is now ``dev2``.
+ *
+ * Implementation notes:
+ *
+ * - To avoid ``journal UUID does not match`` error when switching external
+ *   journal device, we have to assign the same UUID to ``dev1``/``dev2``.
+ * - Before the :manpage:`fsconfig(2)` test, we have to format ``tst_device->dev`` associating to
+ *   ``dev1`` -> ``dev2`` -> ``dev1``. This ensures that both ``dev1``/``dev2`` superblocks contain
+ *   correct content. Otherwise, you will encounter errors such as
+ *   ``EXT4-fs (loop0): External journal has more than one user (unsupported)``
+ *   when switching the external journal device using :manpage:`fsconfig(2)`.
+ */
+
+#include <stdbool.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#include "tst_test.h"
+#include "tst_safe_stdio.h"
+#include "lapi/fsmount.h"
+
+#define LOOP_DEV_SIZE 10
+#define UUID "d73c9e5e-97e4-4a9c-b17e-75a931b02660"
+
+static int fd = -1;
+static char dev1[PATH_MAX];
+static char dev2[PATH_MAX];
+
+static const char *const mkfs_opts_set_UUID[] = {"-F", "-U", UUID, "-O", "journal_dev", NULL};
+
+static void cleanup(void)
+{
+	if (fd != -1)
+		SAFE_CLOSE(fd);
+
+	if (dev1[0])
+		tst_detach_device(dev1);
+
+	if (dev2[0])
+		tst_detach_device(dev2);
+}
+
+static void create_and_attach_loopdev(const char *filename, char *dev_path, size_t dev_path_len)
+{
+	if (tst_prealloc_file(filename, 1024 * 1024, LOOP_DEV_SIZE))
+		tst_brk(TBROK, "Failed to create %s", filename);
+
+	if (tst_find_free_loopdev(dev_path, dev_path_len) == -1)
+		tst_brk(TBROK, "No free loop device found for %s", filename);
+
+	if (tst_attach_device(dev_path, filename))
+		tst_brk(TBROK, "Failed to attach %s to %s", filename, dev_path);
+}
+
+static void format_journal_device(const char *dev, const char *journal)
+{
+	char journal_opt[PATH_MAX + 16];
+	const char *const opts[] = {"-F", "-J", journal_opt, NULL};
+
+	snprintf(journal_opt, sizeof(journal_opt), "device=%s", journal);
+	SAFE_MKFS(dev, tst_device->fs_type, opts, NULL);
+}
+
+static void setup(void)
+{
+	fsopen_supported_by_kernel();
+
+	create_and_attach_loopdev("dev1_file", dev1, sizeof(dev1));
+	create_and_attach_loopdev("dev2_file", dev2, sizeof(dev2));

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 102

Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +10 -0
+}
+
+static void run(void)
+{
+	/* Reset dev1, dev2 and tst_device->dev superblocks before each test run iteration */
+	SAFE_MKFS(dev1, tst_device->fs_type, mkfs_opts_set_UUID, NULL);
+	SAFE_MKFS(dev2, tst_device->fs_type, mkfs_opts_set_UUID, NULL);
+	format_journal_device(tst_device->dev, dev1);
+	format_journal_device(tst_device->dev, dev2);
+	format_journal_device(tst_device->dev, dev1);

I do not get why we have the dev1 and what errors are we working around here. The dev1 is not used for anything, just formatted again and again.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH v17] fsconfig04: Check FSCONFIG_SET_PATH

Quoted 82 lines · Cyril Hrubis
Quoted 81 lines · Wei Gao via ltp

The fsconfig01.c does not test if FSCONFIG_SET_PATH has any effect; most of the calls there just set a dummy "sync" parameter. This test case aims to verify if the FSCONFIG_SET_PATH operation can be used to dynamically change the external journal device of an ext3 or ext4 filesystem.

---
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/fsconfig/.gitignore |   1 +
 .../kernel/syscalls/fsconfig/fsconfig04.c     | 169 ++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig04.c
runtest/syscalls +1 -0
index 2bdb4a9a2..1903f1ac6 100644
@@ -452,6 +452,7 @@ fremovexattr02 fremovexattr02
 fsconfig01 fsconfig01
 fsconfig02 fsconfig02
 fsconfig03 fsconfig03
+fsconfig04 fsconfig04
 
 fsmount01 fsmount01
 fsmount02 fsmount02
testcases/kernel/syscalls/fsconfig/.gitignore +1 -0
index cfedae5f7..bd3754c34 100644
@@ -1,3 +1,4 @@
 /fsconfig01
 /fsconfig02
 /fsconfig03
+/fsconfig04
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +38 -0
new file mode 100644
index 000000000..bd649717e
@@ -0,0 +1,169 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2026 Wei Gao <[email protected]>
+ */
+
+/*\
+ * This test aims to validate :manpage:`fsconfig(2)` with the
+ * ``FSCONFIG_SET_PATH`` operation in dynamically altering the external
+ * journal device of an ext3 or ext4 filesystem.
+ *
+ * Root privileges are required because the test creates and formats loop
+ * devices, and configures filesystems.
+ *
+ * [Algorithm]
+ *
+ * - Acquire three loop devices (``tst_device->dev`` from framework, ``dev1``, ``dev2``).
+ * - Format ``dev1`` and ``dev2`` as external journal devices with the same UUID
+ *   (``-O journal_dev -U <uuid>``).
+ * - Format ``tst_device->dev`` three times to cycle journal associations:
+ *   ``dev1`` -> ``dev2`` -> ``dev1``, so both journal superblocks are consistent.
+ * - Open ``tst_device->dev`` via :manpage:`fsopen(2)` and set the source and journal_path using
+ *   :manpage:`fsconfig(2)` (``FSCONFIG_SET_STRING``) and
+ *   :manpage:`fsconfig(2)` (``FSCONFIG_SET_PATH``).
+ * - Apply ``FSCONFIG_CMD_CREATE`` and verify with ``tune2fs`` that ``tst_device->dev``'s
+ *   journal device is now ``dev2``.
+ *
+ * Implementation notes:
+ *
+ * - To avoid ``journal UUID does not match`` error when switching external
+ *   journal device, we have to assign the same UUID to ``dev1``/``dev2``.
+ * - Before the :manpage:`fsconfig(2)` test, we have to format ``tst_device->dev`` associating to
+ *   ``dev1`` -> ``dev2`` -> ``dev1``. This ensures that both ``dev1``/``dev2`` superblocks contain
+ *   correct content. Otherwise, you will encounter errors such as
+ *   ``EXT4-fs (loop0): External journal has more than one user (unsupported)``
+ *   when switching the external journal device using :manpage:`fsconfig(2)`.
+ */
+
+

...

Quoted 11 lines

testcases/kernel/syscalls/fsconfig/fsconfig04.c line 102

Quoted 8 lines
testcases/kernel/syscalls/fsconfig/fsconfig04.c new file +8 -0
+static void run(void)
+{
+	/* Reset dev1, dev2 and tst_device->dev superblocks before each test run iteration */
+	SAFE_MKFS(dev1, tst_device->fs_type, mkfs_opts_set_UUID, NULL);
+	SAFE_MKFS(dev2, tst_device->fs_type, mkfs_opts_set_UUID, NULL);
+	format_journal_device(tst_device->dev, dev1);
+	format_journal_device(tst_device->dev, dev2);
+	format_journal_device(tst_device->dev, dev1);

I do not get why we have the dev1 and what errors are we working around here. The dev1 is not used for anything, just formatted again and again.

dev1 serves as the initial baseline journal, cycling through dev1 -> dev2 -> dev1 leaves tst_device->dev pointing to dev1 by default while ensuring both dev1 and dev2 superblocks are properly initialized so fsconfig() can successfully perform the dynamic swap from dev1 to dev2.

Cycling format_journal_device() three times pre-conditions the disk state:
- Pass 1 (dev1): Registers tst_device->dev's UUID into dev1's superblock.
- Pass 2 (dev2): Registers tst_device->dev's UUID into dev2's superblock.
- Pass 3 (dev1): Resets tst_device->dev's default disk state back to dev1.
This leaves both dev1 and dev2 superblocks populated with matching, valid UUID entries for tst_device->dev.

Quoted 5 lines
Signature · 3 lines
-- 
Cyril Hrubis
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp