diff mbox series

[blktests,1/6] zbd/008: check no stale page cache after BLKRESETZONE ioctl

Message ID 20220330013215.463555-2-shinichiro.kawasaki@wdc.com (mailing list archive)
State New, archived
Headers show
Series extend zoned mode coverage for scsi devices | expand

Commit Message

Shinichiro Kawasaki March 30, 2022, 1:32 a.m. UTC
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 mbox series

Patch

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