linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH blktests 0/9] support built-in scsi_debug
@ 2023-04-17 12:47 Shin'ichiro Kawasaki
  2023-04-17 12:47 ` [PATCH blktests 1/9] common/rc: skip module file check if modules path does not exist Shin'ichiro Kawasaki
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Shin'ichiro Kawasaki @ 2023-04-17 12:47 UTC (permalink / raw)
  To: linux-block, linux-scsi
  Cc: Shin'ichiro Kawasaki, Shin'ichiro Kawasaki

From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>

In the past, there was an issue related to scsi_debug module unload [1]. At that
time, it was suggested to modify blktests not to rely on module load and unload.
Based on that discussion, blktests was modified not to load or unload null_blk
driver [2][3]. As of today, a number of test cases with null_blk can be run with
built-in null_blk.

This series introduces similar support for built-in scsi_debug. This patch adds
a new helper function _configure_scsi_debug which can set up scsi_debug device
without module load and unload. Also it enables 5 test cases to run with built-
in scsi_debug.

The first patch in this series fixes a minor issue found during this work. Next
two patches modify common/scsi_debug functions as preparation. The 4th patch
introduces the new function _configure_scsi_debug. Following 5 patches modify
the 5 test cases so that they can run with built-in scsi debug.

Of note is that still 9 test cases are left to require loadable scsi_debug. 8 of
them can not be run with built-in scsi_debug because the parameters they set are
read-only on sysfs. The other one test case scsi/007 has other failure symptom
now, so I leave it untouched at this moment.

[1] https://lore.kernel.org/linux-block/bc0b2c10-10e6-a1d9-4139-ac93ad3512b2@interlog.com/
[2] https://lore.kernel.org/linux-block/20220601064837.3473709-1-hch@lst.de/
[3] https://lore.kernel.org/linux-block/20220607124739.1259977-1-hch@lst.de/

Shin'ichiro Kawasaki (9):
  common/rc: skip module file check if modules path does not exist
  common/scsi_debug, tests/*: re-define _have_scsi_debug
  common/scsi_debug: factor out _setup_scsi_debug_vars
  common/scsi_debug: introduce _configure_scsi_debug
  scsi/004: allow to run with built-in scsi_debug
  scsi/005: allow to run with built-in scsi_debug
  block/001: allow to run with built-in scsi_debug and sd_mod
  block/002: allow to run with built-in scsi_debug
  block/027: allow to run with built-in scsi_debug

 common/rc         |   1 +
 common/scsi_debug | 139 ++++++++++++++++++++++++++++++++++++++++++----
 tests/block/001   |   4 +-
 tests/block/002   |   5 +-
 tests/block/009   |   3 +-
 tests/block/025   |   2 +-
 tests/block/027   |   6 +-
 tests/block/028   |   2 +-
 tests/block/032   |   3 +-
 tests/loop/004    |   5 +-
 tests/scsi/004    |  15 ++++-
 tests/scsi/005    |   5 +-
 tests/scsi/007    |   2 +-
 tests/zbd/008     |   5 +-
 tests/zbd/009     |   2 +-
 tests/zbd/010     |   2 +-
 16 files changed, 169 insertions(+), 32 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH blktests 1/9] common/rc: skip module file check if modules path does not exist
  2023-04-17 12:47 [PATCH blktests 0/9] support built-in scsi_debug Shin'ichiro Kawasaki
@ 2023-04-17 12:47 ` Shin'ichiro Kawasaki
  2023-04-18 20:09   ` Chaitanya Kulkarni
  2023-04-17 12:47 ` [PATCH blktests 2/9] common/scsi_debug, tests/*: re-define _have_scsi_debug Shin'ichiro Kawasaki
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Shin'ichiro Kawasaki @ 2023-04-17 12:47 UTC (permalink / raw)
  To: linux-block, linux-scsi
  Cc: Shin'ichiro Kawasaki, Shin'ichiro Kawasaki

From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>

When all of the kernel modules are built-in, /lib/modules/*/kernel path
may not exist. In this case, check for the path results in failure. Skip
the check when the path does not exist.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 common/rc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/rc b/common/rc
index af4c0b1..f67b434 100644
--- a/common/rc
+++ b/common/rc
@@ -36,6 +36,7 @@ _module_file_exists()
 	local -i count
 
 	libpath="/lib/modules/$(uname -r)/kernel"
