Skip to contentSkip to conversation

fstests: add test coverage for cloned filesystem ids

PATCH Superseded Anand Jain 1 participant 10 messages Mar 21 Btrfs file system

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Anand Jain

author
#0 lore raw

v2 cover fstests: add test coverage for cloned filesystem ids

v2:
- Add new helper _require_nouuid_mountopt() inline with the btrfs and ext4 nouuid mount option, matching xfs.
- Clean up background processes in the _cleanup().
- Use fsnotifywait(1) instead of a local tool.
- Drop the use of SCRATCH_DEV_POOL for generic test cases to keep the existing xfs/ext4 test environment compatible for better coverage.

v1:
https://lore.kernel.org/fstests/[email protected]

Anand Jain (9):
fstests: add _require_nouuid_mountopt() helper
fstests: add _loop_image_create_clone() helper
fstests: add _clone_mount_option() helper
fstests: add test for inotify isolation on cloned devices
fstests: verify fanotify isolation on cloned filesystems
fstests: verify f_fsid for cloned filesystems
fstests: verify libblkid resolution of duplicate UUIDs
fstests: verify IMA isolation on cloned filesystems
fstests: verify exportfs file handles on cloned filesystems

 common/config         |   2 +
 common/rc             |  74 +++++++++++++++++++++++++++
 tests/generic/790     |  89 ++++++++++++++++++++++++++++++++
 tests/generic/790.out |   7 +++
 tests/generic/791     | 116 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/791.out |   7 +++
 tests/generic/792     |  62 ++++++++++++++++++++++
 tests/generic/792.out |   7 +++
 tests/generic/793     |  76 +++++++++++++++++++++++++++
 tests/generic/793.out |  19 +++++++
 tests/generic/794     | 103 +++++++++++++++++++++++++++++++++++++
 tests/generic/794.out |  10 ++++
 tests/generic/795     |  73 ++++++++++++++++++++++++++
 tests/generic/795.out |   2 +
 14 files changed, 647 insertions(+)
 create mode 100644 tests/generic/790
 create mode 100644 tests/generic/790.out
 create mode 100644 tests/generic/791
 create mode 100644 tests/generic/791.out
 create mode 100644 tests/generic/792
 create mode 100644 tests/generic/792.out
 create mode 100644 tests/generic/793
 create mode 100644 tests/generic/793.out
 create mode 100644 tests/generic/794
 create mode 100644 tests/generic/794.out
 create mode 100644 tests/generic/795
 create mode 100644 tests/generic/795.out
Signature · 1 line
2.43.0
author
#1 lore raw

PATCH v2 1/9 fstests: add _require_nouuid_mountopt() helper

Add a helper function to check if the filesystem supports the -o nouuid mount option. The helper attempts a scratch mount with -o nouuid and skips the test if the option is not supported by the filesystem.

---
 common/rc | 9 +++++++++
 1 file changed, 9 insertions(+)
common/rc +9 -0
index fd4ca9641822..9e3041beee2f 100644
@@ -6149,6 +6149,15 @@ _require_max_file_range_blocks()
 	esac
 }
 
+_require_nouuid_mountopt()
+{
+	_require_scratch
+	_scratch_mkfs > /dev/null 2>&1 || _notrun "mkfs failed"
+	_try_scratch_mount -o nouuid > /dev/null 2>&1 || \
+		_notrun "mount -o nouuid not supported by $FSTYP"
+	_scratch_unmount
+}
+
 ################################################################################
 # make sure this script returns success
 /bin/true
Signature · 1 line
2.43.0
author
#2 lore raw

PATCH v2 2/9 fstests: add _loop_image_create_clone() helper

In reply to Anand Jain

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.

---
 common/rc | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
common/rc +51 -0
index 9e3041beee2f..a8e6af5d1a1b 100644
@@ -1503,6 +1503,57 @@ _scratch_resvblks()
 	esac
 }
 
