diff mbox series

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

Message ID 20230417124728.458630-4-shinichiro@fastmail.com (mailing list archive)
State New, archived
Headers show
Series support built-in scsi_debug | expand

Commit Message

Shin'ichiro Kawasaki April 17, 2023, 12:47 p.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>
---
 common/scsi_debug | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

Comments

Chaitanya Kulkarni April 18, 2023, 8:11 p.m. UTC | #1
On 4/17/23 05:47, Shin'ichiro Kawasaki wrote:
> 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>
> ---
>

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck
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