+	[[ ! -d $libpath ]] && return 1
 	count=$(find "$libpath" -name "$ko_underscore*" -o \
 		     -name "$ko_hyphen*" | wc -l)
 	((count)) && return 0
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH blktests 2/9] common/scsi_debug, tests/*: re-define _have_scsi_debug
  2023-04-17 12:47 [PATCH blktests 0/9] support built-in scsi_debug Shin'ichiro Kawasaki
  2023-04-17 12:47 ` [PATCH blktests 1/9] common/rc: skip module file check if modules path does not exist Shin'ichiro Kawasaki
@ 2023-04-17 12:47 ` Shin'ichiro Kawasaki
  2023-04-18 20:10   ` Chaitanya Kulkarni
  2023-04-17 12:47 ` [PATCH blktests 3/9] common/scsi_debug: factor out _setup_scsi_debug_vars Shin'ichiro Kawasaki
  2023-04-17 12:47 ` [PATCH blktests 4/9] common/scsi_debug: introduce _configure_scsi_debug Shin'ichiro Kawasaki
  3 siblings, 1 reply; 9+ messages in thread
From: Shin'ichiro Kawasaki @ 2023-04-17 12:47 UTC (permalink / raw)
  To: linux-block, linux-scsi
  Cc: Shin'ichiro Kawasaki, Shin'ichiro Kawasaki

From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>

As a preparation to adapt test cases to built-in scsi_debug module, re-
define the _have_scsi_debug function. It checks that the scsi_debug
module is built as a loadable module. Modify it to check that the
scsi_debug module is available as built-in module or loadable module.

Also replace all _have_scsi_debug calls in test cases with
"_have_module scsi_debug" so that the change of _have_scsi_debug do not
affect the test cases. Following commits will modify them to call
_have_scsi_debug, only for test cases ready to run with built-in
scsi_debug.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 common/scsi_debug | 2 +-
 tests/block/001   | 2 +-
 tests/block/002   | 3 ++-
 tests/block/009   | 3 ++-
 tests/block/025   | 2 +-
 tests/block/027   | 4 +++-
 tests/block/028   | 2 +-
 tests/block/032   | 3 ++-
 tests/loop/004    | 5 ++++-
 tests/scsi/004    | 2 +-
 tests/scsi/005    | 3 ++-
 tests/scsi/007    | 2 +-
 tests/zbd/008     | 5 +++--
 tests/zbd/009     | 2 +-
 tests/zbd/010     | 2 +-
 15 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/common/scsi_debug b/common/scsi_debug
index ae13bb6..5f73354 100644
--- a/common/scsi_debug
+++ b/common/scsi_debug
@@ -5,7 +5,7 @@
 # scsi_debug helper functions.
 
 _have_scsi_debug() {
-	_have_module scsi_debug
+	_have_driver scsi_debug
 }
 
 _init_scsi_debug() {
diff --git a/tests/block/001 b/tests/block/001
index fb93932..2ea3754 100755
--- a/tests/block/001
+++ b/tests/block/001
@@ -13,7 +13,7 @@ DESCRIPTION="stress device hotplugging"
 TIMED=1
 
 requires() {
-	_have_scsi_debug
+	_have_module scsi_debug
 	_have_driver sd_mod
 	_have_driver sr_mod
 }
diff --git a/tests/block/002 b/tests/block/002
index 05d00d2..a5f3ee5 100755
--- a/tests/block/002
+++ b/tests/block/002
@@ -12,7 +12,8 @@ DESCRIPTION="remove a device while running blktrace"
 QUICK=1
 
 requires() {
-	_have_blktrace && _have_scsi_debug
+	_have_blktrace
+	_have_module scsi_debug
 }
 
 test() {
diff --git a/tests/block/009 b/tests/block/009
index df36edb..d3ea42a 100755
--- a/tests/block/009
+++ b/tests/block/009
@@ -12,7 +12,8 @@
 DESCRIPTION="check page-cache coherency after BLKDISCARD"
 
 requires() {
-	_have_scsi_debug && _have_program xfs_io
+	_have_module scsi_debug
+	_have_program xfs_io
 }
 
 test() {
diff --git a/tests/block/025 b/tests/block/025
index f746c1c..4c48e9f 100755
--- a/tests/block/025
+++ b/tests/block/025
@@ -12,7 +12,7 @@
 DESCRIPTION="do a huge discard with 4k sector size"
 
 requires() {
-	_have_scsi_debug
+	_have_module scsi_debug
 }
 
 test() {
diff --git a/tests/block/027 b/tests/block/027
index b60f62c..ab6369b 100755
--- a/tests/block/027
+++ b/tests/block/027
@@ -19,7 +19,9 @@ QUICK=1
 CAN_BE_ZONED=1
 
 requires() {
-	_have_cgroup2_controller io && _have_scsi_debug && _have_fio
+	_have_cgroup2_controller io
+	_have_module scsi_debug
+	_have_fio
 }
 
 scsi_debug_stress_remove() {
diff --git a/tests/block/028 b/tests/block/028
index 5140d94..13b3278 100755
--- a/tests/block/028
+++ b/tests/block/028
@@ -12,7 +12,7 @@ DESCRIPTION="do I/O on scsi_debug with DIF/DIX enabled"
 DMESG_FILTER="sed -r 's/(guard tag error at sector|ref tag error at location)/blktests failure: \\1/'"
 
 requires() {
-	_have_scsi_debug
+	_have_module scsi_debug
 }
 
 test_pi() {
diff --git a/tests/block/032 b/tests/block/032
index b07b7ab..8975879 100755
--- a/tests/block/032
+++ b/tests/block/032
@@ -13,7 +13,8 @@ DESCRIPTION="remove one mounted device"
 QUICK=1
 
 requires() {
-	_have_xfs && _have_scsi_debug
+	_have_xfs
+	_have_module scsi_debug
 }
 
 test() {
diff --git a/tests/loop/004 b/tests/loop/004
index fab34e8..ca52d80 100755
--- a/tests/loop/004
+++ b/tests/loop/004
@@ -11,7 +11,10 @@ DESCRIPTION="combine loop direct I/O mode and a custom block size"
 QUICK=1
 
 requires() {
-	_have_program xfs_io && _have_scsi_debug && _have_src_program loblksize && _have_loop_set_block_size
+	_have_program xfs_io
+	_have_module scsi_debug
+	_have_src_program loblksize
+	_have_loop_set_block_size
 }
 
 test() {
diff --git a/tests/scsi/004 b/tests/scsi/004
index b5ef2dd..f0845c1 100755
--- a/tests/scsi/004
+++ b/tests/scsi/004
@@ -18,7 +18,7 @@ DESCRIPTION="ensure repeated TASK SET FULL results in EIO on timing out command"
 CAN_BE_ZONED=1
 
 requires() {
-	_have_scsi_debug
+	_have_module scsi_debug
 }
 
 test() {
diff --git a/tests/scsi/005 b/tests/scsi/005
index 22fb495..efd3d82 100755
--- a/tests/scsi/005
+++ b/tests/scsi/005
@@ -11,7 +11,8 @@ DESCRIPTION="test SCSI device blacklisting"
 QUICK=1
 
 requires() {
-	_have_scsi_debug && _have_module_param scsi_debug inq_vendor
+	_have_module scsi_debug
+	_have_module_param scsi_debug inq_vendor
 }
 
 test() {
diff --git a/tests/scsi/007 b/tests/scsi/007
index e7088a1..547a735 100755
--- a/tests/scsi/007
+++ b/tests/scsi/007
@@ -12,7 +12,7 @@ DESCRIPTION="Trigger the SCSI error handler"
 QUICK=1
 
 requires() {
-	_have_scsi_debug
+	_have_module scsi_debug
 }
 
 config_hz() {
diff --git a/tests/zbd/008 b/tests/zbd/008
index c625bad..55b5b6c 100755
--- a/tests/zbd/008
+++ b/tests/zbd/008
@@ -13,8 +13,9 @@ DESCRIPTION="check no stale page cache after BLKZONERESET and data read race"
 TIMED=1
 
 requires() {
-	_have_scsi_debug && _have_module_param scsi_debug zbc &&
-		_have_program xfs_io
+	_have_module scsi_debug
+	_have_module_param scsi_debug zbc
+	_have_program xfs_io
 }
 
 test() {
diff --git a/tests/zbd/009 b/tests/zbd/009
index 483cbf6..c0ce1f2 100755
--- a/tests/zbd/009
+++ b/tests/zbd/009
@@ -36,7 +36,7 @@ requires() {
 	_have_driver btrfs
 	_have_module_param scsi_debug zone_cap_mb
 	_have_program mkfs.btrfs
-	_have_scsi_debug
+	_have_module scsi_debug
 	have_good_mkfs_btrfs
 }
 
diff --git a/tests/zbd/010 b/tests/zbd/010
index 35143b8..c5cb76a 100755
--- a/tests/zbd/010
+++ b/tests/zbd/010
@@ -15,7 +15,7 @@ requires() {
 	_have_module null_blk
 	_have_module_param scsi_debug zone_cap_mb
 	_have_program mkfs.f2fs
-	_have_scsi_debug
+	_have_module scsi_debug
 }
 
 test() {
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH blktests 3/9] common/scsi_debug: factor out _setup_scsi_debug_vars
  2023-04-17 12:47 [PATCH blktests 0/9] support built-in scsi_debug Shin'ichiro Kawasaki
  2023-04-17 12:47 ` [PATCH blktests 1/9] common/rc: skip module file check if modules path does not exist Shin'ichiro Kawasaki
  2023-04-17 12:47 ` [PATCH blktests 2/9] common/scsi_debug, tests/*: re-define _have_scsi_debug Shin'ichiro Kawasaki
@ 2023-04-17 12:47 ` Shin'ichiro Kawasaki
  2023-04-18 20:11   ` Chaitanya Kulkarni
  2023-04-17 12:47 ` [PATCH blktests 4/9] common/scsi_debug: introduce _configure_scsi_debug Shin'ichiro Kawasaki
  3 siblings, 1 reply; 9+ messages in thread
From: Shin'ichiro Kawasaki @ 2023-04-17 12:47 UTC (permalink / raw)
  To: linux-block, linux-scsi
  Cc: Shin'ichiro Kawasaki, Shin'ichiro Kawasaki

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(-)

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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH blktests 4/9] common/scsi_debug: introduce _configure_scsi_debug
  2023-04-17 12:47 [PATCH blktests 0/9] support built-in scsi_debug Shin'ichiro Kawasaki
                   ` (2 preceding siblings ...)
  2023-04-17 12:47 ` [PATCH blktests 3/9] common/scsi_debug: factor out _setup_scsi_debug_vars Shin'ichiro Kawasaki
@ 2023-04-17 12:47 ` Shin'ichiro Kawasaki
  2023-04-18 20:15   ` Chaitanya Kulkarni
  3 siblings, 1 reply; 9+ messages in thread
From: Shin'ichiro Kawasaki @ 2023-04-17 12:47 UTC (permalink / raw)
  To: linux-block, linux-scsi
  Cc: Shin'ichiro Kawasaki, Shin'ichiro Kawasaki

From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>

To set up scsi_debug devices with built-in scsi_debug module, introduce
a new helper function _configure_scsi_debug. It works in similar manner
as _init_scsi_debug which sets up scsi_debug devices with loadable
scsi_debug module.

_configure_scsi_debug takes parameters of scsi_debug devices in format
of 'key=value' as its arguments. It calls another new helper function
_scsi_debug_key_path to search sysfs files corresponding to the keys in
/sys/bus/pseudo/drivers/scsi_debug or /sys/module/scsi_debug/parameters.
When it finds the file, it writes the value to the file. The original
values of the files are kept in the global array SCSI_DEBUG_VALUES and
restored by _exit_scsi_debug.

Among the parameters, 'add_host' has special meaning to add new hosts.
Then it is handled separately so that it is set at last in
_configure_scsi_debug, and restored at first in _exit_scsi_debug. Also,
record the hosts which exist before _configure_scsi_debug in the array
ORIG_SCSI_DEBUG_HOSTS. Those hosts should not be used for testing, then
do not add them to SCSI_DEBUG_HOSTS.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 common/scsi_debug | 113 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 112 insertions(+), 1 deletion(-)

diff --git a/common/scsi_debug b/common/scsi_debug
index 0bf768a..ee9edac 100644
--- a/common/scsi_debug
+++ b/common/scsi_debug
@@ -8,16 +8,49 @@ _have_scsi_debug() {
 	_have_driver scsi_debug
 }
 
+SD_PSEUDO_PATH=/sys/bus/pseudo/drivers/scsi_debug
+SD_PARAM_PATH=/sys/module/scsi_debug/parameters
+
+_scsi_debug_key_path() {
+	local key=${1}
+
+	path="${SD_PSEUDO_PATH}/$key"
+	if [[ ! -e $path ]]; then
+		path="${SD_PARAM_PATH}/$key"
+	fi
+	if [[ ! -w $path ]]; then
+		return 1
+	fi
+
+	echo "$path"
+}
+
+declare -a SCSI_DEBUG_HOSTS
+declare -a SCSI_DEBUG_TARGETS
+declare -a SCSI_DEBUG_DEVICES
+declare -a ORIG_SCSI_DEBUG_HOSTS
+
 _setup_scsi_debug_vars() {
 	local host_sysfs host target_sysfs target
+	local -i i
+
 	SCSI_DEBUG_HOSTS=()
 	SCSI_DEBUG_TARGETS=()
 	SCSI_DEBUG_DEVICES=()
+
 	for host_sysfs in /sys/class/scsi_host/*; do
 		if [[ "$(cat "${host_sysfs}/proc_name")" = scsi_debug ]]; then
 			host="${host_sysfs#/sys/class/scsi_host/host}"
+			local orig_host=0
+			for ((i=0;i<${#ORIG_SCSI_DEBUG_HOSTS[@]};i++)); do
+				if (( host == ORIG_SCSI_DEBUG_HOSTS[i])); then
+					orig_host=1
+				fi
+			done
+			((orig_host)) && continue
 			SCSI_DEBUG_HOSTS+=("$host")
 			for target_sysfs in /sys/class/scsi_device/"$host":*; do
+				[[ ! -e $target_sysfs ]] && break
 				target="${target_sysfs#/sys/class/scsi_device/}"
 				SCSI_DEBUG_TARGETS+=("$target")
 				SCSI_DEBUG_DEVICES+=("$(ls "$target_sysfs/device/block")")
@@ -59,10 +92,88 @@ _init_scsi_debug() {
 	_setup_scsi_debug_vars
 }
 
+_configure_scsi_debug() {
+	local -a args=("$@")
+	local -a values
+	local key value path add_host_value=1
+	local -i i
+
+	udevadm settle
+
+	# fall back to _init_scsi_debug because scsi_debug is loadable
+	if _module_file_exists scsi_debug; then
+		_init_scsi_debug "${args[@]}"
+		return
+	fi
+
+	# zoned device is not yet configurable due to read-only zbc parameter
+	if (( RUN_FOR_ZONED )) && ! _have_module scsi_debug; then
+		return 1
+	fi
+
+	# List SCSI_DEBUG_HOSTS before configuration
+	ORIG_SCSI_DEBUG_HOSTS=()
+	_setup_scsi_debug_vars >& /dev/null
+	ORIG_SCSI_DEBUG_HOSTS=("${SCSI_DEBUG_HOSTS[@]}")
+
+	SCSI_DEBUG_KEYS=()
+	SCSI_DEBUG_VALUES=()
+	for o in "$@"; do
+		key=${o%=*}
+		value=${o#*=}
+		SCSI_DEBUG_KEYS+=("${key}")
+		values+=("${value}")
+		if ! path=$(_scsi_debug_key_path "${key}"); then
+			echo "sysfs to write $key is not avaialbe"
+			return 1
+		fi
+		if [[ $key == add_host ]]; then
+			SCSI_DEBUG_VALUES+=("-${value}")
+			add_host_value=${value}
+		else
+			SCSI_DEBUG_VALUES+=("$(<"${path}")")
+			echo -n "${value}" > "${path}"
+		fi
+	done
+
+	echo "${add_host_value}" > ${SD_PSEUDO_PATH}/add_host
+
+	udevadm settle
+
+	_setup_scsi_debug_vars
+}
+
 _exit_scsi_debug() {
+	local i key path add_host_value=-1
+
 	unset SCSI_DEBUG_HOSTS
 	unset SCSI_DEBUG_TARGETS
 	unset SCSI_DEBUG_DEVICES
 	udevadm settle
-	modprobe -r scsi_debug
+
+	if _module_file_exists scsi_debug; then
+		modprobe -r scsi_debug
+		return
+	fi
+
+	for ((i = 0; i < ${#SCSI_DEBUG_KEYS[@]}; i++)); do
+		key=${SCSI_DEBUG_KEYS[i]}
+		if [[ $key == add_host ]]; then
+			add_host_value=${SCSI_DEBUG_VALUES[i]}
+		fi
+	done
+	echo "${add_host_value}" > ${SD_PSEUDO_PATH}/add_host
+
+	for ((i = 0; i < ${#SCSI_DEBUG_KEYS[@]}; i++)); do
+		key=${SCSI_DEBUG_KEYS[i]}
+		if ! path=$(_scsi_debug_key_path "${key}"); then
+			echo "sysfs to write $key is not avaialbe"
+			return 1
+		fi
+		if [[ $key != add_host ]]; then
+			echo -n "${SCSI_DEBUG_VALUES[i]}" > "${path}"
+		fi
+	done
+	unset SCSI_DEBUG_KEYS
+	unset SCSI_DEBUG_VALUES
 }
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH blktests 1/9] common/rc: skip module file check if modules path does not exist
  2023-04-17 12:47 ` [PATCH blktests 1/9] common/rc: skip module file check if modules path does not exist Shin'ichiro Kawasaki
@ 2023-04-18 20:09   ` Chaitanya Kulkarni
  0 siblings, 0 replies; 9+ messages in thread
From: Chaitanya Kulkarni @ 2023-04-18 20:09 UTC (permalink / raw)
  To: Shin'ichiro Kawasaki, linux-block@vger.kernel.org,
	linux-scsi@vger.kernel.org
  Cc: Shin'ichiro Kawasaki

On 4/17/23 05:47, Shin'ichiro Kawasaki wrote:
> From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
>
> When all of the kernel modules are built-in, /lib/modules/*/kernel path
> may not exist. In this case, check for the path results in failure. Skip
> the check when the path does not exist.
>
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---
>