+_loop_image_create_clone()
+{
+	local -n _ret=$1
+	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
+	local temp_mnt=$TEST_DIR/${seq}_mnt
+
+	size=$((size * 1024 * 1024))
+	$XFS_IO_PROG -f -c "truncate $size" $img_file
+
+	case $FSTYP in
+	xfs)
+		_mkfs_dev "-s size=4096" $img_file
+		;;
+	*)
+		_mkfs_dev $img_file
+		;;
+	esac
+
+	case $FSTYP in
+	btrfs)
+		loop_devs=$(_create_loop_device $img_file)
+		mkdir -p $temp_mnt
+		_mount $loop_devs $temp_mnt
+		$BTRFS_UTIL_PROG subvolume create $temp_mnt/sv1 &> /dev/null
+		_unmount $temp_mnt
+		rm -r -f $temp_mnt
+		_destroy_loop_device $loop_devs
+		;;
+	*)
+		;;
+	esac
+
+	cp $img_file $img_file_clone
+
+	loop_devs=$(_create_loop_device $img_file)
+	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
Signature · 1 line
2.43.0
author
#3 lore raw

PATCH v2 3/9 fstests: add _clone_mount_option() helper

In reply to Anand Jain

Adds _clone_mount_option() helper function to handle filesystem-specific requirements for mounting cloned devices. Abstract the need for -o nouuid on XFS.

---
 common/rc | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
common/rc +14 -0
index a8e6af5d1a1b..7ff9815d88e3 100644
@@ -397,6 +397,20 @@ _scratch_mount_options()
 					$SCRATCH_DEV $SCRATCH_MNT
 }
 
+_clone_mount_option()
+{
+	local mount_opts=""
+
+	case "$FSTYP" in
+	ext4|xfs|btrfs)
+		mount_opts="-o nouuid"
+		;;
+	*)
+	esac
+
+	echo $mount_opts
+}
+
 _supports_filetype()
 {
 	local dir=$1
Signature · 1 line
2.43.0
author
#4 lore raw

PATCH v2 4/9 fstests: add test for inotify isolation on cloned devices

In reply to Anand Jain

Add a new test, to verify that the kernel correctly differentiates between two block devices sharing the same FSID/UUID.

---
 common/config         |  1 +
 tests/generic/790     | 89 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/790.out |  7 ++++
 3 files changed, 97 insertions(+)
 create mode 100644 tests/generic/790
 create mode 100644 tests/generic/790.out
common/config +1 -0
index 1420e35ddfee..c08f828575a2 100644
@@ -228,6 +228,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.
 #
tests/generic/790 new file +89 -0

89 lines not on this page · raw message

tests/generic/790.out new file +7 -0
new file mode 100644
index 000000000000..6fc08af59301
@@ -0,0 +1,7 @@
+QA output created by 790
+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.
Signature · 1 line
2.43.0
author
#5 lore raw

PATCH v2 5/9 fstests: verify fanotify isolation on cloned filesystems

In reply to Anand Jain

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.

---
 common/config         |   1 +
 tests/generic/791     | 116 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/791.out |   7 +++
 3 files changed, 124 insertions(+)
 create mode 100644 tests/generic/791
 create mode 100644 tests/generic/791.out
common/config +1 -0
index c08f828575a2..73a2a91df9f9 100644
@@ -229,6 +229,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.
 #
tests/generic/791 new file +116 -0

116 lines not on this page · raw message

tests/generic/791.out new file +7 -0
new file mode 100644
index 000000000000..50e494647388
@@ -0,0 +1,7 @@
+QA output created by 791
+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
Signature · 1 line
2.43.0
author
#6 lore raw

PATCH v2 6/9 fstests: verify f_fsid for cloned filesystems

In reply to Anand Jain

Verify that the cloned filesystem provides an f_fsid that is persistent across mount cycles, yet unique from the original filesystem's f_fsid.

---
 tests/generic/792     | 62 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/792.out |  7 +++++
 2 files changed, 69 insertions(+)
 create mode 100644 tests/generic/792
 create mode 100644 tests/generic/792.out
tests/generic/792 new file +62 -0
new file mode 100644
index 000000000000..7716928cb7d2
@@ -0,0 +1,62 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Anand Jain <[email protected]>.  All Rights Reserved.
+#
+# FS QA Test 792
+# Verify f_fsid and s_uuid of cloned filesystems across mount cycle.
+
+. ./common/preamble
+
+_begin_fstest auto quick mount clone
+
+_require_test
+_require_loop
+_require_nouuid_mountopt
+
+[ "$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
tests/generic/792.out new file +7 -0
new file mode 100644
index 000000000000..27ecbce2225e
@@ -0,0 +1,7 @@
+QA output created by 792
+**** fsid initially ****
+FSID_SCRATCH
+FSID_CLONE
+**** fsid after mount cycle ****
+FSID_SCRATCH
+FSID_CLONE
Signature · 1 line
2.43.0
author
#7 lore raw

PATCH v2 7/9 fstests: verify libblkid resolution of duplicate UUIDs

In reply to Anand Jain

Verify how findmnt, df (libblkid) resolve device paths when multiple block devices share the same FSUUID.

---
 tests/generic/793     | 76 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/793.out | 19 +++++++++++
 2 files changed, 95 insertions(+)
 create mode 100644 tests/generic/793
 create mode 100644 tests/generic/793.out
tests/generic/793 new file +76 -0
new file mode 100644
index 000000000000..fa5d8a6fe642
@@ -0,0 +1,76 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Anand Jain <[email protected]>.  All Rights Reserved.
+#
+# FS QA Test 793
+# 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_loop
+_require_nouuid_mountopt
+
+_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
tests/generic/793.out new file +19 -0
new file mode 100644
index 000000000000..53cb4d850d93
@@ -0,0 +1,19 @@
+QA output created by 793
+
+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
Signature · 1 line
2.43.0
author
#8 lore raw

PATCH v2 8/9 fstests: verify IMA isolation on cloned filesystems

In reply to Anand Jain

Add testcase to verify IMA measurement isolation when multiple devices share the same FSUUID.

---
 tests/generic/794     | 103 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/794.out |  10 ++++
 2 files changed, 113 insertions(+)
 create mode 100644 tests/generic/794
 create mode 100644 tests/generic/794.out
tests/generic/794 new file +103 -0
new file mode 100644
index 000000000000..391563b84cfc
@@ -0,0 +1,103 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Anand Jain <[email protected]>.  All Rights Reserved.
+#
+# FS QA Test 794
+# 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_loop
+_require_nouuid_mountopt
+
+[ "$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
tests/generic/794.out new file +10 -0
new file mode 100644
index 000000000000..492f8b0b0bec
@@ -0,0 +1,10 @@
+QA output created by 794
+MNT1 1
+MNT1/FOOBAR_FILE
+MNT2 0
+MNT2/FOOBAR_FILE
+mount cycle
+MNT1 0
+MNT1/FOOBAR_FILE
+MNT2 0
+MNT2/FOOBAR_FILE
Signature · 1 line
2.43.0
author
#9 lore raw

PATCH v2 9/9 fstests: verify exportfs file handles on cloned filesystems

In reply to Anand Jain

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.

---
 tests/generic/795     | 73 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/795.out |  2 ++
 2 files changed, 75 insertions(+)
 create mode 100644 tests/generic/795
 create mode 100644 tests/generic/795.out
tests/generic/795 new file +73 -0
new file mode 100644
index 000000000000..e7ba146350ee
@@ -0,0 +1,73 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Anand Jain <[email protected]>.  All Rights Reserved.
+#
+# FS QA Test No. 795
+
+. ./common/preamble
+
+_begin_fstest auto quick exportfs clone
+
+_require_test
+_require_exportfs
+_require_loop
+_require_nouuid_mountopt
+_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
tests/generic/795.out new file +2 -0
new file mode 100644
index 000000000000..774fe7487d65
@@ -0,0 +1,2 @@
+QA output created by 795
+test_file_handles after cycle mount
Signature · 1 line
2.43.0