diff mbox series

[v2,2/2] generic: test mount fails on physical device with configured dm volume

Message ID 1b07e16433faa5c149d2f6c0693fbcc656561aad.1710599671.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series fstests: new test cases for generic group | expand

Commit Message

Anand Jain March 16, 2024, 5:02 p.m. UTC
When a dm Flakey device is configured, (or similar dm where both physical
and dm devices are accessible) we have access to both the physical device
and the dm flakey device, ensure that the physical device mount fails.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
Remove redirect for rm
Add _require_test
Add _filter_error_mount
Change log - make it more sound generic with a dm device
Add quick group

 tests/generic/741     | 60 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/741.out |  3 +++
 2 files changed, 63 insertions(+)
 create mode 100755 tests/generic/741
 create mode 100644 tests/generic/741.out

Comments

Anand Jain March 24, 2024, 8:49 a.m. UTC | #1
On 3/16/24 22:32, Anand Jain wrote:
> When a dm Flakey device is configured, (or similar dm where both physical
> and dm devices are accessible) we have access to both the physical device
> and the dm flakey device, ensure that the physical device mount fails.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> Remove redirect for rm
> Add _require_test
> Add _filter_error_mount
> Change log - make it more sound generic with a dm device
> Add quick group
> 
  Thanks for the review comments; they have been accepted in this patch.
  This patch is now applied for the upcoming PR.

Thanks, Anand

>   tests/generic/741     | 60 +++++++++++++++++++++++++++++++++++++++++++
>   tests/generic/741.out |  3 +++
>   2 files changed, 63 insertions(+)
>   create mode 100755 tests/generic/741
>   create mode 100644 tests/generic/741.out
> 
> diff --git a/tests/generic/741 b/tests/generic/741
> new file mode 100755
> index 000000000000..f8f9a7be7619
> --- /dev/null
> +++ b/tests/generic/741
> @@ -0,0 +1,60 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2024 Oracle.  All Rights Reserved.
> +#
> +# FS QA Test 741
> +#
> +# Attempt to mount both the DM physical device and the DM flakey device.
> +# Verify the returned error message.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick volume tempfsid
> +
> +# Override the default cleanup function.
> +_cleanup()
> +{
> +	umount $extra_mnt &> /dev/null
> +	rm -rf $extra_mnt
> +	_unmount_flakey
> +	_cleanup_flakey
> +	cd /
> +	rm -r -f $tmp.*
> +}
> +
> +# Import common functions.
> +. ./common/filter
> +. ./common/dmflakey
> +
> +# real QA test starts here
> +_supported_fs generic
> +_require_test
> +_require_scratch
> +_require_dm_target flakey
> +
> +[ "$FSTYP" = "btrfs" ] && _fixed_by_kernel_commit XXXXXXXXXXXX \
> +			"btrfs: return accurate error code on open failure"
> +
> +_scratch_mkfs >> $seqres.full
> +_init_flakey
> +_mount_flakey
> +
> +extra_mnt=$TEST_DIR/extra_mnt
> +rm -rf $extra_mnt
> +mkdir -p $extra_mnt
> +
> +# Mount must fail because the physical device has a dm created on it.
> +# Filters alter the return code of the mount.
> +_mount $SCRATCH_DEV $extra_mnt 2>&1 | \
> +			_filter_testdir_and_scratch | _filter_error_mount
> +
> +# Try again with flakey unmounted, must fail.
> +_unmount_flakey
> +_mount $SCRATCH_DEV $extra_mnt 2>&1 | \
> +			_filter_testdir_and_scratch | _filter_error_mount
> +
> +# Removing dm should make mount successful.
> +_cleanup_flakey
> +_scratch_mount
> +
> +status=0
> +exit
> diff --git a/tests/generic/741.out b/tests/generic/741.out
> new file mode 100644
> index 000000000000..b694f5fad6b8
> --- /dev/null
> +++ b/tests/generic/741.out
> @@ -0,0 +1,3 @@
> +QA output created by 741
> +mount: TEST_DIR/extra_mnt: SCRATCH_DEV already mounted or mount point busy
> +mount: TEST_DIR/extra_mnt: SCRATCH_DEV already mounted or mount point busy
diff mbox series

Patch

diff --git a/tests/generic/741 b/tests/generic/741
new file mode 100755
index 000000000000..f8f9a7be7619
--- /dev/null
+++ b/tests/generic/741
@@ -0,0 +1,60 @@ 
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oracle.  All Rights Reserved.
+#
+# FS QA Test 741
+#
+# Attempt to mount both the DM physical device and the DM flakey device.
+# Verify the returned error message.
+#
+. ./common/preamble
+_begin_fstest auto quick volume tempfsid
+
+# Override the default cleanup function.
+_cleanup()
+{
+	umount $extra_mnt &> /dev/null
+	rm -rf $extra_mnt
+	_unmount_flakey
+	_cleanup_flakey
+	cd /
+	rm -r -f $tmp.*
+}
+
+# Import common functions.
+. ./common/filter
+. ./common/dmflakey
+
+# real QA test starts here
+_supported_fs generic
+_require_test
+_require_scratch
+_require_dm_target flakey
+
+[ "$FSTYP" = "btrfs" ] && _fixed_by_kernel_commit XXXXXXXXXXXX \
+			"btrfs: return accurate error code on open failure"
+
+_scratch_mkfs >> $seqres.full
+_init_flakey
+_mount_flakey
+
+extra_mnt=$TEST_DIR/extra_mnt
+rm -rf $extra_mnt
+mkdir -p $extra_mnt
+
+# Mount must fail because the physical device has a dm created on it.
+# Filters alter the return code of the mount.
+_mount $SCRATCH_DEV $extra_mnt 2>&1 | \
+			_filter_testdir_and_scratch | _filter_error_mount
+
+# Try again with flakey unmounted, must fail.
+_unmount_flakey
+_mount $SCRATCH_DEV $extra_mnt 2>&1 | \
+			_filter_testdir_and_scratch | _filter_error_mount
+
+# Removing dm should make mount successful.
+_cleanup_flakey
+_scratch_mount
+
+status=0
+exit
diff --git a/tests/generic/741.out b/tests/generic/741.out
new file mode 100644
index 000000000000..b694f5fad6b8
--- /dev/null
+++ b/tests/generic/741.out
@@ -0,0 +1,3 @@ 
+QA output created by 741
+mount: TEST_DIR/extra_mnt: SCRATCH_DEV already mounted or mount point busy
+mount: TEST_DIR/extra_mnt: SCRATCH_DEV already mounted or mount point busy