[LTP] [PATCH v17] fsconfig04: Check FSCONFIG_SET_PATH

Wei Gao wegao@suse.com
Fri Oct 23 09:51:07 CEST 2026


On Thu, Oct 22, 2026 at 03:03:00PM +0200, Cyril Hrubis wrote:
> On Wed, Oct 21, 2026 at 08:49:12AM +0000, Wei Gao via ltp wrote:
> > 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.
> > 
> > Closes: https://github.com/linux-test-project/ltp/issues/1169
> > Signed-off-by: Wei Gao <wegao@suse.com>
> > Reviewed-by: Petr Vorel <pvorel@suse.cz>
> > ---
> >  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 2bdb4a9a2..1903f1ac6 100644
> > --- a/runtest/syscalls
> > +++ b/runtest/syscalls
> > @@ -452,6 +452,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..bd649717e
> > --- /dev/null
> > +++ b/testcases/kernel/syscalls/fsconfig/fsconfig04.c
> > @@ -0,0 +1,169 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > +/*
> > + * Copyright (c) 2026 Wei Gao <wegao@suse.com>
> > + */
> > +
> > +/*\
> > + * 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)`.
> > + */
> > +
> > +
...
> > +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.

> 
> 
> -- 
> Cyril Hrubis
> chrubis@suse.cz


More information about the ltp mailing list