Verify how findmnt, df (libblkid) resolve device paths when multiple block devices share the same FSUUID. Signed-off-by: Anand Jain --- tests/generic/903 | 71 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/903.out | 6 ++++ 2 files changed, 77 insertions(+) create mode 100644 tests/generic/903 create mode 100644 tests/generic/903.out diff --git a/tests/generic/903 b/tests/generic/903 new file mode 100644 index 000000000000..d8aeba691fd4 --- /dev/null +++ b/tests/generic/903 @@ -0,0 +1,71 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2026 Anand Jain . All Rights Reserved. +# +# FS QA Test No. 903 +# Check if the mountinfo based findmnt would resolve to the common uuid +# as per the blkid (libblkid based). + +. ./common/preamble +. ./common/filter + +_begin_fstest auto quick mount tempfsid + +_require_test +_require_loop + +_cleanup() +{ + cd / + rm -r -f $tmp.* + umount $mnt1 $mnt2 2>/dev/null + _destroy_cloned_loop_devs "${devs[@]}" 2> /dev/null +} + +# Normalize pool devices and mount points names +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 +} + +rm -rf $TEST_DIR/$seq 2>/dev/null +mkdir -p $TEST_DIR/$seq +# Setup base loop device and its clone +devs=() +_create_cloned_loop_devs devs +mnt1=$TEST_DIR/$seq/mnt1 +mnt2=$TEST_DIR/$seq/mnt2 +mkdir -p $mnt1 +mkdir -p $mnt2 + +# Get the uuid from the source device +fsuuid=$(blkid -s UUID -o value ${devs[0]}) + +# Mount both identical UUID filesystems simultaneously +_mount $(_common_dev_mount_options) $(_clone_mount_options) ${devs[0]} $mnt1 || \ + _fail "Failed to mount dev1" +_mount $(_common_dev_mount_options) $(_clone_mount_options) ${devs[1]} $mnt2 || \ + _fail "Failed to mount dev2" + +findmnt --noheadings -o SOURCE,TARGET,UUID "${devs[0]}" | \ + sed -e "s/${fsuuid}/FSUUID/g" | filter_pool +findmnt --noheadings -o SOURCE,TARGET,UUID "${devs[1]}" | \ + sed -e "s/${fsuuid}/FSUUID/g" | filter_pool + +# Btrfs assigned a random uuid for the clone fs before the fix. +# Cycle mounts and reverse the initialization (source and clone fs) order. +echo "**** mount cycle ****" +_unmount $mnt1 +_unmount $mnt2 +_mount $(_common_dev_mount_options) $(_clone_mount_options) ${devs[1]} $mnt2 || \ + _fail "Failed to mount dev2" +_mount $(_common_dev_mount_options) $(_clone_mount_options) ${devs[0]} $mnt1 || \ + _fail "Failed to mount dev1" + +findmnt --noheadings -o SOURCE,TARGET,UUID "${devs[0]}" | \ + sed -e "s/${fsuuid}/FSUUID/g" | filter_pool +findmnt --noheadings -o SOURCE,TARGET,UUID "${devs[1]}" | \ + sed -e "s/${fsuuid}/FSUUID/g" | filter_pool + +_exit 0 diff --git a/tests/generic/903.out b/tests/generic/903.out new file mode 100644 index 000000000000..7683506e1c94 --- /dev/null +++ b/tests/generic/903.out @@ -0,0 +1,6 @@ +QA output created by 903 +DEV1 MNT1 FSUUID +DEV2 MNT2 FSUUID +**** mount cycle **** +DEV1 MNT1 FSUUID +DEV2 MNT2 FSUUID -- 2.43.0