linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH blktests] dm/002: repeat dmsetup remove command on failure with EBUSY
@ 2024-07-09 12:44 Shin'ichiro Kawasaki
  2024-07-10 13:43 ` Bryan Gurney
  0 siblings, 1 reply; 6+ messages in thread
From: Shin'ichiro Kawasaki @ 2024-07-09 12:44 UTC (permalink / raw)
  To: linux-block; +Cc: Bryan Gurney, Shin'ichiro Kawasaki

The test case dm/002 rarely fails with the message below:

dm/002 => nvme0n1 (dm-dust general functionality test)       [failed]
    runtime  0.204s  ...  0.174s
    --- tests/dm/002.out        2024-06-14 14:37:40.480794693 +0900
    +++ /home/shin/Blktests/blktests/results/nvme0n1/dm/002.out.bad     2024-06-14 21:38:18.588976499 +0900
    @@ -7,4 +7,6 @@
     countbadblocks: 0 badblock(s) found
     countbadblocks: 3 badblock(s) found
     countbadblocks: 0 badblock(s) found
    +device-mapper: remove ioctl on dust1  failed: Device or resource busy
    +Command failed.
     Test complete
modprobe: FATAL: Module dm_dust is in use.

This failure happens at "dmsetup remove" command, when the previous
operation on the dm device is still ongoing. In this case,
dm_open_count() is non-zero, then IOCTL for device remove fails and
EBUSY is returned.

To avoid the failure, retry the "dmsetup remove" command when it fails
with EBUSY. Introduce the helper function _dm_remove for this purpose.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
This patch addresses a failure found during the debug work for another
dm/002 failure [1].

[1] https://lore.kernel.org/linux-block/42ecobcsduvlqh77iavjj2p3ewdh7u4opdz4xruauz4u5ddljz@yr7ye4fq72tr/

 tests/dm/002 |  2 +-
 tests/dm/rc  | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/tests/dm/002 b/tests/dm/002
index fae3986..8ae8438 100755
--- a/tests/dm/002
+++ b/tests/dm/002
@@ -37,7 +37,7 @@ test_device() {
 	sync
 	dmsetup message dust1 0 countbadblocks
 	sync
-	dmsetup remove dust1
+	_dm_remove dust1
 
 	echo "Test complete"
 }
diff --git a/tests/dm/rc b/tests/dm/rc
index 0486db0..21a35f6 100644
--- a/tests/dm/rc
+++ b/tests/dm/rc
@@ -11,3 +11,26 @@ group_requires() {
 	_have_program dmsetup
 	_have_driver dm-mod
 }
+
+_dm_remove() {
+	local dm_dev=${1}
+	local i out
+
+	# Retry dmsetup remove command in case it fails with EBUSY because of
+	# non-zero dm open count.
+	for ((i = 0; i < 10; i++)); do
+		if out=$(dmsetup remove "${dm_dev}" 2>&1); then
+			break
+		fi
+		echo "$out" >> "$FULL"
+		if ! [[ $out =~ "Device or resource busy" ]]; then
+			echo "$out"
+			break
+		fi
+		sleep 1
+	done
+	if ((i == 10)); then
+		echo "dmsetup remove failed with EBUSY"
+	fi
+
+}
-- 
2.45.2


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

end of thread, other threads:[~2024-07-18 23:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-09 12:44 [PATCH blktests] dm/002: repeat dmsetup remove command on failure with EBUSY Shin'ichiro Kawasaki
2024-07-10 13:43 ` Bryan Gurney
2024-07-10 15:46   ` Mikulas Patocka
2024-07-11 10:39     ` Shinichiro Kawasaki
2024-07-11 17:59       ` Bart Van Assche
2024-07-18 23:22         ` Shinichiro Kawasaki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).