diff mbox series

[27/40] filter: handle mount errors from CONFIG_BLK_DEV_WRITE_MOUNTED=y

Message ID 20241127045403.3665299-28-david@fromorbit.com (mailing list archive)
State New
Headers show
Series fstests: concurrent test execution | expand

Commit Message

Dave Chinner Nov. 27, 2024, 4:51 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

Kernels post 6.x may have CONFIG_BLK_DEV_WRITE_MOUNTED=y which
prevents mount from opening the block device on a mounted
filesystem. This results in an error such as:

mount: <dev>: Can't open blockdev

which is not the error that callers of _filter_error_mount() are
looking for. It is, however, a direct result of the test trying
to mount an alreayd mounted filesystem, so it is reflecting the same
error case. Hence this mismatch in errors should not fail the test.

Catch this mount error and convert it to the expected
"already mounted" error for the tests that exercise this behaviour.

There is also a minor test change here to push mount failure
information to $seqres.full in the cases where mount errors occur.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 common/filter | 8 +++++++-
 tests/xfs/154 | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/common/filter b/common/filter
index 36d51bd95..6a509d8b5 100644
--- a/common/filter
+++ b/common/filter
@@ -430,6 +430,10 @@  _filter_ro_mount() {
 # v2.38 and later:
 # dmesg(1) may have more information after failed mount mount system call
 #
+# Kernels post 6.x may have CONFIG_BLK_DEV_WRITE_MOUNTED=y which prevents mount
+# from opening the block device on a mounted filesytsem:
+# mount: <dev>: Can't open blockdev
+#
 # This is also true for ESTALE error. So let's remove all the changing parts
 # and keep the 'prior to v2.21' format:
 # mount: Structure needs cleaning
@@ -437,7 +441,9 @@  _filter_ro_mount() {
 _filter_error_mount()
 {
 	grep -v "dmesg(1) may have more information after failed mount" | \
-		sed -e "s/mount:\(.*failed:\)/mount:/" | _filter_ending_dot
+		sed -e "s/mount:\(.*failed:\)/mount:/" \
+		    -e "s/mount: SCRATCH_DEV: Can't open blockdev/mount: TEST_DIR\/extra_mnt: SCRATCH_DEV already mounted or mount point busy/" |\
+		    _filter_ending_dot
 }
 
 # Similar to _filter_error_mount, filter a busy mount output.
diff --git a/tests/xfs/154 b/tests/xfs/154
index e8494bbd6..674d06784 100755
--- a/tests/xfs/154
+++ b/tests/xfs/154
@@ -46,6 +46,7 @@  test $? -eq 137 || echo "repair should have been killed??"
 _check_scratch_xfs_features NEEDSREPAIR
 _try_scratch_mount &> $tmp.mount
 res=$?
+cat $tmp.mount >> $seqres.full
 _filter_error_mount < $tmp.mount
 if [ $res -eq 0 ]; then
 	echo "Should not be able to mount after needsrepair crash"