diff mbox series

[blktests,v2,3/6] common/scsi_debug: factor out _setup_scsi_debug_vars

Message ID 20230425114745.376322-4-shinichiro@fastmail.com
State New
Headers show
Series [blktests,v2,1/6] common/rc: skip module file check if modules path does not exist | expand

Commit Message

Shin'ichiro Kawasaki April 25, 2023, 11:47 a.m. UTC
From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>

As a preparation to introduce a new helper function to configure
scsi_debug device with built-in scsi_debug module, factor out a part
of _init_scsi_debug to a new function _setup_scsi_debug_vars.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 common/scsi_debug | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/common/scsi_debug b/common/scsi_debug
index 5f73354..0bf768a 100644
--- a/common/scsi_debug
+++ b/common/scsi_debug
@@ -8,22 +8,7 @@  _have_scsi_debug() {
 	_have_driver scsi_debug
 }
 
-_init_scsi_debug() {
-	local -a args=("$@")
-
-	if (( RUN_FOR_ZONED )); then
-		if ! _have_module_param scsi_debug zbc; then
-			return
-		fi
-		args+=(zbc=host-managed zone_nr_conv=0)
-	fi
-
-	if ! modprobe -r scsi_debug || ! modprobe scsi_debug "${args[@]}"; then
-		return 1
-	fi
-
-	udevadm settle
-
+_setup_scsi_debug_vars() {
 	local host_sysfs host target_sysfs target
 	SCSI_DEBUG_HOSTS=()
 	SCSI_DEBUG_TARGETS=()
@@ -55,6 +40,25 @@  _init_scsi_debug() {
 	return 0
 }
 
+_init_scsi_debug() {
+	local -a args=("$@")
+
+	if (( RUN_FOR_ZONED )); then
+		if ! _have_module_param scsi_debug zbc; then
+			return
+		fi
+		args+=(zbc=host-managed zone_nr_conv=0)
+	fi
+
+	if ! modprobe -r scsi_debug || ! modprobe scsi_debug "${args[@]}"; then
+		return 1
+	fi
+
+	udevadm settle
+
+	_setup_scsi_debug_vars
+}
+
 _exit_scsi_debug() {
 	unset SCSI_DEBUG_HOSTS
 	unset SCSI_DEBUG_TARGETS