* [LTP] [PATCH v1] fsconfig04.c: Check FSCONFIG_SET_PATH
@ 2025-05-16 15:10 Wei Gao via ltp
2025-05-22 20:56 ` Petr Vorel
2025-05-26 14:35 ` [LTP] [PATCH v2] " Wei Gao via ltp
0 siblings, 2 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2025-05-16 15:10 UTC (permalink / raw)
To: 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.
Signed-off-by: Wei Gao <wegao@suse.com>
---
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
diff --git a/runtest/syscalls b/runtest/syscalls
index e369536ea..658ab24c4 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -410,6 +410,7 @@ fremovexattr02 fremovexattr02
fsconfig01 fsconfig01
fsconfig02 fsconfig02
fsconfig03 fsconfig03
+fsconfig04 fsconfig04
fsmount01 fsmount01
fsmount02 fsmount02
diff --git a/testcases/kernel/syscalls/fsconfig/.gitignore b/testcases/kernel/syscalls/fsconfig/.gitignore
index cfedae5f7..bd3754c34 100644
--- a/testcases/kernel/syscalls/fsconfig/.gitignore
+++ b/testcases/kernel/syscalls/fsconfig/.gitignore
@@ -1,3 +1,4 @@
/fsconfig01
/fsconfig02
/fsconfig03
+/fsconfig04
diff --git a/testcases/kernel/syscalls/fsconfig/fsconfig04.c b/testcases/kernel/syscalls/fsconfig/fsconfig04.c
new file mode 100644
index 000000000..119b8b175
--- /dev/null
+++ b/testcases/kernel/syscalls/fsconfig/fsconfig04.c
@@ -0,0 +1,169 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Wei Gao <wegao@suse.com>
+ *
+ * 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:
+ * - 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"
+
+#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);
+
+ 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");
+
+ 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);
+
+ 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];
+
+ 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");
+
+ 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");
+ else
+ tst_res(TFAIL, "Journal device set failed");
+
+ pclose(tune2fs);
+ SAFE_CLOSE(fd);
+}
+
+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},
+};
--
2.49.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v1] fsconfig04.c: Check FSCONFIG_SET_PATH
2025-05-16 15:10 [LTP] [PATCH v1] fsconfig04.c: Check FSCONFIG_SET_PATH Wei Gao via ltp
@ 2025-05-22 20:56 ` Petr Vorel
2025-05-26 14:29 ` Wei Gao via ltp
2025-05-26 14:35 ` [LTP] [PATCH v2] " Wei Gao via ltp
1 sibling, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2025-05-22 20:56 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
Hi Wei,
I'm sorry not a real review, just point out obvious API errors.
> Fixes: 1169
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.
...
> diff --git a/testcases/kernel/syscalls/fsconfig/fsconfig04.c b/testcases/kernel/syscalls/fsconfig/fsconfig04.c
> new file mode 100644
> index 000000000..119b8b175
> --- /dev/null
> +++ b/testcases/kernel/syscalls/fsconfig/fsconfig04.c
> @@ -0,0 +1,169 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2025 Wei Gao <wegao@suse.com>
> + *
This '*' should be '/*\' to be docparse.
> + * 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?
> + * - 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?
> +
> +#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);
> +
> + 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
> +
> + 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);
> +
> + 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?
> +
> + 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");
> +
> + 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" ?
> + else
> + tst_res(TFAIL, "Journal device set failed");
Maybe "Device not found in journal" ?
> +
> + pclose(tune2fs);
> + SAFE_CLOSE(fd);
> +}
> +
> +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
> +};
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v1] fsconfig04.c: Check FSCONFIG_SET_PATH
2025-05-26 14:29 ` Wei Gao via ltp
@ 2025-05-26 6:40 ` Petr Vorel
0 siblings, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2025-05-26 6:40 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
Hi Wei,
> On Thu, May 22, 2025 at 10:56:37PM +0200, Petr Vorel wrote:
> > Hi Wei,
> > I'm sorry not a real review, just point out obvious API errors.
> Thanks for pointing that out :)
> > > +#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.
> > > +
> > > +
> > > + .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
> > 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
> > Kind regards,
> > Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v2] fsconfig04.c: Check FSCONFIG_SET_PATH
2025-05-26 14:35 ` [LTP] [PATCH v2] " Wei Gao via ltp
@ 2025-05-26 9:54 ` Petr Vorel
2025-05-26 12:54 ` Cyril Hrubis
2025-05-26 14:38 ` [LTP] [PATCH v2] fsconfig04.c: Check FSCONFIG_SET_PATH Cyril Hrubis
2025-06-03 21:45 ` [LTP] [PATCH v3] " Wei Gao via ltp
2 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2025-05-26 9:54 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
Hi Wei,
> 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.
...
> diff --git a/testcases/kernel/syscalls/fsconfig/fsconfig04.c b/testcases/kernel/syscalls/fsconfig/fsconfig04.c
> new file mode 100644
> index 000000000..0df16f0ed
> --- /dev/null
> +++ b/testcases/kernel/syscalls/fsconfig/fsconfig04.c
> @@ -0,0 +1,163 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2025 Wei Gao <wegao@suse.com>
> + */
> +
> +/*\ 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.
...
> +
> +static void setup(void)
> +{
...
> + 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.
> +}
> +
> +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");
Using SAFE_SSCANF() is enough (it checks number of found items), please use it:
SAFE_SSCANF(dev2, "/dev/%s", loop_name);
> +
> + sprintf(path, "/sys/block/%s/dev", loop_name);
snprintf() is safer.
> + SAFE_FILE_SCANF(path, "%u:%u", &major, &minor);
> + device_num = (major << 8) | minor;
> + sprintf(device_str, "0x%04X", device_num);
And here as well.
> +
> + 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,
> + .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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v2] fsconfig04.c: Check FSCONFIG_SET_PATH
2025-05-26 9:54 ` Petr Vorel
@ 2025-05-26 12:54 ` Cyril Hrubis
2025-05-26 16:13 ` Petr Vorel
0 siblings, 1 reply; 18+ messages in thread
From: Cyril Hrubis @ 2025-05-26 12:54 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
> 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"},
{}
};
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v1] fsconfig04.c: Check FSCONFIG_SET_PATH
2025-05-22 20:56 ` Petr Vorel
@ 2025-05-26 14:29 ` Wei Gao via ltp
2025-05-26 6:40 ` Petr Vorel
0 siblings, 1 reply; 18+ messages in thread
From: Wei Gao via ltp @ 2025-05-26 14:29 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Thu, May 22, 2025 at 10:56:37PM +0200, Petr Vorel wrote:
> Hi Wei,
>
> I'm sorry not a real review, just point out obvious API errors.
Thanks for pointing that out :)
>
> > +#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
>
> > +
> > +
> > + .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
> 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.
>
> Kind regards,
> Petr
>
> > +};
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* [LTP] [PATCH v2] fsconfig04.c: Check FSCONFIG_SET_PATH
2025-05-16 15:10 [LTP] [PATCH v1] fsconfig04.c: Check FSCONFIG_SET_PATH Wei Gao via ltp
2025-05-22 20:56 ` Petr Vorel
@ 2025-05-26 14:35 ` Wei Gao via ltp
2025-05-26 9:54 ` Petr Vorel
` (2 more replies)
1 sibling, 3 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2025-05-26 14:35 UTC (permalink / raw)
To: 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.
Signed-off-by: Wei Gao <wegao@suse.com>
---
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
diff --git a/runtest/syscalls b/runtest/syscalls
index e369536ea..658ab24c4 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -410,6 +410,7 @@ fremovexattr02 fremovexattr02
fsconfig01 fsconfig01
fsconfig02 fsconfig02
fsconfig03 fsconfig03
+fsconfig04 fsconfig04
fsmount01 fsmount01
fsmount02 fsmount02
diff --git a/testcases/kernel/syscalls/fsconfig/.gitignore b/testcases/kernel/syscalls/fsconfig/.gitignore
index cfedae5f7..bd3754c34 100644
--- a/testcases/kernel/syscalls/fsconfig/.gitignore
+++ b/testcases/kernel/syscalls/fsconfig/.gitignore
@@ -1,3 +1,4 @@
/fsconfig01
/fsconfig02
/fsconfig03
+/fsconfig04
diff --git a/testcases/kernel/syscalls/fsconfig/fsconfig04.c b/testcases/kernel/syscalls/fsconfig/fsconfig04.c
new file mode 100644
index 000000000..0df16f0ed
--- /dev/null
+++ b/testcases/kernel/syscalls/fsconfig/fsconfig04.c
@@ -0,0 +1,163 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Wei Gao <wegao@suse.com>
+ */
+
+/*\ 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:
+ *
+ * - 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"
+
+#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);
+
+ TST_EXP_PASS_SILENT(tst_detach_device(dev1));
+ TST_EXP_PASS_SILENT(tst_detach_device(dev2));
+}
+
+static void setup(void)
+{
+ 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);
+
+ 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];
+
+ 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");
+
+ 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,
+ .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},
+};
--
2.49.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v2] fsconfig04.c: Check FSCONFIG_SET_PATH
2025-05-26 14:35 ` [LTP] [PATCH v2] " Wei Gao via ltp
2025-05-26 9:54 ` Petr Vorel
@ 2025-05-26 14:38 ` Cyril Hrubis
2025-06-03 21:45 ` [LTP] [PATCH v3] " Wei Gao via ltp
2 siblings, 0 replies; 18+ messages in thread
From: Cyril Hrubis @ 2025-05-26 14:38 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
Hi!
> + .skip_filesystems = (const char *const []){"ntfs", "vfat", "exfat",
> + "ext2", "tmpfs", "xfs", "btrfs", NULL},
This should be .filesystems = ... as I wrote in earlier email.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v2] fsconfig04.c: Check FSCONFIG_SET_PATH
2025-05-26 12:54 ` Cyril Hrubis
@ 2025-05-26 16:13 ` Petr Vorel
2025-05-27 8:24 ` Cyril Hrubis
0 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2025-05-26 16:13 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
> Hi!
> > 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"},
> {}
> };
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v2] fsconfig04.c: Check FSCONFIG_SET_PATH
2025-05-26 16:13 ` Petr Vorel
@ 2025-05-27 8:24 ` Cyril Hrubis
2025-05-27 8:58 ` [LTP] LTP doc: test examples [was: Re: [PATCH v2] fsconfig04.c: Check FSCONFIG_SET_PATH] Petr Vorel
0 siblings, 1 reply; 18+ messages in thread
From: Cyril Hrubis @ 2025-05-27 8:24 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
> 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.
> 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.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* [LTP] LTP doc: test examples [was: Re: [PATCH v2] fsconfig04.c: Check FSCONFIG_SET_PATH]
2025-05-27 8:24 ` Cyril Hrubis
@ 2025-05-27 8:58 ` Petr Vorel
0 siblings, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2025-05-27 8:58 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: Ricardo B. Marliere, ltp
Hi all,
> Hi!
> > 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.
> > 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
> 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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* [LTP] [PATCH v3] fsconfig04.c: Check FSCONFIG_SET_PATH
2025-05-26 14:35 ` [LTP] [PATCH v2] " Wei Gao via ltp
2025-05-26 9:54 ` Petr Vorel
2025-05-26 14:38 ` [LTP] [PATCH v2] fsconfig04.c: Check FSCONFIG_SET_PATH Cyril Hrubis
@ 2025-06-03 21:45 ` Wei Gao via ltp
2025-10-17 4:39 ` Wei Gao via ltp
2025-12-12 9:29 ` Andrea Cervesato via ltp
2 siblings, 2 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2025-06-03 21:45 UTC (permalink / raw)
To: 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.
Signed-off-by: Wei Gao <wegao@suse.com>
---
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
diff --git a/runtest/syscalls b/runtest/syscalls
index e369536ea..658ab24c4 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -410,6 +410,7 @@ fremovexattr02 fremovexattr02
fsconfig01 fsconfig01
fsconfig02 fsconfig02
fsconfig03 fsconfig03
+fsconfig04 fsconfig04
fsmount01 fsmount01
fsmount02 fsmount02
diff --git a/testcases/kernel/syscalls/fsconfig/.gitignore b/testcases/kernel/syscalls/fsconfig/.gitignore
index cfedae5f7..bd3754c34 100644
--- a/testcases/kernel/syscalls/fsconfig/.gitignore
+++ b/testcases/kernel/syscalls/fsconfig/.gitignore
@@ -1,3 +1,4 @@
/fsconfig01
/fsconfig02
/fsconfig03
+/fsconfig04
diff --git a/testcases/kernel/syscalls/fsconfig/fsconfig04.c b/testcases/kernel/syscalls/fsconfig/fsconfig04.c
new file mode 100644
index 000000000..c86dac0d2
--- /dev/null
+++ b/testcases/kernel/syscalls/fsconfig/fsconfig04.c
@@ -0,0 +1,162 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Wei Gao <wegao@suse.com>
+ */
+
+/*\
+ * 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:
+ *
+ * - 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"
+
+#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);
+
+ TST_EXP_PASS_SILENT(tst_detach_device(dev1));
+ TST_EXP_PASS_SILENT(tst_detach_device(dev2));
+}
+
+static void setup(void)
+{
+ 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);
+
+ 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];
+
+ 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;
+
+ 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);
+
+ 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,
+ .needs_root = 1,
+ .format_device = 1,
+ .mntpoint = MNTPOINT,
+ .needs_cmds = (const char *[]) {
+ "tune2fs",
+ NULL
+ },
+ .filesystems = (struct tst_fs []) {
+ {.type = "ext3"},
+ {.type = "ext4"},
+ {}
+ },
+};
--
2.49.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v3] fsconfig04.c: Check FSCONFIG_SET_PATH
2025-06-03 21:45 ` [LTP] [PATCH v3] " Wei Gao via ltp
@ 2025-10-17 4:39 ` Wei Gao via ltp
2025-12-12 9:29 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2025-10-17 4:39 UTC (permalink / raw)
To: ltp
CI failure not related to patch, restart of failing job helped, see
https://github.com/coolgw/ltp/actions/runs/18487937913
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v3] fsconfig04.c: Check FSCONFIG_SET_PATH
2025-06-03 21:45 ` [LTP] [PATCH v3] " Wei Gao via ltp
2025-10-17 4:39 ` Wei Gao via ltp
@ 2025-12-12 9:29 ` Andrea Cervesato via ltp
2026-02-25 9:27 ` Wei Gao via ltp
1 sibling, 1 reply; 18+ messages in thread
From: Andrea Cervesato via ltp @ 2025-12-12 9:29 UTC (permalink / raw)
To: Wei Gao, ltp
Hi!
please, re-read the previous reviews before submitting a new version,
because there are still some issues not achieved.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v3] fsconfig04.c: Check FSCONFIG_SET_PATH
2025-12-12 9:29 ` Andrea Cervesato via ltp
@ 2026-02-25 9:27 ` Wei Gao via ltp
2026-03-16 8:49 ` Petr Vorel
0 siblings, 1 reply; 18+ messages in thread
From: Wei Gao via ltp @ 2026-02-25 9:27 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
On Fri, Dec 12, 2025 at 10:29:35AM +0100, Andrea Cervesato wrote:
> 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.
> --
> Andrea Cervesato
> SUSE QE Automation Engineer Linux
> andrea.cervesato@suse.com
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v3] fsconfig04.c: Check FSCONFIG_SET_PATH
2026-02-25 9:27 ` Wei Gao via ltp
@ 2026-03-16 8:49 ` Petr Vorel
2026-03-17 0:59 ` Wei Gao via ltp
2026-03-24 12:50 ` Petr Vorel
0 siblings, 2 replies; 18+ messages in thread
From: Petr Vorel @ 2026-03-16 8:49 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
Hi Andrea, Wei,
> On Fri, Dec 12, 2025 at 10:29:35AM +0100, Andrea Cervesato wrote:
> > 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 :).
> 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"},
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v3] fsconfig04.c: Check FSCONFIG_SET_PATH
2026-03-16 8:49 ` Petr Vorel
@ 2026-03-17 0:59 ` Wei Gao via ltp
2026-03-24 12:50 ` Petr Vorel
1 sibling, 0 replies; 18+ messages in thread
From: Wei Gao via ltp @ 2026-03-17 0:59 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Mon, Mar 16, 2026 at 09:49:20AM +0100, Petr Vorel wrote:
> Hi Andrea, Wei,
>
> > On Fri, Dec 12, 2025 at 10:29:35AM +0100, Andrea Cervesato wrote:
> > > 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 :).
>
> > 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 :).
>
> 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"},
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [LTP] [PATCH v3] fsconfig04.c: Check FSCONFIG_SET_PATH
2026-03-16 8:49 ` Petr Vorel
2026-03-17 0:59 ` Wei Gao via ltp
@ 2026-03-24 12:50 ` Petr Vorel
1 sibling, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2026-03-24 12:50 UTC (permalink / raw)
To: Wei Gao, ltp
Hi Wei,
> + 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
> +++ 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"},
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2026-03-24 12:50 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-16 15:10 [LTP] [PATCH v1] fsconfig04.c: Check FSCONFIG_SET_PATH Wei Gao via ltp
2025-05-22 20:56 ` Petr Vorel
2025-05-26 14:29 ` Wei Gao via ltp
2025-05-26 6:40 ` Petr Vorel
2025-05-26 14:35 ` [LTP] [PATCH v2] " Wei Gao via ltp
2025-05-26 9:54 ` Petr Vorel
2025-05-26 12:54 ` Cyril Hrubis
2025-05-26 16:13 ` Petr Vorel
2025-05-27 8:24 ` Cyril Hrubis
2025-05-27 8:58 ` [LTP] LTP doc: test examples [was: Re: [PATCH v2] fsconfig04.c: Check FSCONFIG_SET_PATH] Petr Vorel
2025-05-26 14:38 ` [LTP] [PATCH v2] fsconfig04.c: Check FSCONFIG_SET_PATH Cyril Hrubis
2025-06-03 21:45 ` [LTP] [PATCH v3] " Wei Gao via ltp
2025-10-17 4:39 ` Wei Gao via ltp
2025-12-12 9:29 ` Andrea Cervesato via ltp
2026-02-25 9:27 ` Wei Gao via ltp
2026-03-16 8:49 ` Petr Vorel
2026-03-17 0:59 ` Wei Gao via ltp
2026-03-24 12:50 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox