* [PATCH blktests 1/6] zbd/008: check no stale page cache after BLKRESETZONE ioctl
2022-03-30 1:32 [PATCH blktests 0/6] extend zoned mode coverage for scsi devices Shin'ichiro Kawasaki
@ 2022-03-30 1:32 ` Shin'ichiro Kawasaki
2022-03-30 1:32 ` [PATCH blktests 2/6] common/scsi_debug: prepare scsi_debug in zoned mode Shin'ichiro Kawasaki
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Shin'ichiro Kawasaki @ 2022-03-30 1:32 UTC (permalink / raw)
To: linux-block, Omar Sandoval
Cc: Omar Sandoval, Damien Le Moal, Johannes Thumshirn, Niklas Cassel,
Shin'ichiro Kawasaki
Run two processes which repeat data read and BLKRESETZONE ioctl, and
check that the race does not leave stale page cache. This allows to
catch the bug fixed with the commit e5113505904e ("block: Discard page
cache of # zone reset target range").
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
tests/zbd/008 | 54 +++++++++++++++++++++++++++++++++++++++++++++++
tests/zbd/008.out | 2 ++
2 files changed, 56 insertions(+)
create mode 100755 tests/zbd/008
create mode 100644 tests/zbd/008.out
diff --git a/tests/zbd/008 b/tests/zbd/008
new file mode 100755
index 0000000..c625bad
--- /dev/null
+++ b/tests/zbd/008
@@ -0,0 +1,54 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2022 Western Digital Corporation or its affiliates.
+#
+# Check stale page cache is not left after race between BLKZONERESET and data
+# read. Regression test for commit e5113505904e ("block: Discard page cache of
+# zone reset target range").
+
+. tests/block/rc
+. common/scsi_debug
+
+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
+}
+
+test() {
+ local dev dump
+ echo "Running ${TEST_NAME}"
+
+ rm -f "$FULL"
+
+ # Create virtual device with zones
+ if ! _init_scsi_debug dev_size_mb=32 \
+ zbc=host-managed zone_nr_conv=0; then
+ return 1
+ fi
+ dev="/dev/${SCSI_DEBUG_DEVICES[0]}"
+
+ # Run read workload
+ : "${TIMEOUT:=10}"
+ _run_fio --filename="$dev" --size="32M" --rw=randread \
+ --norandommap --name=reads --time_based &
+
+ while kill -0 $! 2>/dev/null; do
+ # Fill the device with known pattern
+ xfs_io -c "pwrite -S 0xaa -b 2M 0 32M" -d "$dev" >> "$FULL"
+
+ # Data read should return zero data pattern after zone reset
+ blkzone reset "$dev"
+ dump=$(dd if="$dev" bs=4k 2>> "$FULL" | hexdump -e '"%x"')
+ if [[ $dump != "0*" ]]; then
+ echo "$dump"
+ break
+ fi
+ done
+
+ _exit_scsi_debug
+
+ echo "Test complete"
+}
diff --git a/tests/zbd/008.out b/tests/zbd/008.out
new file mode 100644
index 0000000..08575bd
--- /dev/null
+++ b/tests/zbd/008.out
@@ -0,0 +1,2 @@
+Running zbd/008
+Test complete
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH blktests 2/6] common/scsi_debug: prepare scsi_debug in zoned mode
2022-03-30 1:32 [PATCH blktests 0/6] extend zoned mode coverage for scsi devices Shin'ichiro Kawasaki
2022-03-30 1:32 ` [PATCH blktests 1/6] zbd/008: check no stale page cache after BLKRESETZONE ioctl Shin'ichiro Kawasaki
@ 2022-03-30 1:32 ` Shin'ichiro Kawasaki
2022-03-30 1:32 ` [PATCH blktests 3/6] block/027, scsi/004: whitelist scsi_debug test cases for " Shin'ichiro Kawasaki
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Shin'ichiro Kawasaki @ 2022-03-30 1:32 UTC (permalink / raw)
To: linux-block, Omar Sandoval
Cc: Omar Sandoval, Damien Le Moal, Johannes Thumshirn, Niklas Cassel,
Shin'ichiro Kawasaki
To allow running tests using scsi_debug device with the zoned mode
disabled (current setup) as well as enabled, modify the _init_scsi_debug
helper function. When RUN_FOR_ZONED is set, specify zbc=host-managed
parameter to scsi_debug module so that the scsi_debug devices are
prepared in zoned mode.
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
common/scsi_debug | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/common/scsi_debug b/common/scsi_debug
index b48cdc9..95da14e 100644
--- a/common/scsi_debug
+++ b/common/scsi_debug
@@ -9,7 +9,16 @@ _have_scsi_debug() {
}
_init_scsi_debug() {
- if ! modprobe -r scsi_debug || ! modprobe scsi_debug "$@"; then
+ 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
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH blktests 3/6] block/027, scsi/004: whitelist scsi_debug test cases for zoned mode
2022-03-30 1:32 [PATCH blktests 0/6] extend zoned mode coverage for scsi devices Shin'ichiro Kawasaki
2022-03-30 1:32 ` [PATCH blktests 1/6] zbd/008: check no stale page cache after BLKRESETZONE ioctl Shin'ichiro Kawasaki
2022-03-30 1:32 ` [PATCH blktests 2/6] common/scsi_debug: prepare scsi_debug in zoned mode Shin'ichiro Kawasaki
@ 2022-03-30 1:32 ` Shin'ichiro Kawasaki
2022-03-30 1:32 ` [PATCH blktests 4/6] scsi/006: whitelist " Shin'ichiro Kawasaki
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Shin'ichiro Kawasaki @ 2022-03-30 1:32 UTC (permalink / raw)
To: linux-block, Omar Sandoval
Cc: Omar Sandoval, Damien Le Moal, Johannes Thumshirn, Niklas Cassel,
Shin'ichiro Kawasaki
Define CAN_BE_ZONED=1 in block/027 and scsi/004. These test cases can be
executed in zoned mode without problem against scsi_debug devices in
zoned mode.
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
tests/block/027 | 1 +
tests/scsi/004 | 1 +
2 files changed, 2 insertions(+)
diff --git a/tests/block/027 b/tests/block/027
index e818bf7..b60f62c 100755
--- a/tests/block/027
+++ b/tests/block/027
@@ -16,6 +16,7 @@
DESCRIPTION="stress device hotplugging with running fio jobs and different schedulers"
QUICK=1
+CAN_BE_ZONED=1
requires() {
_have_cgroup2_controller io && _have_scsi_debug && _have_fio
diff --git a/tests/scsi/004 b/tests/scsi/004
index 416117a..b5ef2dd 100755
--- a/tests/scsi/004
+++ b/tests/scsi/004
@@ -15,6 +15,7 @@
. common/scsi_debug
DESCRIPTION="ensure repeated TASK SET FULL results in EIO on timing out command"
+CAN_BE_ZONED=1
requires() {
_have_scsi_debug
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH blktests 4/6] scsi/006: whitelist for zoned mode
2022-03-30 1:32 [PATCH blktests 0/6] extend zoned mode coverage for scsi devices Shin'ichiro Kawasaki
` (2 preceding siblings ...)
2022-03-30 1:32 ` [PATCH blktests 3/6] block/027, scsi/004: whitelist scsi_debug test cases for " Shin'ichiro Kawasaki
@ 2022-03-30 1:32 ` Shin'ichiro Kawasaki
2022-03-30 1:32 ` [PATCH blktests 5/6] scsi/006: skip cache types which disable read cache for SATA drives Shin'ichiro Kawasaki
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Shin'ichiro Kawasaki @ 2022-03-30 1:32 UTC (permalink / raw)
To: linux-block, Omar Sandoval
Cc: Omar Sandoval, Damien Le Moal, Johannes Thumshirn, Niklas Cassel,
Shin'ichiro Kawasaki
Define CAN_BE_ZONED=1 in scsi/006. This test case can be executed
without problem against zoned SCSI devices specified in TEST_DEVS, such
as SMR HDDs.
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
tests/scsi/006 | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/scsi/006 b/tests/scsi/006
index 05ed652..74df39d 100755
--- a/tests/scsi/006
+++ b/tests/scsi/006
@@ -10,6 +10,7 @@
DESCRIPTION="toggle SCSI cache type"
QUICK=1
+CAN_BE_ZONED=1
device_requires() {
_require_test_dev_is_scsi_disk
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH blktests 5/6] scsi/006: skip cache types which disable read cache for SATA drives
2022-03-30 1:32 [PATCH blktests 0/6] extend zoned mode coverage for scsi devices Shin'ichiro Kawasaki
` (3 preceding siblings ...)
2022-03-30 1:32 ` [PATCH blktests 4/6] scsi/006: whitelist " Shin'ichiro Kawasaki
@ 2022-03-30 1:32 ` Shin'ichiro Kawasaki
2022-03-30 1:32 ` [PATCH blktests 6/6] scsi/003: remove unnecessary out file Shin'ichiro Kawasaki
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Shin'ichiro Kawasaki @ 2022-03-30 1:32 UTC (permalink / raw)
To: linux-block, Omar Sandoval
Cc: Omar Sandoval, Damien Le Moal, Johannes Thumshirn, Niklas Cassel,
Shin'ichiro Kawasaki
The test case scsi/006 sets four cache types to test target SCSI
devices. Two cache types out of the four, "none" and "write back, no
read (daft)" disable read cache. However, these two types do not work
for SATA drives since SAT specification requires Disable Read Cache is
always set to zero in the caching mode page. It results in invalid
argument error and the test case failure.
To avoid the failure, skip the cache types which disable read cache if
the test devices are SATA drives. To check the device, add a helper
function _test_dev_is_sata in scsi/rc.
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
tests/scsi/006 | 4 ++++
tests/scsi/rc | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/tests/scsi/006 b/tests/scsi/006
index 74df39d..fe1d202 100755
--- a/tests/scsi/006
+++ b/tests/scsi/006
@@ -35,6 +35,10 @@ test_device() {
original_cache_type="$(cat "$cache_type_path")"
for cache_type in "${cache_types[@]}"; do
echo "$cache_type"
+ # SAT requires Read Cache Disable always set to zero.
+ # Skip cache types which disable read cache for SATA drives.
+ _test_dev_is_sata && [[ $cache_type == none ]] ||
+ [[ $cache_type =~ "no read" ]] && continue
( echo "$cache_type" > "$cache_type_path" ) |& grep -v "Invalid argument"
if [[ ${PIPESTATUS[0]} -eq 0 ]]; then
# If setting the cache type succeeded, it should now
diff --git a/tests/scsi/rc b/tests/scsi/rc
index 1477cec..c8d2f42 100644
--- a/tests/scsi/rc
+++ b/tests/scsi/rc
@@ -37,3 +37,7 @@ _require_test_dev_is_scsi_disk() {
_get_test_dev_sg() {
echo "${TEST_DEV_SYSFS}"/device/scsi_generic/sg* | grep -Eo "sg[0-9]+"
}
+
+_test_dev_is_sata() {
+ [[ $(<"${TEST_DEV_SYSFS}"/device/vendor) == "ATA " ]]
+}
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH blktests 6/6] scsi/003: remove unnecessary out file
2022-03-30 1:32 [PATCH blktests 0/6] extend zoned mode coverage for scsi devices Shin'ichiro Kawasaki
` (4 preceding siblings ...)
2022-03-30 1:32 ` [PATCH blktests 5/6] scsi/006: skip cache types which disable read cache for SATA drives Shin'ichiro Kawasaki
@ 2022-03-30 1:32 ` Shin'ichiro Kawasaki
2022-04-27 13:46 ` [PATCH blktests 0/6] extend zoned mode coverage for scsi devices Johannes Thumshirn
2022-05-09 19:16 ` Omar Sandoval
7 siblings, 0 replies; 9+ messages in thread
From: Shin'ichiro Kawasaki @ 2022-03-30 1:32 UTC (permalink / raw)
To: linux-block, Omar Sandoval
Cc: Omar Sandoval, Damien Le Moal, Johannes Thumshirn, Niklas Cassel,
Shin'ichiro Kawasaki
The test case scsi/003 was removed with the commit 5e803ca0ae99 ("Remove
partition rereading tests for reverted fixes"), but its out file was
left. Remove it.
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
tests/scsi/003.out | 7 -------
1 file changed, 7 deletions(-)
delete mode 100644 tests/scsi/003.out
diff --git a/tests/scsi/003.out b/tests/scsi/003.out
deleted file mode 100644
index b9c2450..0000000
--- a/tests/scsi/003.out
+++ /dev/null
@@ -1,7 +0,0 @@
-Running scsi/003
-1
-1
-Operation not permitted
-0
-0
-Test complete
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH blktests 0/6] extend zoned mode coverage for scsi devices
2022-03-30 1:32 [PATCH blktests 0/6] extend zoned mode coverage for scsi devices Shin'ichiro Kawasaki
` (5 preceding siblings ...)
2022-03-30 1:32 ` [PATCH blktests 6/6] scsi/003: remove unnecessary out file Shin'ichiro Kawasaki
@ 2022-04-27 13:46 ` Johannes Thumshirn
2022-05-09 19:16 ` Omar Sandoval
7 siblings, 0 replies; 9+ messages in thread
From: Johannes Thumshirn @ 2022-04-27 13:46 UTC (permalink / raw)
To: Shinichiro Kawasaki, linux-block@vger.kernel.org, Omar Sandoval
Cc: Omar Sandoval, Damien Le Moal, Niklas Cassel
For the series:
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH blktests 0/6] extend zoned mode coverage for scsi devices
2022-03-30 1:32 [PATCH blktests 0/6] extend zoned mode coverage for scsi devices Shin'ichiro Kawasaki
` (6 preceding siblings ...)
2022-04-27 13:46 ` [PATCH blktests 0/6] extend zoned mode coverage for scsi devices Johannes Thumshirn
@ 2022-05-09 19:16 ` Omar Sandoval
7 siblings, 0 replies; 9+ messages in thread
From: Omar Sandoval @ 2022-05-09 19:16 UTC (permalink / raw)
To: Shin'ichiro Kawasaki
Cc: linux-block, Omar Sandoval, Damien Le Moal, Johannes Thumshirn,
Niklas Cassel
On Wed, Mar 30, 2022 at 10:32:09AM +0900, Shin'ichiro Kawasaki wrote:
> This patch series extends blktests coverage in zoned mode on scsi devices.
> Recently scsi_debug introduced ZBC support and can work in zoned mode. The first
> patch adds a new test case zbd/008 using scsi_debug in zoned mode. The second
> and third patches allow test cases block/027 and scsi/004 to run in zoned mode
> using scsi_debug. Following three patches are scsi test group improvements
> unrelated to scsi_debug. The fourth patch allows scsi/006 to run on SCSI devices
> in zoned mode. The fifth patch is a bug fix in scsi/006. The last patch removes
> an unnecessary scsi/003 out file.
>
> Shin'ichiro Kawasaki (6):
> zbd/008: check no stale page cache after BLKRESETZONE ioctl
> common/scsi_debug: prepare scsi_debug in zoned mode
> block/027, scsi/004: whitelist scsi_debug test cases for zoned mode
> scsi/006: whitelist for zoned mode
> scsi/006: skip cache types which disable read cache for SATA drives
> scsi/003: remove unnecessary out file
>
> common/scsi_debug | 11 +++++++++-
> tests/block/027 | 1 +
> tests/scsi/003.out | 7 ------
> tests/scsi/004 | 1 +
> tests/scsi/006 | 5 +++++
> tests/scsi/rc | 4 ++++
> tests/zbd/008 | 54 ++++++++++++++++++++++++++++++++++++++++++++++
> tests/zbd/008.out | 2 ++
> 8 files changed, 77 insertions(+), 8 deletions(-)
> delete mode 100644 tests/scsi/003.out
> create mode 100755 tests/zbd/008
> create mode 100644 tests/zbd/008.out
Thank you for the patches, applied.
^ permalink raw reply [flat|nested] 9+ messages in thread