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

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



From: Dave Chinner <dchinner@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 common/filter | 8 +++++++-
 tests/xfs/154 | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

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"
-- 
2.45.2





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux