* [PATCH v5 01/10] fstests: add _loop_image_create_clone() helper
2026-05-21 12:54 [PATCH v5 0/10] fstests: add test coverage for cloned filesystem ids Anand Jain
@ 2026-05-21 12:54 ` Anand Jain
2026-05-25 7:07 ` Christoph Hellwig
2026-05-21 12:54 ` [PATCH v5 02/10] fstests: add _clone_mount_option() helper Anand Jain
` (8 subsequent siblings)
9 siblings, 1 reply; 22+ messages in thread
From: Anand Jain @ 2026-05-21 12:54 UTC (permalink / raw)
To: fstests
Cc: linux-btrfs, linux-ext4, linux-xfs, linux-f2fs, amir73il, zlang,
hch
Introduce _loop_image_create_clone() and _loop_image_destroy() to mkfs an
image file and clone it to another image file, and attach a loop device to
them. And its destroy part.
Signed-off-by: Anand Jain <asj@kernel.org>
---
common/rc | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/common/rc b/common/rc
index 9632b211b58f..a2ee23c45003 100644
--- a/common/rc
+++ b/common/rc
@@ -1503,6 +1503,56 @@ _scratch_resvblks()
esac
}
+_loop_image_create_clone()
+{
+ local -n _ret=$1
+ local pre_clone_tune_func="$2"
+ local img_file=$TEST_DIR/${seq}.img
+ local img_file_clone=$TEST_DIR/${seq}_clone.img
+ local size=$(_small_fs_size_mb 128) # Smallest possible
+ local loop_devs
+
+ _require_fs_space $TEST_DIR $((size * 1024))
+
+ _create_file_sized $((size * 1024 * 1024)) $img_file ||
+ _fail "Failed: Create $img_file $size"
+
+ loop_devs=$(_create_loop_device $img_file)
+ _ret=($loop_devs)
+
+ case $FSTYP in
+ xfs)
+ _mkfs_dev "-s size=4096" ${loop_devs[0]}
+ ;;
+ btrfs)
+ _mkfs_dev ${loop_devs[0]}
+ ;;
+ *)
+ _mkfs_dev ${loop_devs[0]}
+ ;;
+ esac
+
+ # Only execute if the function argument is not empty
+ if [ -n "$pre_clone_tune_func" ]; then
+ $pre_clone_tune_func ${loop_devs[0]}
+ fi
+
+ sync ${loop_devs[0]}
+ cp $img_file $img_file_clone
+
+ loop_devs="$loop_devs $(_create_loop_device $img_file_clone)"
+
+ _ret=($loop_devs)
+}
+
+_loop_image_destroy()
+{
+ for d in "$@"; do
+ local f=$(losetup --noheadings --output BACK-FILE $d)
+ _destroy_loop_device "$d"
+ [ -n "$f" ] && rm -f "$f"
+ done
+}
# Repair scratch filesystem. Returns 0 if the FS is good to go (either no
# errors found or errors were fixed) and nonzero otherwise; also spits out
--
2.43.0
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH v5 01/10] fstests: add _loop_image_create_clone() helper
2026-05-21 12:54 ` [PATCH v5 01/10] fstests: add _loop_image_create_clone() helper Anand Jain
@ 2026-05-25 7:07 ` Christoph Hellwig
0 siblings, 0 replies; 22+ messages in thread
From: Christoph Hellwig @ 2026-05-25 7:07 UTC (permalink / raw)
To: Anand Jain
Cc: fstests, linux-btrfs, linux-ext4, linux-xfs, linux-f2fs, amir73il,
zlang, hch
On Thu, May 21, 2026 at 08:54:51PM +0800, Anand Jain wrote:
> Introduce _loop_image_create_clone() and _loop_image_destroy() to mkfs an
> image file and clone it to another image file, and attach a loop device to
> them. And its destroy part.
>
> Signed-off-by: Anand Jain <asj@kernel.org>
> ---
> common/rc | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
>
> diff --git a/common/rc b/common/rc
> index 9632b211b58f..a2ee23c45003 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -1503,6 +1503,56 @@ _scratch_resvblks()
> esac
> }
>
> +_loop_image_create_clone()
> +{
Please add a comment explaining the function and how to use it.
> +_loop_image_destroy()
> +{
Same.
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v5 02/10] fstests: add _clone_mount_option() helper
2026-05-21 12:54 [PATCH v5 0/10] fstests: add test coverage for cloned filesystem ids Anand Jain
2026-05-21 12:54 ` [PATCH v5 01/10] fstests: add _loop_image_create_clone() helper Anand Jain
@ 2026-05-21 12:54 ` Anand Jain
2026-05-25 7:07 ` Christoph Hellwig
2026-05-21 12:54 ` [PATCH v5 03/10] fstests: add test for inotify isolation on cloned devices Anand Jain
` (7 subsequent siblings)
9 siblings, 1 reply; 22+ messages in thread
From: Anand Jain @ 2026-05-21 12:54 UTC (permalink / raw)
To: fstests
Cc: linux-btrfs, linux-ext4, linux-xfs, linux-f2fs, amir73il, zlang,
hch
Adds _clone_mount_option() helper function to handle filesystem-specific
requirements for mounting cloned devices. Abstract the need for -o nouuid
on XFS.
Signed-off-by: Anand Jain <asj@kernel.org>
---
common/rc | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/common/rc b/common/rc
index a2ee23c45003..7ae9877918c8 100644
--- a/common/rc
+++ b/common/rc
@@ -397,6 +397,20 @@ _scratch_mount_options()
$SCRATCH_DEV $SCRATCH_MNT
}
+_clone_mount_option()
+{
+ local mount_opts=""
+
+ case "$FSTYP" in
+ xfs)
+ mount_opts="-o nouuid"
+ ;;
+ *)
+ esac
+
+ echo $mount_opts
+}
+
_supports_filetype()
{
local dir=$1
--
2.43.0
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH v5 02/10] fstests: add _clone_mount_option() helper
2026-05-21 12:54 ` [PATCH v5 02/10] fstests: add _clone_mount_option() helper Anand Jain
@ 2026-05-25 7:07 ` Christoph Hellwig
0 siblings, 0 replies; 22+ messages in thread
From: Christoph Hellwig @ 2026-05-25 7:07 UTC (permalink / raw)
To: Anand Jain
Cc: fstests, linux-btrfs, linux-ext4, linux-xfs, linux-f2fs, amir73il,
zlang, hch
On Thu, May 21, 2026 at 08:54:52PM +0800, Anand Jain wrote:
> Adds _clone_mount_option() helper function to handle filesystem-specific
> requirements for mounting cloned devices. Abstract the need for -o nouuid
> on XFS.
>
> Signed-off-by: Anand Jain <asj@kernel.org>
> ---
> common/rc | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/common/rc b/common/rc
> index a2ee23c45003..7ae9877918c8 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -397,6 +397,20 @@ _scratch_mount_options()
> $SCRATCH_DEV $SCRATCH_MNT
> }
>
> +_clone_mount_option()
> +{
Comment please.
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v5 03/10] fstests: add test for inotify isolation on cloned devices
2026-05-21 12:54 [PATCH v5 0/10] fstests: add test coverage for cloned filesystem ids Anand Jain
2026-05-21 12:54 ` [PATCH v5 01/10] fstests: add _loop_image_create_clone() helper Anand Jain
2026-05-21 12:54 ` [PATCH v5 02/10] fstests: add _clone_mount_option() helper Anand Jain
@ 2026-05-21 12:54 ` Anand Jain
2026-05-25 7:09 ` Christoph Hellwig
2026-05-21 12:54 ` [PATCH v5 04/10] fstests: verify fanotify isolation on cloned filesystems Anand Jain
` (6 subsequent siblings)
9 siblings, 1 reply; 22+ messages in thread
From: Anand Jain @ 2026-05-21 12:54 UTC (permalink / raw)
To: fstests
Cc: linux-btrfs, linux-ext4, linux-xfs, linux-f2fs, amir73il, zlang,
hch
Add a new test, to verify that the kernel correctly differentiates between
two block devices sharing the same FSID/UUID.
Signed-off-by: Anand Jain <asj@kernel.org>
---
common/config | 1 +
tests/generic/800 | 89 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/800.out | 7 ++++
3 files changed, 97 insertions(+)
create mode 100644 tests/generic/800
create mode 100644 tests/generic/800.out
diff --git a/common/config b/common/config
index 4fd4c2c8af11..605a57947a40 100644
--- a/common/config
+++ b/common/config
@@ -242,6 +242,7 @@ export BTRFS_MAP_LOGICAL_PROG=$(type -P btrfs-map-logical)
export PARTED_PROG="$(type -P parted)"
export XFS_PROPERTY_PROG="$(type -P xfs_property)"
export FSCRYPTCTL_PROG="$(type -P fscryptctl)"
+export INOTIFYWAIT_PROG="$(type -P inotifywait)"
# udev wait functions.
#
diff --git a/tests/generic/800 b/tests/generic/800
new file mode 100644
index 000000000000..4b9bd3e4f487
--- /dev/null
+++ b/tests/generic/800
@@ -0,0 +1,89 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Anand Jain <asj@kernel.org>. All Rights Reserved.
+#
+# FS QA Test 800
+#
+# Verify if the kernel or userspace becomes confused when two block devices
+# share the same fid/fsid/uuid. Create inotify on both original and cloned
+# filesystem. Monitor the notification in the respective logs.
+
+. ./common/preamble
+
+_begin_fstest auto quick mount clone
+
+_require_test
+_require_block_device $TEST_DEV
+_require_loop
+_require_command "$INOTIFYWAIT_PROG" inotifywait
+
+_cleanup()
+{
+ cd /
+ [[ -n $pid1 ]] && { kill -TERM "$pid1" 2> /dev/null; wait $pid1; }
+ [[ -n $pid2 ]] && { kill -TERM "$pid2" 2> /dev/null; wait $pid2; }
+ rm -r -f $tmp.*
+ _unmount $mnt1 2>/dev/null
+ _unmount $mnt2 2>/dev/null
+ _loop_image_destroy "${devs[@]}" 2> /dev/null
+}
+
+devs=()
+_loop_image_create_clone devs
+mkdir -p $TEST_DIR/$seq
+mnt1=$TEST_DIR/$seq/mnt1
+mnt2=$TEST_DIR/$seq/mnt2
+mkdir -p $mnt1
+mkdir -p $mnt2
+
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[0]} $mnt1 || \
+ _fail "Failed to mount dev1"
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[1]} $mnt2 || \
+ _fail "Failed to mount dev2"
+
+log1=$tmp.inotify1
+log2=$tmp.inotify2
+
+pid1=""
+pid2=""
+echo "Setup inotify watchers on both mnt1 and mnt2"
+$INOTIFYWAIT_PROG -m -e create --format '%f' $mnt1 > $log1 2>&1 &
+pid1=$!
+$INOTIFYWAIT_PROG -m -e create --format '%f' $mnt2 > $log2 2>&1 &
+pid2=$!
+sleep 2
+
+echo "Trigger file creation on mnt1"
+touch $mnt1/file_on_mnt1
+sync
+sleep 1
+
+echo "Trigger file creation on mnt2"
+touch $mnt2/file_on_mnt2
+sync
+sleep 1
+
+echo "Verify inotify isolation"
+kill $pid1 $pid2
+wait $pid1 $pid2 2>/dev/null
+pid1=""
+pid2=""
+
+if grep -q "file_on_mnt1" $log1 && ! grep -q "file_on_mnt2" $log1; then
+ echo "SUCCESS: mnt1 events isolated."
+else
+ echo "FAIL: mnt1 inotify confusion!"
+ [ ! -s $log1 ] && echo " - mnt1 received no events."
+ grep -q "file_on_mnt2" $log1 && echo " - mnt1 received event from mnt2."
+fi
+
+if grep -q "file_on_mnt2" $log2 && ! grep -q "file_on_mnt1" $log2; then
+ echo "SUCCESS: mnt2 events isolated."
+else
+ echo "FAIL: mnt2 inotify confusion!"
+ [ ! -s $log2 ] && echo " - mnt2 received no events."
+ grep -q "file_on_mnt1" $log2 && echo " - mnt2 received event from mnt1."
+fi
+
+status=0
+exit
diff --git a/tests/generic/800.out b/tests/generic/800.out
new file mode 100644
index 000000000000..b10842a31210
--- /dev/null
+++ b/tests/generic/800.out
@@ -0,0 +1,7 @@
+QA output created by 800
+Setup inotify watchers on both mnt1 and mnt2
+Trigger file creation on mnt1
+Trigger file creation on mnt2
+Verify inotify isolation
+SUCCESS: mnt1 events isolated.
+SUCCESS: mnt2 events isolated.
--
2.43.0
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH v5 03/10] fstests: add test for inotify isolation on cloned devices
2026-05-21 12:54 ` [PATCH v5 03/10] fstests: add test for inotify isolation on cloned devices Anand Jain
@ 2026-05-25 7:09 ` Christoph Hellwig
2026-05-25 8:35 ` Anand Jain
0 siblings, 1 reply; 22+ messages in thread
From: Christoph Hellwig @ 2026-05-25 7:09 UTC (permalink / raw)
To: Anand Jain
Cc: fstests, linux-btrfs, linux-ext4, linux-xfs, linux-f2fs-devel,
amir73il, zlang, hch
> diff --git a/common/config b/common/config
> index 4fd4c2c8af11..605a57947a40 100644
> --- a/common/config
> +++ b/common/config
> @@ -242,6 +242,7 @@ export BTRFS_MAP_LOGICAL_PROG=$(type -P btrfs-map-logical)
> export PARTED_PROG="$(type -P parted)"
> export XFS_PROPERTY_PROG="$(type -P xfs_property)"
> export FSCRYPTCTL_PROG="$(type -P fscryptctl)"
> +export INOTIFYWAIT_PROG="$(type -P inotifywait)"
Usually we try to split infrastructure changes like this out into
separate patches.
Also any reason to rely on the obsolete inotify instead of fsnotify?
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5 03/10] fstests: add test for inotify isolation on cloned devices
2026-05-25 7:09 ` Christoph Hellwig
@ 2026-05-25 8:35 ` Anand Jain
0 siblings, 0 replies; 22+ messages in thread
From: Anand Jain @ 2026-05-25 8:35 UTC (permalink / raw)
To: Christoph Hellwig, Anand Jain
Cc: fstests, linux-btrfs, linux-ext4, linux-xfs, amir73il, zlang
On 25/5/26 15:09, Christoph Hellwig wrote:
>> diff --git a/common/config b/common/config
>> index 4fd4c2c8af11..605a57947a40 100644
>> --- a/common/config
>> +++ b/common/config
>> @@ -242,6 +242,7 @@ export BTRFS_MAP_LOGICAL_PROG=$(type -P btrfs-map-logical)
>> export PARTED_PROG="$(type -P parted)"
>> export XFS_PROPERTY_PROG="$(type -P xfs_property)"
>> export FSCRYPTCTL_PROG="$(type -P fscryptctl)"
>> +export INOTIFYWAIT_PROG="$(type -P inotifywait)"
>
> Usually we try to split infrastructure changes like this out into
> separate patches.
Right. I'll split it into a separate patch.
> Also any reason to rely on the obsolete inotify instead of fsnotify?
fsnotify is exercised in patch 4/10.
IMO, exercising inotify ensures we don't break legacy stuff.
In general, is it fine to keep obsolete command/testcase from
an LTS kernel perspective? We did that a couple of times before.
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v5 04/10] fstests: verify fanotify isolation on cloned filesystems
2026-05-21 12:54 [PATCH v5 0/10] fstests: add test coverage for cloned filesystem ids Anand Jain
` (2 preceding siblings ...)
2026-05-21 12:54 ` [PATCH v5 03/10] fstests: add test for inotify isolation on cloned devices Anand Jain
@ 2026-05-21 12:54 ` Anand Jain
2026-05-25 7:11 ` Christoph Hellwig
2026-05-21 12:54 ` [PATCH v5 05/10] fstests: verify f_fsid for " Anand Jain
` (5 subsequent siblings)
9 siblings, 1 reply; 22+ messages in thread
From: Anand Jain @ 2026-05-21 12:54 UTC (permalink / raw)
To: fstests
Cc: linux-btrfs, linux-ext4, linux-xfs, linux-f2fs, amir73il, zlang,
hch
Verify that fanotify events are correctly routed to the appropriate
watcher when cloned filesystems are mounted.
Helps verify kernel's event notification distinguishes between devices
sharing the same FSID/UUID.
Signed-off-by: Anand Jain <asj@kernel.org>
---
common/config | 1 +
tests/generic/801 | 125 ++++++++++++++++++++++++++++++++++++++++++
tests/generic/801.out | 7 +++
3 files changed, 133 insertions(+)
create mode 100644 tests/generic/801
create mode 100644 tests/generic/801.out
diff --git a/common/config b/common/config
index 605a57947a40..1588bdcb1aa1 100644
--- a/common/config
+++ b/common/config
@@ -243,6 +243,7 @@ export PARTED_PROG="$(type -P parted)"
export XFS_PROPERTY_PROG="$(type -P xfs_property)"
export FSCRYPTCTL_PROG="$(type -P fscryptctl)"
export INOTIFYWAIT_PROG="$(type -P inotifywait)"
+export FSNOTIFYWAIT_PROG="$(type -P fsnotifywait)"
# udev wait functions.
#
diff --git a/tests/generic/801 b/tests/generic/801
new file mode 100644
index 000000000000..5cbdfb85539b
--- /dev/null
+++ b/tests/generic/801
@@ -0,0 +1,125 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Anand Jain <asj@kernel.org>. All Rights Reserved.
+#
+# FS QA Test 801
+# Verify fanotify FID functionality on cloned filesystems by setting up
+# watchers and making sure notifications are in the correct logs files.
+
+. ./common/preamble
+
+_begin_fstest auto quick mount clone
+
+_require_test
+_require_block_device $TEST_DEV
+_require_loop
+_require_command "$FSNOTIFYWAIT_PROG" fsnotifywait
+
+_cleanup()
+{
+ cd /
+ [[ -n $pid1 ]] && { kill -TERM "$pid1" 2> /dev/null; wait $pid1; }
+ [[ -n $pid2 ]] && { kill -TERM "$pid2" 2> /dev/null; wait $pid2; }
+
+ if [ "$semanage_added" = "yes" ]; then
+ semanage permissive -d unconfined_t >/dev/null 2>&1 || true
+ fi
+
+ umount $mnt1 $mnt2 2>/dev/null
+ _loop_image_destroy "${devs[@]}" 2> /dev/null
+ rm -r -f $tmp.*
+}
+
+monitor_fanotify()
+{
+ local mmnt=$1
+ exec stdbuf -oL $FSNOTIFYWAIT_PROG -m -F -S -e create "$mmnt" 2>&1
+}
+
+fsid_to_fid_parts()
+{
+ local fsid=$1
+ # Pad to 16 hex chars (64-bit), then split into two 32-bit halves
+ local padded=$(printf '%016x' "0x${fsid}")
+ local hi=$(printf '%x' "0x${padded:0:8}") # strips leading zeros
+ local lo=$(printf '%x' "0x${padded:8:8}") # strips leading zeros
+ echo "${hi}.${lo}"
+}
+
+devs=()
+_loop_image_create_clone devs
+mkdir -p $TEST_DIR/$seq
+mnt1=$TEST_DIR/$seq/mnt1
+mnt2=$TEST_DIR/$seq/mnt2
+mkdir -p $mnt1
+mkdir -p $mnt2
+
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[0]} $mnt1 || \
+ _fail "Failed to mount dev1"
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[1]} $mnt2 || \
+ _fail "Failed to mount dev2"
+
+fsid1=$(stat -f -c "%i" $mnt1)
+fsid2=$(stat -f -c "%i" $mnt2)
+
+[[ "$fsid1" == "$fsid2" ]] && \
+ _notrun "Require clone filesystem with unique f_fsid"
+
+log1=$tmp.fanotify1
+log2=$tmp.fanotify2
+
+pid1=""
+pid2=""
+echo "Setup FID fanotify watchers on both mnt1 and mnt2"
+semanage_added="no"
+if [ "$(getenforce 2>/dev/null)" = "Enforcing" ]; then
+ if ! semanage permissive -l | grep -q "unconfined_t"; then
+ semanage permissive -a unconfined_t >/dev/null 2>&1 && semanage_added="yes"
+ fi
+fi
+
+( monitor_fanotify "$mnt1" > "$log1" ) &
+pid1=$!
+( monitor_fanotify "$mnt2" > "$log2" ) &
+pid2=$!
+sleep 2
+
+echo "Trigger file creation on mnt1"
+touch $mnt1/file_on_mnt1
+sync
+sleep 1
+
+echo "Trigger file creation on mnt2"
+touch $mnt2/file_on_mnt2
+sync
+sleep 1
+
+echo "Verify fsid in the fanotify"
+kill $pid1 $pid2
+wait $pid1 $pid2 2>/dev/null
+pid1=""
+pid2=""
+
+e_fsid1=$(fsid_to_fid_parts "$fsid1")
+e_fsid2=$(fsid_to_fid_parts "$fsid2")
+
+echo $fsid1 $e_fsid1 $fsid2 $e_fsid2 >> $seqres.full
+cat $log1 >> $seqres.full
+cat $log2 >> $seqres.full
+
+if grep -qF "$e_fsid1" "$log1" && ! grep -qF "$e_fsid2" "$log1"; then
+ echo "SUCCESS: mnt1 events found"
+else
+ [ ! -s "$log1" ] && echo " - mnt1 received no events."
+ grep -qF "$e_fsid2" "$log1" && echo " - mnt1 received event from mnt2."
+fi
+
+if grep -qF "$e_fsid2" "$log2" && ! grep -qF "$e_fsid1" "$log2"; then
+ echo "SUCCESS: mnt2 events found"
+else
+ [ ! -s "$log2" ] && echo " - mnt2 received no events."
+ grep -qF "$e_fsid1" "$log2" && echo " - mnt2 received event from mnt1."
+fi
+
+status=0
+exit
diff --git a/tests/generic/801.out b/tests/generic/801.out
new file mode 100644
index 000000000000..d7b318d9f27c
--- /dev/null
+++ b/tests/generic/801.out
@@ -0,0 +1,7 @@
+QA output created by 801
+Setup FID fanotify watchers on both mnt1 and mnt2
+Trigger file creation on mnt1
+Trigger file creation on mnt2
+Verify fsid in the fanotify
+SUCCESS: mnt1 events found
+SUCCESS: mnt2 events found
--
2.43.0
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH v5 04/10] fstests: verify fanotify isolation on cloned filesystems
2026-05-21 12:54 ` [PATCH v5 04/10] fstests: verify fanotify isolation on cloned filesystems Anand Jain
@ 2026-05-25 7:11 ` Christoph Hellwig
2026-05-25 8:20 ` Anand Jain
0 siblings, 1 reply; 22+ messages in thread
From: Christoph Hellwig @ 2026-05-25 7:11 UTC (permalink / raw)
To: Anand Jain
Cc: fstests, linux-btrfs, linux-ext4, linux-xfs, linux-f2fs-devel,
amir73il, zlang, hch
> +export FSNOTIFYWAIT_PROG="$(type -P fsnotifywait)"
Same comment about adding new common bits outside of test cases applies,
but why use both inotify and fsnotify?
> +[[ "$fsid1" == "$fsid2" ]] && \
> + _notrun "Require clone filesystem with unique f_fsid"
Please add a comment why this happens. I also have to say I find
the if syntax easier to follow then && with a line continuation.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5 04/10] fstests: verify fanotify isolation on cloned filesystems
2026-05-25 7:11 ` Christoph Hellwig
@ 2026-05-25 8:20 ` Anand Jain
0 siblings, 0 replies; 22+ messages in thread
From: Anand Jain @ 2026-05-25 8:20 UTC (permalink / raw)
To: Christoph Hellwig, Anand Jain
Cc: fstests, linux-btrfs, linux-ext4, linux-xfs, linux-f2fs-devel,
amir73il, zlang
On 25/5/26 15:11, Christoph Hellwig wrote:
>> +export FSNOTIFYWAIT_PROG="$(type -P fsnotifywait)"
>
> Same comment about adding new common bits outside of test cases applies,
Got it.
> but why use both inotify and fsnotify?
>
The SYSCALL and stuffs until fsnotify_..() are different,
so I decided to keep them both.
>> +[[ "$fsid1" == "$fsid2" ]] && \
>> + _notrun "Require clone filesystem with unique f_fsid"
>
> Please add a comment why this happens. I also have to say I find
> the if syntax easier to follow then && with a line continuation.
Got it. If statements are better for readability.
Also, I'll add comments.
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v5 05/10] fstests: verify f_fsid for cloned filesystems
2026-05-21 12:54 [PATCH v5 0/10] fstests: add test coverage for cloned filesystem ids Anand Jain
` (3 preceding siblings ...)
2026-05-21 12:54 ` [PATCH v5 04/10] fstests: verify fanotify isolation on cloned filesystems Anand Jain
@ 2026-05-21 12:54 ` Anand Jain
2026-05-25 7:13 ` Christoph Hellwig
2026-05-21 12:54 ` [PATCH v5 06/10] fstests: verify libblkid resolution of duplicate UUIDs Anand Jain
` (4 subsequent siblings)
9 siblings, 1 reply; 22+ messages in thread
From: Anand Jain @ 2026-05-21 12:54 UTC (permalink / raw)
To: fstests
Cc: linux-btrfs, linux-ext4, linux-xfs, linux-f2fs, amir73il, zlang,
hch
Verify that the cloned filesystem provides an f_fsid that is persistent
across mount cycles, yet unique from the original filesystem's f_fsid.
Signed-off-by: Anand Jain <asj@kernel.org>
---
tests/generic/802 | 62 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/802.out | 7 +++++
2 files changed, 69 insertions(+)
create mode 100644 tests/generic/802
create mode 100644 tests/generic/802.out
diff --git a/tests/generic/802 b/tests/generic/802
new file mode 100644
index 000000000000..31044695f3a8
--- /dev/null
+++ b/tests/generic/802
@@ -0,0 +1,62 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Anand Jain <asj@kernel.org>. All Rights Reserved.
+#
+# FS QA Test 802
+# Verify f_fsid and s_uuid of cloned filesystems across mount cycle.
+
+. ./common/preamble
+
+_begin_fstest auto quick mount clone
+
+_require_test
+_require_block_device $TEST_DEV
+_require_loop
+
+[ "$FSTYP" = "btrfs" ] && _fixed_by_kernel_commit xxxxxxxxxxxx \
+ "btrfs: use on-disk uuid for s_uuid in temp_fsid mounts"
+[ "$FSTYP" = "btrfs" ] && _fixed_by_kernel_commit xxxxxxxxxxxx \
+ "btrfs: derive f_fsid from on-disk fsuuid and dev_t"
+
+_cleanup()
+{
+ cd /
+ rm -r -f $tmp.*
+ umount $mnt1 $mnt2 2>/dev/null
+ _loop_image_destroy "${devs[@]}" 2> /dev/null
+}
+
+devs=()
+_loop_image_create_clone devs
+mkdir -p $TEST_DIR/$seq
+mnt1=$TEST_DIR/$seq/mnt1
+mnt2=$TEST_DIR/$seq/mnt2
+mkdir -p $mnt1
+mkdir -p $mnt2
+
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[0]} $mnt1 || \
+ _fail "Failed to mount dev1"
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[1]} $mnt2 || \
+ _fail "Failed to mount dev2"
+
+fsid_scratch=$(stat -f -c "%i" $mnt1)
+fsid_clone=$(stat -f -c "%i" $mnt2)
+
+echo "**** fsid initially ****"
+echo $fsid_scratch | sed -e "s/$fsid_scratch/FSID_SCRATCH/g"
+echo $fsid_clone | sed -e "s/$fsid_clone/FSID_CLONE/g"
+
+# Make sure fsid still match across a mount cycle, also reverse the order.
+echo "**** fsid after mount cycle ****"
+_unmount $mnt1
+_unmount $mnt2
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[1]} $mnt2 || \
+ _fail "Failed to mount dev2"
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[0]} $mnt1 || \
+ _fail "Failed to mount dev1"
+
+stat -f -c "%i" $mnt1 | sed -e "s/$fsid_scratch/FSID_SCRATCH/g"
+stat -f -c "%i" $mnt2 | sed -e "s/$fsid_clone/FSID_CLONE/g"
+
+status=0
+exit
diff --git a/tests/generic/802.out b/tests/generic/802.out
new file mode 100644
index 000000000000..d1e008f122bb
--- /dev/null
+++ b/tests/generic/802.out
@@ -0,0 +1,7 @@
+QA output created by 802
+**** fsid initially ****
+FSID_SCRATCH
+FSID_CLONE
+**** fsid after mount cycle ****
+FSID_SCRATCH
+FSID_CLONE
--
2.43.0
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH v5 05/10] fstests: verify f_fsid for cloned filesystems
2026-05-21 12:54 ` [PATCH v5 05/10] fstests: verify f_fsid for " Anand Jain
@ 2026-05-25 7:13 ` Christoph Hellwig
0 siblings, 0 replies; 22+ messages in thread
From: Christoph Hellwig @ 2026-05-25 7:13 UTC (permalink / raw)
To: Anand Jain
Cc: fstests, linux-btrfs, linux-ext4, linux-xfs, linux-f2fs-devel,
amir73il, zlang
On Thu, May 21, 2026 at 08:54:55PM +0800, Anand Jain wrote:
> +[ "$FSTYP" = "btrfs" ] && _fixed_by_kernel_commit xxxxxxxxxxxx \
> + "btrfs: use on-disk uuid for s_uuid in temp_fsid mounts"
> +[ "$FSTYP" = "btrfs" ] && _fixed_by_kernel_commit xxxxxxxxxxxx \
> + "btrfs: derive f_fsid from on-disk fsuuid and dev_t"
Seems like these are stuck on the btrfs list. Any progress on that?
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v5 06/10] fstests: verify libblkid resolution of duplicate UUIDs
2026-05-21 12:54 [PATCH v5 0/10] fstests: add test coverage for cloned filesystem ids Anand Jain
` (4 preceding siblings ...)
2026-05-21 12:54 ` [PATCH v5 05/10] fstests: verify f_fsid for " Anand Jain
@ 2026-05-21 12:54 ` Anand Jain
2026-05-21 12:54 ` [PATCH v5 07/10] fstests: verify IMA isolation on cloned filesystems Anand Jain
` (3 subsequent siblings)
9 siblings, 0 replies; 22+ messages in thread
From: Anand Jain @ 2026-05-21 12:54 UTC (permalink / raw)
To: fstests
Cc: linux-btrfs, linux-ext4, linux-xfs, linux-f2fs, amir73il, zlang,
hch
Verify how findmnt, df (libblkid) resolve device paths when multiple
block devices share the same FSUUID.
Signed-off-by: Anand Jain <asj@kernel.org>
---
tests/generic/803 | 76 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/803.out | 19 +++++++++++
2 files changed, 95 insertions(+)
create mode 100644 tests/generic/803
create mode 100644 tests/generic/803.out
diff --git a/tests/generic/803 b/tests/generic/803
new file mode 100644
index 000000000000..36de7887065e
--- /dev/null
+++ b/tests/generic/803
@@ -0,0 +1,76 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Anand Jain <asj@kernel.org>. All Rights Reserved.
+#
+# FS QA Test 803
+# Verify how libblkid resolve devices when multiple devices sharing the
+# same FSUUID.
+
+. ./common/preamble
+. ./common/filter
+
+_begin_fstest auto quick mount clone
+
+_require_test
+_require_block_device $TEST_DEV
+_require_loop
+
+_cleanup()
+{
+ cd /
+ rm -r -f $tmp.*
+ umount $mnt1 $mnt2 2>/dev/null
+ _loop_image_destroy "${devs[@]}" 2> /dev/null
+}
+
+filter_pool()
+{
+ sed -e "s|${devs[0]}|DEV1|g" -e "s|${mnt1}|MNT1|g" \
+ -e "s|${devs[1]}|DEV2|g" -e "s|${mnt2}|MNT2|g" | _filter_spaces
+}
+
+print_info()
+{
+ local mntpt=$1
+ local tgt=$(findmnt -no SOURCE $mntpt)
+ local fsuuid=$(blkid -s UUID -o value $tgt)
+
+ echo "mntpt=$mntpt tgt=$tgt fsuuid=$fsuuid" >> $seqres.full
+ echo
+ findmnt -o SOURCE,TARGET,UUID "$tgt" | tail -n +2 | \
+ sed -e "s/${fsuuid}/FSUUID/g" | filter_pool
+ awk -v dev="$tgt" '$1 == dev { print $1, $2 }' /proc/self/mounts | \
+ filter_pool
+ df --all --output=source,target "$tgt" | tail -n +2 | filter_pool
+}
+
+devs=()
+_loop_image_create_clone devs
+mkdir -p $TEST_DIR/$seq
+mnt1=$TEST_DIR/$seq/mnt1
+mnt2=$TEST_DIR/$seq/mnt2
+mkdir -p $mnt1
+mkdir -p $mnt2
+
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[0]} $mnt1 || \
+ _fail "Failed to mount dev1"
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[1]} $mnt2 || \
+ _fail "Failed to mount dev2"
+
+print_info $mnt1
+print_info $mnt2
+
+echo
+echo "**** mount cycle ****"
+_unmount $mnt1
+_unmount $mnt2
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[1]} $mnt2 || \
+ _fail "Failed to mount dev2"
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[0]} $mnt1 || \
+ _fail "Failed to mount dev1"
+
+print_info $mnt1
+print_info $mnt2
+
+status=0
+exit
diff --git a/tests/generic/803.out b/tests/generic/803.out
new file mode 100644
index 000000000000..20a1cb36a213
--- /dev/null
+++ b/tests/generic/803.out
@@ -0,0 +1,19 @@
+QA output created by 803
+
+DEV1 MNT1 FSUUID
+DEV1 MNT1
+DEV1 MNT1
+
+DEV2 MNT2 FSUUID
+DEV2 MNT2
+DEV2 MNT2
+
+**** mount cycle ****
+
+DEV1 MNT1 FSUUID
+DEV1 MNT1
+DEV1 MNT1
+
+DEV2 MNT2 FSUUID
+DEV2 MNT2
+DEV2 MNT2
--
2.43.0
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v5 07/10] fstests: verify IMA isolation on cloned filesystems
2026-05-21 12:54 [PATCH v5 0/10] fstests: add test coverage for cloned filesystem ids Anand Jain
` (5 preceding siblings ...)
2026-05-21 12:54 ` [PATCH v5 06/10] fstests: verify libblkid resolution of duplicate UUIDs Anand Jain
@ 2026-05-21 12:54 ` Anand Jain
2026-05-21 12:54 ` [PATCH v5 08/10] fstests: verify exportfs file handles " Anand Jain
` (2 subsequent siblings)
9 siblings, 0 replies; 22+ messages in thread
From: Anand Jain @ 2026-05-21 12:54 UTC (permalink / raw)
To: fstests
Cc: linux-btrfs, linux-ext4, linux-xfs, linux-f2fs, amir73il, zlang,
hch
Add testcase to verify IMA measurement isolation when multiple devices
share the same FSUUID.
Signed-off-by: Anand Jain <asj@kernel.org>
---
tests/generic/804 | 103 ++++++++++++++++++++++++++++++++++++++++++
tests/generic/804.out | 10 ++++
2 files changed, 113 insertions(+)
create mode 100644 tests/generic/804
create mode 100644 tests/generic/804.out
diff --git a/tests/generic/804 b/tests/generic/804
new file mode 100644
index 000000000000..9f3459015422
--- /dev/null
+++ b/tests/generic/804
@@ -0,0 +1,103 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Anand Jain <asj@kernel.org>. All Rights Reserved.
+#
+# FS QA Test 804
+# Verify IMA isolation on cloned filesystems:
+# . Mount two devices sharing the same FSUUID (cloned).
+# . Apply an IMA policy to measure files based on that FSUUID.
+# . Create unique files on each mount point to trigger measurements.
+# . Confirm the IMA log correctly attributes events to the respective mounts.
+
+. ./common/preamble
+. ./common/filter
+
+_begin_fstest auto quick clone
+
+_require_test
+_require_block_device $TEST_DEV
+_require_loop
+
+[ "$FSTYP" = "btrfs" ] && _fixed_by_kernel_commit xxxxxxxxxxxx \
+ "btrfs: use on-disk uuid for s_uuid in temp_fsid mounts"
+[ "$FSTYP" = "btrfs" ] && _fixed_by_kernel_commit xxxxxxxxxxxx \
+ "btrfs: derive f_fsid from on-disk fsuuid and dev_t"
+
+_cleanup()
+{
+ cd /
+ rm -r -f $tmp.*
+ _unmount $mnt1 2>/dev/null
+ _unmount $mnt2 2>/dev/null
+ _loop_image_destroy "${devs[@]}" 2> /dev/null
+}
+
+filter_pool()
+{
+ sed -e "s|${devs[0]}|DEV1|g" -e "s|$mnt1|MNT1|g" \
+ -e "s|${devs[1]}|DEV2|g" -e "s|$mnt2|MNT2|g" | _filter_spaces
+}
+
+do_ima()
+{
+ local ima_policy="/sys/kernel/security/ima/policy"
+ local ima_log="/sys/kernel/security/ima/ascii_runtime_measurements"
+ local fsuuid
+ local mnt=$1
+ local enable=$2
+
+ # Since the in-memory IMA audit log is only cleared upon reboot,
+ # use unique random filenames to avoid log collisions.
+ local foofile=$(mktemp --dry-run foobar_XXXXX)
+
+ echo $mnt $enable | filter_pool
+
+ [ -w "$ima_policy" ] || _notrun "IMA policy not writable"
+
+ fsuuid=$(blkid -s UUID -o value ${devs[0]})
+
+ # Load IMA policy to measure file access specifically for this
+ # filesystem UUID.
+ if [[ $enable -eq 1 ]]; then
+ echo "measure func=FILE_CHECK fsuuid=$fsuuid" > "$ima_policy" || \
+ _notrun "Policy rejected"
+ fi
+
+ # Create a file to trigger measurement and verify its entry in
+ # the IMA log.
+ echo "test_data" > $mnt/$foofile
+
+ # For $ima_log column entry please ref to
+ grep $foofile "$ima_log" | awk '{ print $5 }' | filter_pool | \
+ sed "s/$foofile/FOOBAR_FILE/"
+
+ echo "dbg: $mnt $fsuuid $foofile" >> $seqres.full
+ cat $ima_log | tail -1 >> $seqres.full
+ echo >> $seqres.full
+}
+
+devs=()
+_loop_image_create_clone devs
+mnt1=$TEST_DIR/$seq/mnt1
+mnt2=$TEST_DIR/$seq/mnt2
+mkdir -p $mnt1
+mkdir -p $mnt2
+
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[0]} $mnt1 || \
+ _fail "Failed to mount dev1"
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[1]} $mnt2 || \
+ _fail "Failed to mount dev2"
+
+do_ima $mnt1 1
+do_ima $mnt2 0
+
+# Btrfs uses in-memory dynamic temp_fsid
+echo mount cycle
+_unmount $mnt2
+_mount $mount_opts ${devs[1]} $mnt2 || _fail "Failed to mount dev2"
+
+do_ima $mnt1 0
+do_ima $mnt2 0
+
+status=0
+exit
diff --git a/tests/generic/804.out b/tests/generic/804.out
new file mode 100644
index 000000000000..9804181d6c17
--- /dev/null
+++ b/tests/generic/804.out
@@ -0,0 +1,10 @@
+QA output created by 804
+MNT1 1
+MNT1/FOOBAR_FILE
+MNT2 0
+MNT2/FOOBAR_FILE
+mount cycle
+MNT1 0
+MNT1/FOOBAR_FILE
+MNT2 0
+MNT2/FOOBAR_FILE
--
2.43.0
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v5 08/10] fstests: verify exportfs file handles on cloned filesystems
2026-05-21 12:54 [PATCH v5 0/10] fstests: add test coverage for cloned filesystem ids Anand Jain
` (6 preceding siblings ...)
2026-05-21 12:54 ` [PATCH v5 07/10] fstests: verify IMA isolation on cloned filesystems Anand Jain
@ 2026-05-21 12:54 ` Anand Jain
2026-05-21 12:54 ` [PATCH v5 09/10] fstests: add pre_clone_tune_uuid() healper Anand Jain
2026-05-21 12:55 ` [PATCH v5 10/10] fstests: test UUID consistency for clones with metadata_uuid Anand Jain
9 siblings, 0 replies; 22+ messages in thread
From: Anand Jain @ 2026-05-21 12:54 UTC (permalink / raw)
To: fstests
Cc: linux-btrfs, linux-ext4, linux-xfs, linux-f2fs, amir73il, zlang,
hch
Ensure that exportfs can correctly decode file handles on a cloned
filesystem across a mount cycle, by file handles generated on a
cloned device remain valid after mount cycle.
Signed-off-by: Anand Jain <asj@kernel.org>
---
tests/generic/805 | 73 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/805.out | 2 ++
2 files changed, 75 insertions(+)
create mode 100644 tests/generic/805
create mode 100644 tests/generic/805.out
diff --git a/tests/generic/805 b/tests/generic/805
new file mode 100644
index 000000000000..98e7172e141f
--- /dev/null
+++ b/tests/generic/805
@@ -0,0 +1,73 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Anand Jain <asj@kernel.org>. All Rights Reserved.
+#
+# FS QA Test No. 805
+
+. ./common/preamble
+
+_begin_fstest auto quick exportfs clone
+
+_require_test
+_require_block_device $TEST_DEV
+_require_exportfs
+_require_loop
+_require_test_program "open_by_handle"
+
+_cleanup()
+{
+ cd /
+ rm -r -f $tmp.*
+ _unmount $mnt1 2>/dev/null
+ _unmount $mnt2 2>/dev/null
+ _loop_image_destroy "${devs[@]}" 2> /dev/null
+}
+
+# Create test dir and test files, encode file handles and store to tmp file
+create_test_files()
+{
+ rm -rf $testdir
+ mkdir -p $testdir
+ $here/src/open_by_handle -cwp -o $tmp.handles_file $testdir $NUMFILES
+}
+
+# Decode file handles loaded from tmp file
+test_file_handles()
+{
+ local opt=$1
+ local when=$2
+
+ echo test_file_handles after $when
+ $here/src/open_by_handle $opt -i $tmp.handles_file $mnt2 $NUMFILES
+}
+
+devs=()
+_loop_image_create_clone devs
+mkdir -p $TEST_DIR/$seq
+mnt1=$TEST_DIR/$seq/mnt1
+mnt2=$TEST_DIR/$seq/mnt2
+mkdir -p $mnt1
+mkdir -p $mnt2
+
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[0]} $mnt1 || \
+ _fail "Failed to mount dev1"
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[1]} $mnt2 || \
+ _fail "Failed to mount dev2"
+
+NUMFILES=1
+testdir=$mnt2/testdir
+
+# Decode file handles of files/dir after cycle mount
+create_test_files
+
+_unmount $mnt1
+_unmount $mnt2
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[1]} $mnt2 || \
+ _fail "Failed to mount dev2"
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[0]} $mnt1 || \
+ _fail "Failed to mount dev1"
+
+test_file_handles -rp "cycle mount"
+
+status=0
+exit
diff --git a/tests/generic/805.out b/tests/generic/805.out
new file mode 100644
index 000000000000..29b11ec77ffb
--- /dev/null
+++ b/tests/generic/805.out
@@ -0,0 +1,2 @@
+QA output created by 805
+test_file_handles after cycle mount
--
2.43.0
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v5 09/10] fstests: add pre_clone_tune_uuid() healper
2026-05-21 12:54 [PATCH v5 0/10] fstests: add test coverage for cloned filesystem ids Anand Jain
` (7 preceding siblings ...)
2026-05-21 12:54 ` [PATCH v5 08/10] fstests: verify exportfs file handles " Anand Jain
@ 2026-05-21 12:54 ` Anand Jain
2026-05-21 13:10 ` Anand Jain
2026-05-21 12:55 ` [PATCH v5 10/10] fstests: test UUID consistency for clones with metadata_uuid Anand Jain
9 siblings, 1 reply; 22+ messages in thread
From: Anand Jain @ 2026-05-21 12:54 UTC (permalink / raw)
To: fstests
Cc: linux-btrfs, linux-ext4, linux-xfs, linux-f2fs, amir73il, zlang,
hch
pre_clone_tune_uuid() changes the UUID of the golden filesystem before it
is cloned.
Signed-off-by: Anand Jain <asj@kernel.org>
---
common/rc | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/common/rc b/common/rc
index 7ae9877918c8..1b3a32d9ea9b 100644
--- a/common/rc
+++ b/common/rc
@@ -1517,6 +1517,26 @@ _scratch_resvblks()
esac
}
+pre_clone_tune_uuid()
+{
+ local temp_mnt=$TEST_DIR/${seq}_mnt
+ local dev=$1
+
+ case $FSTYP in
+ xfs)
+ _require_command "$XFS_ADMIN_PROG" "xfs_admin"
+ $XFS_ADMIN_PROG -U generate $dev >> $seqres.full
+ ;;
+ btrfs)
+ _require_command "$BTRFS_TUNE_PROG" "btrfstune"
+ $BTRFS_TUNE_PROG -m $dev
+ ;;
+ *)
+ _notrun "Require filesystem with metadata_uuid feature"
+ ;;
+ esac
+}
+
_loop_image_create_clone()
{
local -n _ret=$1
--
2.43.0
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH v5 09/10] fstests: add pre_clone_tune_uuid() healper
2026-05-21 12:54 ` [PATCH v5 09/10] fstests: add pre_clone_tune_uuid() healper Anand Jain
@ 2026-05-21 13:10 ` Anand Jain
2026-05-25 7:14 ` Christoph Hellwig
0 siblings, 1 reply; 22+ messages in thread
From: Anand Jain @ 2026-05-21 13:10 UTC (permalink / raw)
To: fstests, zlang, Zorro Lang
Cc: linux-btrfs, linux-ext4, linux-xfs, linux-f2fs, amir73il, hch,
Anand Jain
On 21/5/26 20:54, Anand Jain wrote:
> pre_clone_tune_uuid() changes the UUID of the golden filesystem before it
> is cloned.
>
> Signed-off-by: Anand Jain <asj@kernel.org>
> ---
> common/rc | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/common/rc b/common/rc
> index 7ae9877918c8..1b3a32d9ea9b 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -1517,6 +1517,26 @@ _scratch_resvblks()
> esac
> }
>
> +pre_clone_tune_uuid()
I missed the "_" prefix for pre_clone_tune_uuid() to match
the common/rc style.
Zorro,
If there are no other rerolls, can you please fix it at merge
or should I resend?
Thanks
> +{
> + local temp_mnt=$TEST_DIR/${seq}_mnt
> + local dev=$1
> +
> + case $FSTYP in
> + xfs)
> + _require_command "$XFS_ADMIN_PROG" "xfs_admin"
> + $XFS_ADMIN_PROG -U generate $dev >> $seqres.full
> + ;;
> + btrfs)
> + _require_command "$BTRFS_TUNE_PROG" "btrfstune"
> + $BTRFS_TUNE_PROG -m $dev
> + ;;
> + *)
> + _notrun "Require filesystem with metadata_uuid feature"
> + ;;
> + esac
> +}
> +
> _loop_image_create_clone()
> {
> local -n _ret=$1
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH v5 09/10] fstests: add pre_clone_tune_uuid() healper
2026-05-21 13:10 ` Anand Jain
@ 2026-05-25 7:14 ` Christoph Hellwig
2026-05-25 7:31 ` Anand Jain
0 siblings, 1 reply; 22+ messages in thread
From: Christoph Hellwig @ 2026-05-25 7:14 UTC (permalink / raw)
To: Anand Jain
Cc: fstests, zlang, Zorro Lang, linux-btrfs, linux-ext4, linux-xfs,
linux-f2fs, amir73il, hch, Anand Jain
On Thu, May 21, 2026 at 09:10:36PM +0800, Anand Jain wrote:
> > +pre_clone_tune_uuid()
>
>
> I missed the "_" prefix for pre_clone_tune_uuid() to match
> the common/rc style.
and a comment explaining the helper. Also I think it should
be named to describe what it does, not what you use for, i.e.
something about changing the metadata uuid.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5 09/10] fstests: add pre_clone_tune_uuid() healper
2026-05-25 7:14 ` Christoph Hellwig
@ 2026-05-25 7:31 ` Anand Jain
2026-05-25 7:48 ` Christoph Hellwig
0 siblings, 1 reply; 22+ messages in thread
From: Anand Jain @ 2026-05-25 7:31 UTC (permalink / raw)
To: Christoph Hellwig
Cc: fstests, zlang, Zorro Lang, linux-btrfs, linux-ext4, linux-xfs,
linux-f2fs, amir73il, Anand Jain
On 25/5/26 15:14, Christoph Hellwig wrote:
> On Thu, May 21, 2026 at 09:10:36PM +0800, Anand Jain wrote:
>>> +pre_clone_tune_uuid()
>>
>>
>> I missed the "_" prefix for pre_clone_tune_uuid() to match
>> the common/rc style.
>
> and a comment explaining the helper. Also I think it should
> be named to describe what it does, not what you use for, i.e.
> something about changing the metadata uuid.
>
Agreed. I'll update it. Is _change_metadata_uuid() a better name?
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v5 09/10] fstests: add pre_clone_tune_uuid() healper
2026-05-25 7:31 ` Anand Jain
@ 2026-05-25 7:48 ` Christoph Hellwig
0 siblings, 0 replies; 22+ messages in thread
From: Christoph Hellwig @ 2026-05-25 7:48 UTC (permalink / raw)
To: Anand Jain
Cc: Christoph Hellwig, fstests, zlang, Zorro Lang, linux-btrfs,
linux-ext4, linux-xfs, linux-f2fs, amir73il, Anand Jain
On Mon, May 25, 2026 at 03:31:59PM +0800, Anand Jain wrote:
> > and a comment explaining the helper. Also I think it should
> > be named to describe what it does, not what you use for, i.e.
> > something about changing the metadata uuid.
> >
>
> Agreed. I'll update it. Is _change_metadata_uuid() a better name?
Sounds better to me at least.
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v5 10/10] fstests: test UUID consistency for clones with metadata_uuid
2026-05-21 12:54 [PATCH v5 0/10] fstests: add test coverage for cloned filesystem ids Anand Jain
` (8 preceding siblings ...)
2026-05-21 12:54 ` [PATCH v5 09/10] fstests: add pre_clone_tune_uuid() healper Anand Jain
@ 2026-05-21 12:55 ` Anand Jain
9 siblings, 0 replies; 22+ messages in thread
From: Anand Jain @ 2026-05-21 12:55 UTC (permalink / raw)
To: fstests
Cc: linux-btrfs, linux-ext4, linux-xfs, linux-f2fs, amir73il, zlang,
hch
Btrfs and xfs uses the metadata_uuid superblock feature to change the
on-disk UUID without rewriting every block header. This patch adds a
sanity check to ensure UUID consistency when a filesystem with
metadata_uuid enabled is cloned.
Signed-off-by: Anand Jain <asj@kernel.org>
---
tests/generic/806 | 78 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/806.out | 19 +++++++++++
2 files changed, 97 insertions(+)
create mode 100644 tests/generic/806
create mode 100644 tests/generic/806.out
diff --git a/tests/generic/806 b/tests/generic/806
new file mode 100644
index 000000000000..222d138976d3
--- /dev/null
+++ b/tests/generic/806
@@ -0,0 +1,78 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Anand Jain <asj@kernel.org>. All Rights Reserved.
+#
+# FS QA Test 806
+#
+# Verify that the cloned filesystem UUID remains consistent, even when the
+# `metadata_uuid` feature is enabled.
+#
+
+. ./common/preamble
+. ./common/filter
+
+_begin_fstest auto quick mount clone
+
+_require_test
+_require_block_device $TEST_DEV
+_require_loop
+
+_cleanup()
+{
+ cd /
+ rm -r -f $tmp.*
+ umount $mnt1 $mnt2 2>/dev/null
+ _loop_image_destroy "${devs[@]}" 2> /dev/null
+}
+
+filter_pool()
+{
+ sed -e "s|${devs[0]}|DEV1|g" -e "s|${mnt1}|MNT1|g" \
+ -e "s|${devs[1]}|DEV2|g" -e "s|${mnt2}|MNT2|g" | _filter_spaces
+}
+
+print_info()
+{
+ local mntpt=$1
+ local tgt=$(findmnt -no SOURCE $mntpt)
+ local fsuuid=$(blkid -s UUID -o value $tgt)
+
+ echo "mntpt=$mntpt tgt=$tgt fsuuid=$fsuuid" >> $seqres.full
+ echo
+ findmnt -o SOURCE,TARGET,UUID "$tgt" | tail -n +2 | \
+ sed -e "s/${fsuuid}/FSUUID/g" | filter_pool
+ awk -v dev="$tgt" '$1 == dev { print $1, $2 }' /proc/self/mounts | \
+ filter_pool
+ df --all --output=source,target "$tgt" | tail -n +2 | filter_pool
+}
+
+devs=()
+_loop_image_create_clone devs pre_clone_tune_uuid
+mkdir -p $TEST_DIR/$seq
+mnt1=$TEST_DIR/$seq/mnt1
+mnt2=$TEST_DIR/$seq/mnt2
+mkdir -p $mnt1
+mkdir -p $mnt2
+
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[0]} $mnt1 || \
+ _fail "Failed to mount dev1"
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[1]} $mnt2 || \
+ _fail "Failed to mount dev2"
+
+print_info $mnt1
+print_info $mnt2
+
+echo
+echo "**** mount cycle ****"
+_unmount $mnt1
+_unmount $mnt2
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[1]} $mnt2 || \
+ _fail "Failed to mount dev2"
+_mount $(_common_dev_mount_options) $(_clone_mount_option) ${devs[0]} $mnt1 || \
+ _fail "Failed to mount dev1"
+
+print_info $mnt1
+print_info $mnt2
+
+status=0
+exit
diff --git a/tests/generic/806.out b/tests/generic/806.out
new file mode 100644
index 000000000000..7315e791ba51
--- /dev/null
+++ b/tests/generic/806.out
@@ -0,0 +1,19 @@
+QA output created by 806
+
+DEV1 MNT1 FSUUID
+DEV1 MNT1
+DEV1 MNT1
+
+DEV2 MNT2 FSUUID
+DEV2 MNT2
+DEV2 MNT2
+
+**** mount cycle ****
+
+DEV1 MNT1 FSUUID
+DEV1 MNT1
+DEV1 MNT1
+
+DEV2 MNT2 FSUUID
+DEV2 MNT2
+DEV2 MNT2
--
2.43.0
^ permalink raw reply related [flat|nested] 22+ messages in thread