]> www.infradead.org Git - users/hch/blktests.git/commitdiff
zbd/008: check no stale page cache after BLKRESETZONE ioctl
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Wed, 30 Mar 2022 01:32:10 +0000 (10:32 +0900)
committerOmar Sandoval <osandov@fb.com>
Mon, 9 May 2022 19:11:16 +0000 (12:11 -0700)
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").

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
tests/zbd/008 [new file with mode: 0755]
tests/zbd/008.out [new file with mode: 0644]

diff --git a/tests/zbd/008 b/tests/zbd/008
new file mode 100755 (executable)
index 0000000..c625bad
--- /dev/null
@@ -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 (file)
index 0000000..08575bd
--- /dev/null
@@ -0,0 +1,2 @@
+Running zbd/008
+Test complete