Skip to contentSkip to conversation

srp: skip test if scsi_transport_srp module is loaded and in use

PATCH Applied Nilay Shroff 4 participants 4 messages Feb 5, 2025 – Feb 9, 2025 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH v2 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 argument

So if the scsi_transport_srp module is loaded and in use then skip running srp/* tests.

---
Changes from v1:
- Fix formatting, replace white spaces with tabs (Shinichiro Kawasaki)
- Rename _have_module_not_in_use to _module_not_in_use (Bart Van Assche)

---
 common/rc    | 13 +++++++++++++
 tests/srp/rc |  1 +
 2 files changed, 14 insertions(+)
common/rc +13 -0
index bcb215d..20579b0 100644
@@ -78,6 +78,19 @@ _have_module() {
 	return 0
 }
 
+_module_not_in_use() {
+	local refcnt
+
+	_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
index 85bd1dd..47b9546 100755
@@ -61,6 +61,7 @@ group_requires() {
 	_have_module scsi_debug
 	_have_module target_core_iblock
 	_have_module target_core_mod
+	_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
Tested-by on v2 1/1
#2 lore raw
In reply to Nilay Shroff
Quoted 16 lines · Nilay Shroff

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 argument
Quoted 4 lines

So if the scsi_transport_srp module is loaded and in use then skip running srp/* tests.

I have tested the patch on PowerPC machine, it works fine.

Quoted 46 lines

---
Changes from v1:
- Fix formatting, replace white spaces with tabs (Shinichiro Kawasaki)
- Rename _have_module_not_in_use to _module_not_in_use (Bart Van Assche)

---
  common/rc    | 13 +++++++++++++
  tests/srp/rc |  1 +
  2 files changed, 14 insertions(+)
common/rc +13 -0
index bcb215d..20579b0 100644
@@ -78,6 +78,19 @@ _have_module() {
  	return 0
  }
 
+_module_not_in_use() {
+	local refcnt
+
+	_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
index 85bd1dd..47b9546 100755
@@ -61,6 +61,7 @@ group_requires() {
  	_have_module scsi_debug
  	_have_module target_core_iblock
  	_have_module target_core_mod
+	_module_not_in_use scsi_transport_srp
 
  	for p in mkfs.ext4 mkfs.xfs multipath multipathd pidof rdma \
  		 sg_reset fio; do
#3 lore raw
In reply to Nilay Shroff
Quoted 16 lines · Nilay Shroff

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 argument
Quoted 4 lines

So if the scsi_transport_srp module is loaded and in use then skip running srp/* tests.

I applied the patch with a few minor edits. Thanks!