diff mbox series

[blktests] zbd/006: Test revalidate during other I/O requests

Message ID 20190314034633.13233-1-shinichiro.kawasaki@wdc.com (mailing list archive)
State New, archived
Headers show
Series [blktests] zbd/006: Test revalidate during other I/O requests | expand

Commit Message

Shinichiro Kawasaki March 14, 2019, 3:46 a.m. UTC
Since SCSI scanning occurs asynchronously, the kernel function
blk_revalidate_disk_zones() called from sd_revalidate_disk() may be
executed while write I/Os are ongoing. As a result,
blk_revalidate_disk_zones() must not cause write I/O errors by changing
zone related parameters of the device queue unless the disk has changed.
This patch allows checking this behavior and catch regressions such as
fixed by commit ccce20fc7968 ("scsi: sd_zbc: Avoid that resetting a zone
fails sporadically").

To trigger disk revalidate, fio is executed with the --loops option
causing the target device file to be closed and reopen at each loop. The
file close triggers disk revalidate and fio starts issuing I/Os before
revalidate completes, resulting in the desired simultaneous parallel
execution of write I/Os and blk_revalidate_disk_zones().

Also move the _find_first_sequential_zone() helper function from zbd/005
to zbd/rc and reuse it in the new test case for target zone selection.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 tests/zbd/005     | 13 ------------
 tests/zbd/006     | 52 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/zbd/006.out |  2 ++
 tests/zbd/rc      | 13 ++++++++++++
 4 files changed, 67 insertions(+), 13 deletions(-)
 create mode 100644 tests/zbd/006
 create mode 100644 tests/zbd/006.out

Comments

Omar Sandoval March 21, 2019, 10:07 p.m. UTC | #1
On Thu, Mar 14, 2019 at 12:46:33PM +0900, Shin'ichiro Kawasaki wrote:
> Since SCSI scanning occurs asynchronously, the kernel function
> blk_revalidate_disk_zones() called from sd_revalidate_disk() may be
> executed while write I/Os are ongoing. As a result,
> blk_revalidate_disk_zones() must not cause write I/O errors by changing
> zone related parameters of the device queue unless the disk has changed.
> This patch allows checking this behavior and catch regressions such as
> fixed by commit ccce20fc7968 ("scsi: sd_zbc: Avoid that resetting a zone
> fails sporadically").
> 
> To trigger disk revalidate, fio is executed with the --loops option
> causing the target device file to be closed and reopen at each loop. The
> file close triggers disk revalidate and fio starts issuing I/Os before
> revalidate completes, resulting in the desired simultaneous parallel
> execution of write I/Os and blk_revalidate_disk_zones().
> 
> Also move the _find_first_sequential_zone() helper function from zbd/005
> to zbd/rc and reuse it in the new test case for target zone selection.
> 
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---
>  tests/zbd/005     | 13 ------------
>  tests/zbd/006     | 52 +++++++++++++++++++++++++++++++++++++++++++++++
>  tests/zbd/006.out |  2 ++
>  tests/zbd/rc      | 13 ++++++++++++
>  4 files changed, 67 insertions(+), 13 deletions(-)
>  create mode 100644 tests/zbd/006
>  create mode 100644 tests/zbd/006.out

Thanks, applied.
diff mbox series

Patch

diff --git a/tests/zbd/005 b/tests/zbd/005
index bc9cad5..65546a6 100755
--- a/tests/zbd/005
+++ b/tests/zbd/005
@@ -25,19 +25,6 @@  cleanup_fallback_device() {
 	_exit_null_blk
 }
 
-_find_first_sequential_zone() {
-	for ((idx =  NR_CONV_ZONES; idx < REPORTED_COUNT; idx++)); do
-		if [[ ${ZONE_TYPES[idx]} -eq ${ZONE_TYPE_SEQ_WRITE_REQUIRED} ]];
-		then
-			echo "${idx}"
-			return 0
-		fi
-	done
-	echo "Sequential write required zone not found"
-
-	return 1
-}
-
 test_device() {
 	local -i zone_idx
 	local -i offset
diff --git a/tests/zbd/006 b/tests/zbd/006
new file mode 100644
index 0000000..b745acd
--- /dev/null
+++ b/tests/zbd/006
@@ -0,0 +1,52 @@ 
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2019 Western Digital Corporation or its affiliates.
+#
+# Run fio write job with loops option to cause file close and scsi disk
+# zone revalidate in parallel with write requests.
+
+. tests/zbd/rc
+
+DESCRIPTION="revalidate"
+TIMED=1
+CAN_BE_ZONED=1
+
+requires() {
+	_have_fio_zbd_zonemode
+}
+
+fallback_device() {
+	_fallback_null_blk_zoned
+}
+
+cleanup_fallback_device() {
+	_exit_null_blk
+}
+
+test_device() {
+	local -i zone_idx
+	local -i offset
+	local -i size
+
+	echo "Running ${TEST_NAME}"
+
+	_get_blkzone_report "${TEST_DEV}" || return $?
+
+	zone_idx=$(_find_first_sequential_zone) || return $?
+	offset=$((ZONE_STARTS[zone_idx] * 512))
+	size=$((ZONE_LENGTHS[zone_idx] * 512))
+
+	blkzone reset -o "${ZONE_STARTS[zone_idx]}" "${TEST_DEV}"
+
+	_test_dev_queue_set scheduler deadline
+
+	: "${TIMEOUT:=30}"
+	FIO_PERF_FIELDS=("write io" "write iops")
+	_fio_perf --filename="${TEST_DEV}" --name zbdwo --rw=randwrite \
+		  --zonemode=zbd --direct=1 --ioengine=libaio --iodepth=8 \
+		  --bs=4k --offset="${offset}" --size="${size}" --loops=8
+
+	_put_blkzone_report
+
+	echo "Test complete"
+}
diff --git a/tests/zbd/006.out b/tests/zbd/006.out
new file mode 100644
index 0000000..ee844f7
--- /dev/null
+++ b/tests/zbd/006.out
@@ -0,0 +1,2 @@ 
+Running zbd/006
+Test complete
diff --git a/tests/zbd/rc b/tests/zbd/rc
index 88538d0..5f04c84 100644
--- a/tests/zbd/rc
+++ b/tests/zbd/rc
@@ -180,6 +180,19 @@  _reset_zones() {
 	fi
 }
 
+_find_first_sequential_zone() {
+	for ((idx =  NR_CONV_ZONES; idx < REPORTED_COUNT; idx++)); do
+		if [[ ${ZONE_TYPES[idx]} -eq ${ZONE_TYPE_SEQ_WRITE_REQUIRED} ]];
+		then
+			echo "${idx}"
+			return 0
+		fi
+	done
+	echo "Sequential write required zone not found"
+
+	return 1
+}
+
 # Search zones and find two contiguous sequential required zones.
 # Return index of the first zone of the found two zones.
 # Call _get_blkzone_report() beforehand.