Skip to contentSkip to conversation

blktests: add test to cover umount one deleted disk

PATCH Superseded Ming Lei 1 participant 1 message Feb 8, 2023 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 blktests: add test to cover umount one deleted disk

From: Ming Lei <[email protected]>

disk can be disappear any time because of error handling, when it is usually being mounted. Make sure umount can be done successfully after disk deleting is done from error handling.

---
 tests/block/032 | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100755 tests/block/032
tests/block/032 new file +35 -0
new file mode 100755
index 0000000..b07b7ab
@@ -0,0 +1,35 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2023 Ming Lei
+#
+# Test umount after deleting disk. Removes a device while the disk
+# is still mounted.
+
+. tests/block/rc
+. common/xfs
+. common/scsi_debug
+
+DESCRIPTION="remove one mounted device"
+QUICK=1
+
+requires() {
+	_have_xfs && _have_scsi_debug
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	if ! _init_scsi_debug dev_size_mb=300; then
+		return 1
+	fi
+
+	mkdir -p "${TMPDIR}/mnt"
+	_xfs_mkfs_and_mount "/dev/${SCSI_DEBUG_DEVICES[0]}" "${TMPDIR}/mnt" > /dev/null 2>&1
+	echo 1 > "/sys/block/${SCSI_DEBUG_DEVICES[0]}/device/delete"
+	sleep 2
+	umount "${TMPDIR}/mnt"
+
+	_exit_scsi_debug
+
+	echo "Test complete"
+}
Signature · 1 line
2.38.1