All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] fstests: new testcase to verify show_devname.
@ 2025-05-20  8:28 Anand Jain
  2025-05-20  8:28 ` [PATCH 1/2] fstests: new test case to verify show_devname() device path Anand Jain
  2025-05-20  8:28 ` [PATCH 2/2] fstests: btrfs: new test: show_devname() on multi-device volumes Anand Jain
  0 siblings, 2 replies; 3+ messages in thread
From: Anand Jain @ 2025-05-20  8:28 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

Mismatch causes mount -a (UUID) to fail with -EBUSY in libmount 2.37.4.
In libmount 2.40.2 with Btrfs, it shows 'successfully mounted' instead
of 'already mounted', kernel without fix.

Anand Jain (2):
  fstests: new test case to verify show_devname() device path
  fstests: btrfs: new test: show_devname() on multi-device volumes

 tests/btrfs/329       | 107 ++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/329.out   |  19 ++++++++
 tests/generic/765     |  74 +++++++++++++++++++++++++++++
 tests/generic/765.out |   6 +++
 4 files changed, 206 insertions(+)
 create mode 100755 tests/btrfs/329
 create mode 100644 tests/btrfs/329.out
 create mode 100755 tests/generic/765
 create mode 100644 tests/generic/765.out

-- 
2.49.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] fstests: new test case to verify show_devname() device path
  2025-05-20  8:28 [PATCH 0/2] fstests: new testcase to verify show_devname Anand Jain
@ 2025-05-20  8:28 ` Anand Jain
  2025-05-20  8:28 ` [PATCH 2/2] fstests: btrfs: new test: show_devname() on multi-device volumes Anand Jain
  1 sibling, 0 replies; 3+ messages in thread
From: Anand Jain @ 2025-05-20  8:28 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

If the device path under /proc/self/mounts does not match the path shown
by findmnt --uuid, commands like mount -a may fail to recognize that the
device is already mounted and attempt to mount it again. This test case
verifies that the two paths match.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tests/generic/765     | 74 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/765.out |  6 ++++
 2 files changed, 80 insertions(+)
 create mode 100755 tests/generic/765
 create mode 100644 tests/generic/765.out

diff --git a/tests/generic/765 b/tests/generic/765
new file mode 100755
index 000000000000..9d4b69344678
--- /dev/null
+++ b/tests/generic/765
@@ -0,0 +1,74 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Oracle.  All Rights Reserved.
+#
+# FS QA Test 765
+#
+# Test if the device paths are compatible with systemd udev tools like
+# mount -a and findmnt.
+# Provide the device dm path to the mount command and verify that it is
+# correctly resolved to the mapper path in the kernel.
+#
+. ./common/preamble
+_begin_fstest auto
+
+node="fstests_${seq}"
+
+_cleanup()
+{
+	cd /
+	rm -r -f $tmp.*
+
+	sed -i "\|[[:space:]]$SCRATCH_MNT[[:space:]]|d" /etc/fstab
+	_systemd_installed && _systemd_reload
+
+	_unmount $SCRATCH_MNT > /dev/null 2>&1
+	udevadm control --start-exec-queue
+	_dmsetup_remove $node
+}
+
+. ./common/systemd
+. ./common/filter
+
+_require_scratch
+_require_block_device $SCRATCH_DEV
+_require_dm_target linear
+
+[ "$FSTYP" = btrfs ] && _fixed_by_kernel_commit XXXXXXXXXXXX \
+		"btrfs: pass device path update from mount thread"
+
+filter_mapper()
+{
+	sed -e "s,\B$scratch_mapper_dev,MAPPER_PATH,g" |\
+		sed -e "s,/dev/dm-[^ ]*,DM_PATH,g" |\
+		_filter_scratch
+}
+
+#size doesn't matter just create it to the device size
+sectors=$(blockdev --getsz $SCRATCH_DEV)
+table="0 $sectors linear  $SCRATCH_DEV 0"
+_dmsetup_create $node --table "$table" || _fail "setup dm device failed"
+
+scratch_mapper_dev=/dev/mapper/$node
+scratch_dm_dev=$(realpath ${scratch_mapper_dev})
+
+# Block external triggers that alter the device path inside the kernel,
+# they are unreliable.
+udevadm control --stop-exec-queue
+_mkfs_dev $scratch_dm_dev
+
+# mount resolves dm path to its mapper path
+_mount --verbose $scratch_dm_dev $SCRATCH_MNT | filter_mapper
+
+fsid=$(findmnt -n -o UUID ${scratch_dm_dev})
+blkid --uuid ${fsid} | filter_mapper
+findmnt --source UUID=${fsid} --noheadings --output SOURCE | filter_mapper
+cat /proc/self/mounts | grep ${SCRATCH_MNT} | \
+				$AWK_PROG '{print $1" "$2}' | filter_mapper
+
+echo "UUID=${fsid} ${SCRATCH_MNT} $FSTYP defaults 0 0" >> /etc/fstab
+_systemd_installed && _systemd_reload
+_mount --verbose -a | grep $SCRATCH_MNT | filter_mapper
+
+status=0
+exit
diff --git a/tests/generic/765.out b/tests/generic/765.out
new file mode 100644
index 000000000000..62abea736f4d
--- /dev/null
+++ b/tests/generic/765.out
@@ -0,0 +1,6 @@
+QA output created by 765
+mount: MAPPER_PATH mounted on SCRATCH_MNT.
+MAPPER_PATH
+MAPPER_PATH
+MAPPER_PATH SCRATCH_MNT
+SCRATCH_MNT             : already mounted
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] fstests: btrfs: new test: show_devname() on multi-device volumes
  2025-05-20  8:28 [PATCH 0/2] fstests: new testcase to verify show_devname Anand Jain
  2025-05-20  8:28 ` [PATCH 1/2] fstests: new test case to verify show_devname() device path Anand Jain
@ 2025-05-20  8:28 ` Anand Jain
  1 sibling, 0 replies; 3+ messages in thread
From: Anand Jain @ 2025-05-20  8:28 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

If the device path under /proc/self/mounts does not match the path shown
by findmnt --uuid, commands like mount -a may fail to recognize that the
device is already mounted and attempt to mount it again. This test case
verifies that the two paths match.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tests/btrfs/329     | 107 ++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/329.out |  19 ++++++++
 2 files changed, 126 insertions(+)
 create mode 100755 tests/btrfs/329
 create mode 100644 tests/btrfs/329.out

