Skip to contentSkip to conversation

common/scsi_debug: make sure scsi_debug been removed correctly

PATCH New yangerkun 1 participant 1 message Jan 14, 2019

lore
Share & tools
lore

yangerkun

author
#0 lore raw

PATCH v2 1/1 common/scsi_debug: make sure scsi_debug been removed correctly

Case generic/108 sometimes may fail while testing with some fs, and the reson is that rmmod scsi_debug in _put_scsi_debug_dev can randomly fail due to open references from udev scan. Now add the loop to do rmmod to make sure scsi_debug can remove correctly.

This patch is a reference to 'https://gitlab.com/cryptsetup/cryptsetup.git' commit d7b9ed05f0931b416c33c8eb2ff1e6efa39270ff from Ondrej Kozina, thanks a lot!

---
 common/scsi_debug | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
common/scsi_debug +4 -2
index d9aa0bd..890ec68 100644
@@ -45,11 +45,13 @@ _put_scsi_debug_dev()
 {
 	lsmod | grep -wq scsi_debug || return
 
-	n=2
+	n=15
 	# use redirection not -q option of modprobe here, because -q of old
 	# modprobe is only quiet when the module is not found, not when the
 	# module is in use.
-	while [ $n -ge 0 ] && ! modprobe -nr scsi_debug >/dev/null 2>&1; do
+	while [ $n -ge 0 ]; do
+		modprobe -r scsi_debug >/dev/null 2>&1
+		[ $? -eq 0 ] && return 0
 		sleep 1
 		n=$((n-1))
 	done
Signature · 1 line
2.9.5