Looks good.

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

-ck



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH blktests 2/9] common/scsi_debug, tests/*: re-define _have_scsi_debug
  2023-04-17 12:47 ` [PATCH blktests 2/9] common/scsi_debug, tests/*: re-define _have_scsi_debug Shin'ichiro Kawasaki
@ 2023-04-18 20:10   ` Chaitanya Kulkarni
  0 siblings, 0 replies; 9+ messages in thread
From: Chaitanya Kulkarni @ 2023-04-18 20:10 UTC (permalink / raw)
  To: Shin'ichiro Kawasaki, linux-block@vger.kernel.org,
	linux-scsi@vger.kernel.org
  Cc: Shin'ichiro Kawasaki

On 4/17/23 05:47, Shin'ichiro Kawasaki wrote:
> From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
>
> As a preparation to adapt test cases to built-in scsi_debug module, re-
> define the _have_scsi_debug function. It checks that the scsi_debug
> module is built as a loadable module. Modify it to check that the
> scsi_debug module is available as built-in module or loadable module.
>
> Also replace all _have_scsi_debug calls in test cases with
> "_have_module scsi_debug" so that the change of _have_scsi_debug do not
> affect the test cases. Following commits will modify them to call
> _have_scsi_debug, only for test cases ready to run with built-in
> scsi_debug.
>
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---
>

Looks good.

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

-ck



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH blktests 3/9] common/scsi_debug: factor out _setup_scsi_debug_vars
  2023-04-17 12:47 ` [PATCH blktests 3/9] common/scsi_debug: factor out _setup_scsi_debug_vars Shin'ichiro Kawasaki
@ 2023-04-18 20:11   ` Chaitanya Kulkarni
  0 siblings, 0 replies; 9+ messages in thread
From: Chaitanya Kulkarni @ 2023-04-18 20:11 UTC (permalink / raw)
  To: Shin'ichiro Kawasaki, linux-block@vger.kernel.org,
	linux-scsi@vger.kernel.org
  Cc: Shin'ichiro Kawasaki

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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH blktests 4/9] common/scsi_debug: introduce _configure_scsi_debug
  2023-04-17 12:47 ` [PATCH blktests 4/9] common/scsi_debug: introduce _configure_scsi_debug Shin'ichiro Kawasaki
@ 2023-04-18 20:15   ` Chaitanya Kulkarni
  0 siblings, 0 replies; 9+ messages in thread
From: Chaitanya Kulkarni @ 2023-04-18 20:15 UTC (permalink / raw)
  To: Shin'ichiro Kawasaki, linux-block@vger.kernel.org,
	linux-scsi@vger.kernel.org
  Cc: Shin'ichiro Kawasaki

On 4/17/23 05:47, Shin'ichiro Kawasaki wrote:
> From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
>
> To set up scsi_debug devices with built-in scsi_debug module, introduce
> a new helper function _configure_scsi_debug. It works in similar manner
> as _init_scsi_debug which sets up scsi_debug devices with loadable
> scsi_debug module.
>
> _configure_scsi_debug takes parameters of scsi_debug devices in format
> of 'key=value' as its arguments. It calls another new helper function
> _scsi_debug_key_path to search sysfs files corresponding to the keys in
> /sys/bus/pseudo/drivers/scsi_debug or /sys/module/scsi_debug/parameters.
> When it finds the file, it writes the value to the file. The original
> values of the files are kept in the global array SCSI_DEBUG_VALUES and
> restored by _exit_scsi_debug.
>
> Among the parameters, 'add_host' has special meaning to add new hosts.
> Then it is handled separately so that it is set at last in
> _configure_scsi_debug, and restored at first in _exit_scsi_debug. Also,
> record the hosts which exist before _configure_scsi_debug in the array
> ORIG_SCSI_DEBUG_HOSTS. Those hosts should not be used for testing, then
> do not add them to SCSI_DEBUG_HOSTS.
>
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---
>   


Looks good.

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

-ck



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-04-18 20:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-17 12:47 [PATCH blktests 0/9] support built-in scsi_debug Shin'ichiro Kawasaki
2023-04-17 12:47 ` [PATCH blktests 1/9] common/rc: skip module file check if modules path does not exist Shin'ichiro Kawasaki
2023-04-18 20:09   ` Chaitanya Kulkarni
2023-04-17 12:47 ` [PATCH blktests 2/9] common/scsi_debug, tests/*: re-define _have_scsi_debug Shin'ichiro Kawasaki
2023-04-18 20:10   ` Chaitanya Kulkarni
2023-04-17 12:47 ` [PATCH blktests 3/9] common/scsi_debug: factor out _setup_scsi_debug_vars Shin'ichiro Kawasaki
2023-04-18 20:11   ` Chaitanya Kulkarni
2023-04-17 12:47 ` [PATCH blktests 4/9] common/scsi_debug: introduce _configure_scsi_debug Shin'ichiro Kawasaki
2023-04-18 20:15   ` Chaitanya Kulkarni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).