diff --git a/tests/btrfs/329 b/tests/btrfs/329
new file mode 100755
index 000000000000..c73e0175c6a4
--- /dev/null
+++ b/tests/btrfs/329
@@ -0,0 +1,107 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Oracle.  All Rights Reserved.
+#
+# FS QA Test 329
+#
+# Test that show_devname() returns a device path that matches findmnt,
+# ensuring that mount -a works correctly for multi-device Btrfs filesystems.
+
+. ./common/preamble
+_begin_fstest auto volume
+
+node="fstests_${seq}"
+
+_cleanup()
+{
+	cd /
+	rm -r -f $tmp.*
+
+	clean_per_iteration
+
+	udevadm control --start-exec-queue
+	_dmsetup_remove $node
+}
+
+. ./common/systemd
+. ./common/filter
+
+_require_scratch_dev_pool 2
+_require_btrfs_forget_or_module_loadable
+_require_block_device $SCRATCH_DEV
+_require_dm_target linear
+
+_fixed_by_kernel_commit XXXXXXXXXXXX \
+	"btrfs: pass device path update from mount thread"
+
+_scratch_dev_pool_get 3
+scratch_devs=($SCRATCH_DEV_POOL)
+#size doesn't matter just create it to the device size
+sectors=$(blockdev --getsz ${scratch_devs[0]})
+table="0 $sectors linear  ${scratch_devs[0]} 0"
+_dmsetup_create $node --table "$table" || _fail "setup dm device failed"
+scratch_mapper_dev=/dev/mapper/$node
+scratch_dm_dev=$(realpath ${scratch_mapper_dev})
+
+clean_per_iteration()
+{
+	_unmount $SCRATCH_MNT > /dev/null 2>&1
+	sed -i "\|[[:space:]]$SCRATCH_MNT[[:space:]]|d" /etc/fstab
+	_systemd_installed && _systemd_reload
+}
+
+filter_mapper()
+{
+	sed -e "s,\B$scratch_mapper_dev,MAPPER_PATH,g" |\
+		sed -e "s,/dev/dm-[^ ]*,DM_PATH,g" |\
+		_filter_scratch_pool
+}
+
+test_dev_path()
+{
+	clean_per_iteration
+	_btrfs_forget_or_module_reload
+
+	echo --- ${devs[@]} ---- | filter_mapper
+	_mkfs_dev "${devs[0]} ${devs[1]}"
+
+	# mount resolves dm path to its mapper path
+	_mount --verbose ${devs[0]} -o device=${devs[1]} $SCRATCH_MNT | \
+								filter_mapper
+
+	fsid=$(findmnt -n -o UUID ${devs[0]})
+	blkid --uuid ${fsid} | filter_mapper
+	findmnt --source UUID=${fsid} --noheadings --output SOURCE | \
+								filter_mapper
+	cat /proc/self/mounts | grep ${SCRATCH_MNT} | \
+				$AWK_PROG '{print $1" "$2}' | filter_mapper
+
+	echo "UUID=${fsid} ${SCRATCH_MNT} $FSTYP defaults 0 0" >> /etc/fstab
+	_systemd_installed && _systemd_reload
+
+	# The error output from `mount -a --verbose` varies.
+        # In libmount 2.37.4, the `mount -a` command will fail with -EBUSY.
+        # In libmount 2.40.2, it will report "Successfully mounted" instead
+        # of "already mounted."
+	_mount --verbose -a | grep $SCRATCH_MNT | _filter_scratch
+}
+
+# Block external triggers such as (64-btrfs-dm.rules) that alter the device path
+# inside the kernel, they are unreliable.
+udevadm control --stop-exec-queue
+secnarios=(
+	"$scratch_dm_dev ${scratch_devs[1]}"
+	"${scratch_devs[2]} ${scratch_devs[1]}"
+	"${scratch_devs[1]} ${scratch_devs[2]}"
+)
+
+devs=()
+for devs_str in "${secnarios[@]}"; do
+	devs=($devs_str)
+	test_dev_path
+done
+udevadm control --start-exec-queue
+
+_scratch_dev_pool_put
+status=0
+exit
diff --git a/tests/btrfs/329.out b/tests/btrfs/329.out
new file mode 100644
index 000000000000..96891dcc68b4
--- /dev/null
+++ b/tests/btrfs/329.out
@@ -0,0 +1,19 @@
+QA output created by 329
+--- DM_PATH SCRATCH_DEV ----
+mount: MAPPER_PATH mounted on /mnt/scratch.
+MAPPER_PATH
+MAPPER_PATH
+MAPPER_PATH /mnt/scratch
+SCRATCH_MNT             : already mounted
+--- SCRATCH_DEV SCRATCH_DEV ----
+mount: SCRATCH_DEV mounted on /mnt/scratch.
+SCRATCH_DEV
+SCRATCH_DEV
+SCRATCH_DEV /mnt/scratch
+SCRATCH_MNT             : already mounted
+--- SCRATCH_DEV SCRATCH_DEV ----
+mount: SCRATCH_DEV mounted on /mnt/scratch.
+SCRATCH_DEV
+SCRATCH_DEV
+SCRATCH_DEV /mnt/scratch
+SCRATCH_MNT             : already mounted
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-20  8:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-20  8:28 [PATCH 0/2] fstests: new testcase to verify show_devname Anand Jain
2025-05-20  8:28 ` [PATCH 1/2] fstests: new test case to verify show_devname() device path Anand Jain
2025-05-20  8:28 ` [PATCH 2/2] fstests: btrfs: new test: show_devname() on multi-device volumes Anand Jain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.