clean up scsi_debug module handling
authorEric Sandeen <sandeen@redhat.com>
Fri, 9 Mar 2012 17:36:54 +0000 (11:36 -0600)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 9 Mar 2012 17:36:54 +0000 (11:36 -0600)
2 little fixes to common scsi_debug handling.

* don't consider the scsi_debug module in use in
  _require, unless it can't be rmmod'd
* don't try to rmmod it in _put unless it is currently
  loaded

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
common.scsi_debug

index 9f9177c14907d84c8af15e4063cb1ab1de030e7f..a085a67362689ddd568193b291e907c2dd99935a 100644 (file)
@@ -26,7 +26,7 @@ _require_scsi_debug()
 {
        # make sure we have the module and it's not already used
        modinfo scsi_debug 2>&1 > /dev/null || _notrun "scsi_debug module not found"
 {
        # make sure we have the module and it's not already used
        modinfo scsi_debug 2>&1 > /dev/null || _notrun "scsi_debug module not found"
-       lsmod | grep -wq scsi_debug && _notrun "scsi_debug module in use"
+       lsmod | grep -wq scsi_debug && (rmmod scsi_debug || _notrun "scsi_debug module in use")
        # make sure it has the features we need
        # logical/physical sectors plus unmap support all went in together
        modinfo scsi_debug | grep -wq sector_size || _notrun "scsi_debug too old"
        # make sure it has the features we need
        # logical/physical sectors plus unmap support all went in together
        modinfo scsi_debug | grep -wq sector_size || _notrun "scsi_debug too old"
@@ -58,5 +58,6 @@ _get_scsi_debug_dev()
 _put_scsi_debug_dev()
 {
        sleep 1
 _put_scsi_debug_dev()
 {
        sleep 1
+       lsmod | grep -wq scsi_debug || return
        rmmod scsi_debug || _fail "Could not remove scsi_debug module"
 }
        rmmod scsi_debug || _fail "Could not remove scsi_debug module"
 }