]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/scsi_debug: fix removal of scsi_debug module
authorEryu Guan <eguan@redhat.com>
Mon, 11 Jan 2016 04:08:20 +0000 (15:08 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 11 Jan 2016 04:08:20 +0000 (15:08 +1100)
Occasionally scsi_debug cannot be removed because it's still in use and
causes xfs/279 to fail.

Now dryrun the removal by modprobe firstly then do the real rmmod.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
common/scsi_debug

index d073b6d9e6961c2b5aea0f914541b97fe1f2dee4..eb08126f3387f8bfeb159ffc68b1680dfac4befa 100644 (file)
@@ -57,7 +57,15 @@ _get_scsi_debug_dev()
 
 _put_scsi_debug_dev()
 {
-       sleep 1
        lsmod | grep -wq scsi_debug || return
+
+       n=2
+       # 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
+               sleep 1
+               n=$((n-1))
+       done
        rmmod scsi_debug || _fail "Could not remove scsi_debug module"
 }