srp: skip test if scsi_transport_srp module is loaded and in use
PATCH 1/1 srp: skip test if scsi_transport_srp module is loaded and in use
The srp/* tests requires exclusive access to scsi_transport_srp module. Running srp/* tests would definitely fail if the test can't get exclusive access of scsi_transport_srp module as shown below:
$ lsmod | grep scsi_transport_srp scsi_transport_srp 327680 1 ibmvscsi
$ ./check srp/001
srp/001 (Create and remove LUNs) [failed]
runtime ... 0.249s
tests/srp/rc: line 263: /sys/class/srp_remote_ports/port-0:1/delete: Permission denied
tests/srp/rc: line 263: /sys/class/srp_remote_ports/port-0:1/delete: Permission denied
modprobe: FATAL: Module scsi_transport_srp is in use.
error: Invalid argument
error: Invalid argumentSo if the scsi_transport_srp module is loaded and in use then skip running srp/* tests.
--- common/rc | 11 +++++++++++ tests/srp/rc | 1 + 2 files changed, 12 insertions(+)
common/rc +11 -0
@@ -78,6 +78,17 @@ _have_module() { return 0 } +_have_module_not_in_use() { + _have_module "$1" || return + + if [ -d "/sys/module/$1" ]; then + refcnt="$(cat /sys/module/$1/refcnt)" + if [ "$refcnt" -ne "0" ]; then + SKIP_REASONS+=("module $1 is in use") + fi + fi +} + _have_module_param() { _have_driver "$1" || return
tests/srp/rc +1 -0
@@ -61,6 +61,7 @@ group_requires() { _have_module scsi_debug _have_module target_core_iblock _have_module target_core_mod + _have_module_not_in_use scsi_transport_srp for p in mkfs.ext4 mkfs.xfs multipath multipathd pidof rdma \ sg_reset fio; do
Signature · 1 line
2.47.1
CC+: Bart,
Quoted 16 lines · Nilay Shroff
The srp/* tests requires exclusive access to
scsi_transport_srpmodule. Running srp/* tests would definitely fail if the test can't get exclusive access ofscsi_transport_srpmodule as shown below:$ lsmod | grep scsi_transport_srp scsi_transport_srp 327680 1 ibmvscsi$ ./check srp/001 srp/001 (Create and remove LUNs) [failed] runtime ... 0.249s tests/srp/rc: line 263: /sys/class/srp_remote_ports/port-0:1/delete: Permission denied tests/srp/rc: line 263: /sys/class/srp_remote_ports/port-0:1/delete: Permission denied modprobe: FATAL: Module scsi_transport_srp is in use. error: Invalid argument error: Invalid argument
Quoted 2 lines
So if the
scsi_transport_srpmodule is loaded and in use then skip running srp/* tests.
Thanks. I think this is a good improvement.
Quoted 15 lines
Signed-off-by Nilay Shroff <[email protected]>--- common/rc | 11 +++++++++++ tests/srp/rc | 1 + 2 files changed, 12 insertions(+)common/rc +0
-0@@ -78,6 +78,17 @@ _have_module() { return 0 }
common/rc _have_module() { · line 90
Quoted 10 lines
common/rc +10
-0+_have_module_not_in_use() { + _have_module "$1" || return + + if [ -d "/sys/module/$1" ]; then + refcnt="$(cat /sys/module/$1/refcnt)" + if [ "$refcnt" -ne "0" ]; then + SKIP_REASONS+=("module $1 is in use") + fi + fi +}
Spaces are used for indents. Please use tabs instead.
Nit: "refcnt" is not declared as a local variable. Let's declare it. Or, it would be the better to avoid "refcnt". Instead, $(< /sys/module/$1/refcnt) can be used as follows. Either way is fine for me.
if [ -d "/sys/module/$1" ] && (($(</sys/module/"$1"/refcnt) != 0)); then
SKIP_REASONS+=("module $1 is in use")
fiQuoted 39 lines · Shinichiro Kawasaki
CC+: Bart,
Quoted 16 lines · Nilay Shroff
The srp/* tests requires exclusive access to
scsi_transport_srpmodule. Running srp/* tests would definitely fail if the test can't get exclusive access ofscsi_transport_srpmodule as shown below:$ lsmod | grep scsi_transport_srp scsi_transport_srp 327680 1 ibmvscsi$ ./check srp/001 srp/001 (Create and remove LUNs) [failed] runtime ... 0.249s tests/srp/rc: line 263: /sys/class/srp_remote_ports/port-0:1/delete: Permission denied tests/srp/rc: line 263: /sys/class/srp_remote_ports/port-0:1/delete: Permission denied modprobe: FATAL: Module scsi_transport_srp is in use. error: Invalid argument error: Invalid argumentQuoted 2 lines
So if the
scsi_transport_srpmodule is loaded and in use then skip running srp/* tests.Thanks. I think this is a good improvement.
Quoted 15 lines
Signed-off-by Nilay Shroff <[email protected]>--- common/rc | 11 +++++++++++ tests/srp/rc | 1 + 2 files changed, 12 insertions(+)common/rc +0
-0@@ -78,6 +78,17 @@ _have_module() { return 0 }
Quoted 13 lines
common/rc _have_module() { · line 90
Quoted 10 lines
common/rc +10
-0+_have_module_not_in_use() { + _have_module "$1" || return + + if [ -d "/sys/module/$1" ]; then + refcnt="$(cat /sys/module/$1/refcnt)" + if [ "$refcnt" -ne "0" ]; then + SKIP_REASONS+=("module $1 is in use") + fi + fi +}Spaces are used for indents. Please use tabs instead.
Grrr.. I think my editor inserted spaces instead of tabs, I would fix this in the next version of the patch.
Quoted 7 lines
Nit: "refcnt" is not declared as a local variable. Let's declare it. Or, it would be the better to avoid "refcnt". Instead, $(<
/sys/module/$1/refcnt) can be used as follows. Either way is fine for me.if [ -d "/sys/module/$1" ] && (($(</sys/module/"$1"/refcnt) != 0)); then SKIP_REASONS+=("module $1 is in use") fi
Okay, I'd make "refcnt" local and update.
Thanks,
--Nilay
Quoted 1 line · Nilay Shroff
+_have_module_not_in_use() {
The name "_have_module_not_in_use()" sounds weird to me. Wouldn't _module_not_in_use() be a better name?
Thanks,
Bart.
Quoted 6 lines · Bart Van Assche
Quoted 1 line · Nilay Shroff
+_have_module_not_in_use() {
The name "
_have_module_not_in_use()" sounds weird to me. Wouldn't_module_not_in_use()be a better name?
Yeah _module_not_in_use() sounds better. I will incorporate this in the next patch.
Thanks,
--Nilay