[PATCH v7 6/7] common: move module_unload to common
Sagi Grimberg
sagi at grimberg.me
Thu Sep 3 19:53:36 EDT 2020
It creates a dependency between multipath-over-rdma and test/nvmeof/rc
(and test/srp/rc) which is not a natural home for it.
Move it to common helpers.
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
common/rc | 13 +++++++++++++
tests/nvmeof-mp/rc | 13 -------------
tests/srp/rc | 13 -------------
3 files changed, 13 insertions(+), 26 deletions(-)
diff --git a/common/rc b/common/rc
index 7f02103dc786..cdc0150ea5ea 100644
--- a/common/rc
+++ b/common/rc
@@ -291,3 +291,16 @@ _filter_xfs_io_error() {
_uptime_s() {
awk '{ print int($1) }' /proc/uptime
}
+
+# Arguments: module to unload ($1) and retry count ($2).
+unload_module() {
+ local i m=$1 rc=${2:-1}
+
+ [ ! -e "/sys/module/$m" ] && return 0
+ for ((i=rc;i>0;i--)); do
+ modprobe -r "$m"
+ [ ! -e "/sys/module/$m" ] && return 0
+ sleep .1
+ done
+ return 1
+}
diff --git a/tests/nvmeof-mp/rc b/tests/nvmeof-mp/rc
index b95adf047a2f..d7a7c878fb19 100755
--- a/tests/nvmeof-mp/rc
+++ b/tests/nvmeof-mp/rc
@@ -149,19 +149,6 @@ remove_mpath_devs() {
} &>> "$FULL"
}
-# Arguments: module to unload ($1) and retry count ($2).
-unload_module() {
- local i m=$1 rc=${2:-1}
-
- [ ! -e "/sys/module/$m" ] && return 0
- for ((i=rc;i>0;i--)); do
- modprobe -r "$m"
- [ ! -e "/sys/module/$m" ] && return 0
- sleep .1
- done
- return 1
-}
-
start_nvme_client() {
modprobe nvme-core dyndbg=+pmf &&
modprobe nvme dyndbg=+pmf &&
diff --git a/tests/srp/rc b/tests/srp/rc
index 72a3bca3b44d..7fc094b8267f 100755
--- a/tests/srp/rc
+++ b/tests/srp/rc
@@ -321,19 +321,6 @@ remove_mpath_devs() {
} &>> "$FULL"
}
-# Arguments: module to unload ($1) and retry count ($2).
-unload_module() {
- local i m=$1 rc=${2:-1}
-
- [ ! -e "/sys/module/$m" ] && return 0
- for ((i=rc;i>0;i--)); do
- modprobe -r "$m"
- [ ! -e "/sys/module/$m" ] && return 0
- sleep .1
- done
- return 1
-}
-
# Load the SRP initiator driver with kernel module parameters $1..$n.
start_srp_ini() {
modprobe scsi_transport_srp || return $?
--
2.25.1
More information about the Linux-nvme
mailing list