* [PATCH blktests 1/3] Introduce the io_schedulers() function
2022-04-27 21:31 [PATCH blktests 0/3] Add QD=1 and gap zone tests Bart Van Assche
@ 2022-04-27 21:31 ` Bart Van Assche
2022-04-28 3:50 ` Shinichiro Kawasaki
2022-04-27 21:31 ` [PATCH blktests 2/3] Add I/O scheduler tests for queue depth 1 Bart Van Assche
2022-04-27 21:31 ` [PATCH blktests 3/3] tests/scsi: Add tests for SCSI devices with gap zones Bart Van Assche
2 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2022-04-27 21:31 UTC (permalink / raw)
To: Omar Sandoval; +Cc: linux-block, Bart Van Assche
The functionality for retrieving the I/O schedulers supported by a request
queue occurs multiple times. Hence introduce a function for retrieving the
supported I/O schedulers.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
common/iosched | 12 ++++++++++++
common/multipath-over-rdma | 11 -----------
tests/block/005 | 4 ++--
tests/block/014 | 7 ++-----
tests/block/015 | 7 ++-----
tests/block/020 | 7 ++-----
tests/block/021 | 6 ++----
tests/nvmeof-mp/012 | 3 ++-
tests/srp/012 | 3 ++-
9 files changed, 26 insertions(+), 34 deletions(-)
create mode 100644 common/iosched
diff --git a/common/iosched b/common/iosched
new file mode 100644
index 000000000000..5dd46216afcb
--- /dev/null
+++ b/common/iosched
@@ -0,0 +1,12 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2022 Google LLC
+
+# Prints a space-separated list with the names of all I/O schedulers supported
+# by block device $1.
+io_schedulers() {
+ local path=/sys/class/block/$1/queue/scheduler
+
+ [ -e "${path}" ] || return 1
+ sed 's/[][]//g' "${path}"
+}
diff --git a/common/multipath-over-rdma b/common/multipath-over-rdma
index cef05ec92d29..75a5c832d6da 100644
--- a/common/multipath-over-rdma
+++ b/common/multipath-over-rdma
@@ -298,17 +298,6 @@ set_scheduler() {
fi
}
-# Get block dev scheduler list
-get_scheduler_list() {
- local b=$1 p
- p=/sys/block/"$b"/queue/scheduler
- if [ -e "$p" ]; then
- sed 's/[][]//g' /sys/block/"$b"/queue/scheduler
- else
- return 1
- fi
-}
-
# Get a /dev/... path that points at dm device number $1. Set its I/O scheduler
# to $2 and its timeout to $3. The shell script that includes this file must
# define a function get_bdev_path() that translates device number $1 into a
diff --git a/tests/block/005 b/tests/block/005
index 77b9e2f57203..383c8f5b7d2b 100755
--- a/tests/block/005
+++ b/tests/block/005
@@ -5,6 +5,7 @@
# Threads doing IO to a device, while we switch schedulers
. tests/block/rc
+. common/iosched
DESCRIPTION="switch schedulers while doing IO"
TIMED=1
@@ -17,9 +18,8 @@ requires() {
test_device() {
echo "Running ${TEST_NAME}"
- local scheds
# shellcheck disable=SC2207
- scheds=($(sed 's/[][]//g' "${TEST_DEV_SYSFS}/queue/scheduler"))
+ local scheds=($(io_schedulers "${TEST_DEV_SYSFS}"))
if _test_dev_is_rotational; then
size="32m"
diff --git a/tests/block/014 b/tests/block/014
index 04c34fa12b5c..78e90269389e 100755
--- a/tests/block/014
+++ b/tests/block/014
@@ -6,6 +6,7 @@
. tests/block/rc
. common/null_blk
+. common/iosched
DESCRIPTION="run null-blk with blk-mq and timeout injection configured"
@@ -22,11 +23,7 @@ test() {
return 1
fi
- local scheds
- # shellcheck disable=SC2207
- scheds=($(sed 's/[][]//g' /sys/block/nullb0/queue/scheduler))
-
- for sched in "${scheds[@]}"; do
+ for sched in $(io_schedulers nullb0); do
echo "Testing $sched" >> "$FULL"
echo "$sched" > /sys/block/nullb0/queue/scheduler
# Do a bunch of I/Os which will timeout and then complete. The
diff --git a/tests/block/015 b/tests/block/015
index 79102a2bea54..5eb954b4906c 100755
--- a/tests/block/015
+++ b/tests/block/015
@@ -7,6 +7,7 @@
. tests/block/rc
. common/null_blk
+. common/iosched
DESCRIPTION="run null-blk on different schedulers with requeue injection configured"
QUICK=1
@@ -24,11 +25,7 @@ test() {
return 1
fi
- local scheds
- # shellcheck disable=SC2207
- scheds=($(sed 's/[][]//g' /sys/block/nullb0/queue/scheduler))
-
- for sched in "${scheds[@]}"; do
+ for sched in $(io_schedulers nullb0); do
echo "Testing $sched" >> "$FULL"
echo "$sched" > /sys/block/nullb0/queue/scheduler
dd if=/dev/nullb0 of=/dev/null bs=4K count=$((512 * 1024)) \
diff --git a/tests/block/020 b/tests/block/020
index b4887a26ff0a..0301129e1c1d 100755
--- a/tests/block/020
+++ b/tests/block/020
@@ -8,6 +8,7 @@
. tests/block/rc
. common/null_blk
+. common/iosched
DESCRIPTION="run null-blk on different schedulers with only one hardware tag"
QUICK=1
@@ -25,16 +26,12 @@ test() {
return 1
fi
- local scheds
- # shellcheck disable=SC2207
- scheds=($(sed 's/[][]//g' /sys/block/nullb0/queue/scheduler))
-
local max_iodepth=$(($(cat /proc/sys/fs/aio-max-nr) / $(nproc)))
local iodepth=1024
if (( iodepth > max_iodepth )); then
iodepth=$max_iodepth
fi
- for sched in "${scheds[@]}"; do
+ for sched in $(io_schedulers nullb0); do
echo "Testing $sched" >> "$FULL"
echo "$sched" > /sys/block/nullb0/queue/scheduler
_fio_perf --bs=4k --ioengine=libaio --iodepth=$iodepth \
diff --git a/tests/block/021 b/tests/block/021
index a1bbf45a3bc9..7b562de0f99c 100755
--- a/tests/block/021
+++ b/tests/block/021
@@ -8,6 +8,7 @@
. tests/block/rc
. common/null_blk
+. common/iosched
DESCRIPTION="read/write nr_requests on null-blk with different schedulers"
QUICK=1
@@ -26,11 +27,8 @@ test() {
local max_nr
local nr
- local scheds
- # shellcheck disable=SC2207
- scheds=($(sed 's/[][]//g' /sys/block/nullb0/queue/scheduler))
- for sched in "${scheds[@]}"; do
+ for sched in $(io_schedulers nullb0); do
echo "Testing $sched" >> "$FULL"
echo "$sched" > /sys/block/nullb0/queue/scheduler
max_nr="$(cat /sys/block/nullb0/queue/nr_requests)"
diff --git a/tests/nvmeof-mp/012 b/tests/nvmeof-mp/012
index 8b2e918773e5..0b56dfb46d1e 100755
--- a/tests/nvmeof-mp/012
+++ b/tests/nvmeof-mp/012
@@ -3,6 +3,7 @@
# Copyright (c) 2018 Western Digital Corporation or its affiliates
. tests/nvmeof-mp/rc
+. common/iosched
DESCRIPTION="dm-mpath on top of multiple I/O schedulers"
QUICK=1
@@ -18,7 +19,7 @@ test_io_schedulers() {
use_blk_mq ${mq} || return $?
dev=$(get_bdev 0) || return $?
dm=$(basename "$(readlink -f "${dev}")") || return $?
- scheds="$(get_scheduler_list "$dm")" || return $?
+ scheds="$(io_schedulers "$dm")" || return $?
for sched in $scheds; do
set_scheduler "$dm" "$sched" \
>>"$FULL" 2>&1 || continue
diff --git a/tests/srp/012 b/tests/srp/012
index 1a2fc6d2dc2f..7c72288b773b 100755
--- a/tests/srp/012
+++ b/tests/srp/012
@@ -3,6 +3,7 @@
# Copyright (c) 2018 Western Digital Corporation or its affiliates
. tests/srp/rc
+. common/iosched
DESCRIPTION="dm-mpath on top of multiple I/O schedulers"
QUICK=1
@@ -22,7 +23,7 @@ test_io_schedulers() {
use_blk_mq ${mq} ${mq} || return $?
dev=$(get_bdev 0) || return $?
dm=$(basename "$(readlink -f "${dev}")") || return $?
- scheds="$(get_scheduler_list "$dm")" || return $?
+ scheds="$(io_schedulers "$dm")" || return $?
for sched in $scheds; do
set_scheduler "$dm" "$sched" \
>>"$FULL" 2>&1 || continue
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH blktests 2/3] Add I/O scheduler tests for queue depth 1
2022-04-27 21:31 [PATCH blktests 0/3] Add QD=1 and gap zone tests Bart Van Assche
2022-04-27 21:31 ` [PATCH blktests 1/3] Introduce the io_schedulers() function Bart Van Assche
@ 2022-04-27 21:31 ` Bart Van Assche
2022-04-28 6:27 ` Shinichiro Kawasaki
2022-04-27 21:31 ` [PATCH blktests 3/3] tests/scsi: Add tests for SCSI devices with gap zones Bart Van Assche
2 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2022-04-27 21:31 UTC (permalink / raw)
To: Omar Sandoval; +Cc: linux-block, Bart Van Assche
Some block devices, e.g. USB sticks, only support queue depth 1. The
QD=1 code paths do not get tested routinely. Hence add tests for the
QD=1 use case.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
common/rc | 5 ++++
tests/block/032 | 62 ++++++++++++++++++++++++++++++++++++++++++++
tests/block/032.out | 2 ++
tests/scsi/008 | 63 +++++++++++++++++++++++++++++++++++++++++++++
tests/scsi/008.out | 2 ++
5 files changed, 134 insertions(+)
create mode 100755 tests/block/032
create mode 100644 tests/block/032.out
create mode 100755 tests/scsi/008
create mode 100644 tests/scsi/008.out
diff --git a/common/rc b/common/rc
index 0528ce808256..2377e223aea7 100644
--- a/common/rc
+++ b/common/rc
@@ -321,6 +321,11 @@ _uptime_s() {
awk '{ print int($1) }' /proc/uptime
}
+# System uptime in centiseconds.
+_uptime_cs() {
+ sed 's/\.//;s/ .*//' /proc/uptime
+}
+
# Arguments: module to unload ($1) and retry count ($2).
unload_module() {
local i m=$1 rc=${2:-1}
diff --git a/tests/block/032 b/tests/block/032
new file mode 100755
index 000000000000..8b4d30282988
--- /dev/null
+++ b/tests/block/032
@@ -0,0 +1,62 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2022 Google LLC
+
+. tests/block/rc
+. common/null_blk
+. common/iosched
+
+DESCRIPTION="test I/O scheduler performance of null_blk with queue_depth 1"
+QUICK=1
+
+requires() {
+ _have_null_blk
+}
+
+# Measure the time required to perform I/O on dev $1 with I/O scheduler $2.
+sched_time() {
+ local dev=$1 sched=$2
+ echo "$sched" > "/sys/block/$dev/queue/scheduler"
+ local start
+ start=$(_uptime_cs)
+ dd if="/dev/$dev" of=/dev/null bs=4K count=$((512 * 1024)) \
+ iflag=direct status=none &
+ dd of="/dev/$dev" if=/dev/zero bs=4K count=$((512 * 1024)) \
+ oflag=direct status=none &
+ wait
+ echo $(($(_uptime_cs) - start))
+}
+
+test() {
+ echo "Running ${TEST_NAME}"
+
+ local params=(
+ hw_queue_depth=1
+ queue_mode=2
+ )
+ _init_null_blk "${params[@]}" || return 1
+
+ local dev=nullb0 fail status
+
+ none_time_cs=$(sched_time "$dev" none)
+ for sched in $(io_schedulers "$dev"); do
+ [ "$sched" = none ] && continue
+ time_cs=$(sched_time "$dev" "$sched")
+ if [ "$time_cs" -lt $(("$none_time_cs" * 110 / 100)) ]; then
+ status=pass
+ else
+ status=fail
+ fail=true
+ fi
+ TEST_RUN[$sched]="$time_cs vs $none_time_cs: $status"
+ done
+
+ _exit_null_blk
+
+ if [ -z "$fail" ]; then
+ echo "Test complete"
+ else
+ echo "Test failed"
+ return 1
+ fi
+}
diff --git a/tests/block/032.out b/tests/block/032.out
new file mode 100644
index 000000000000..3604e9e1e751
--- /dev/null
+++ b/tests/block/032.out
@@ -0,0 +1,2 @@
+Running block/032
+Test complete
diff --git a/tests/scsi/008 b/tests/scsi/008
new file mode 100755
index 000000000000..dec304fd29a2
--- /dev/null
+++ b/tests/scsi/008
@@ -0,0 +1,63 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2022 Google LLC
+
+. tests/scsi/rc
+. common/iosched
+. common/scsi_debug
+
+DESCRIPTION="test I/O scheduler performance of scsi_debug with queue_depth 1"
+QUICK=1
+
+requires() {
+ _have_scsi_debug
+}
+
+# Measure the time required to perform I/O on dev $1 with I/O scheduler $2.
+sched_time() {
+ local dev=$1 sched=$2
+ echo "$sched" > "/sys/block/$dev/queue/scheduler"
+ local start
+ start=$(_uptime_cs)
+ dd if="/dev/$dev" of=/dev/null bs=4K count=$((512 * 1024)) \
+ iflag=direct status=none &
+ dd of="/dev/$dev" if=/dev/zero bs=4K count=$((512 * 1024)) \
+ oflag=direct status=none &
+ wait
+ echo $(($(_uptime_cs) - start))
+}
+
+test() {
+ echo "Running ${TEST_NAME}"
+
+ local params=(
+ delay=0
+ dev_size_mb=2048
+ host_max_queue=1
+ )
+ _init_scsi_debug "${params[@]}" || return 1
+
+ local dev="${SCSI_DEBUG_DEVICES[0]}" fail
+
+ none_time_cs=$(sched_time "$dev" none)
+ for sched in $(io_schedulers "$dev"); do
+ [ "$sched" = none ] && continue
+ time_cs=$(sched_time "$dev" "$sched")
+ if [ "$time_cs" -lt $(("$none_time_cs" * 110 / 100)) ]; then
+ status=pass
+ else
+ status=fail
+ fail=true
+ fi
+ TEST_RUN[$sched]="$time_cs vs $none_time_cs: $status"
+ done
+
+ _exit_scsi_debug
+
+ if [ -z "$fail" ]; then
+ echo "Test complete"
+ else
+ echo "Test failed"
+ return 1
+ fi
+}
diff --git a/tests/scsi/008.out b/tests/scsi/008.out
new file mode 100644
index 000000000000..135bd5ae4b2d
--- /dev/null
+++ b/tests/scsi/008.out
@@ -0,0 +1,2 @@
+Running scsi/008
+Test complete
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH blktests 3/3] tests/scsi: Add tests for SCSI devices with gap zones
2022-04-27 21:31 [PATCH blktests 0/3] Add QD=1 and gap zone tests Bart Van Assche
2022-04-27 21:31 ` [PATCH blktests 1/3] Introduce the io_schedulers() function Bart Van Assche
2022-04-27 21:31 ` [PATCH blktests 2/3] Add I/O scheduler tests for queue depth 1 Bart Van Assche
@ 2022-04-27 21:31 ` Bart Van Assche
2022-04-28 0:39 ` Shinichiro Kawasaki
2 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2022-04-27 21:31 UTC (permalink / raw)
To: Omar Sandoval; +Cc: linux-block, Bart Van Assche
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
tests/scsi/009 | 56 +++++++++++++++++++++++++++++++++++++
tests/scsi/009.out | 2 ++
tests/scsi/010 | 70 ++++++++++++++++++++++++++++++++++++++++++++++
tests/scsi/010.out | 2 ++
4 files changed, 130 insertions(+)
create mode 100755 tests/scsi/009
create mode 100644 tests/scsi/009.out
create mode 100644 tests/scsi/010
create mode 100644 tests/scsi/010.out
diff --git a/tests/scsi/009 b/tests/scsi/009
new file mode 100755
index 000000000000..38f771f14e02
--- /dev/null
+++ b/tests/scsi/009
@@ -0,0 +1,56 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2022 Google LLC
+
+. tests/scsi/rc
+. common/scsi_debug
+
+DESCRIPTION="test gap zone support with BTRFS"
+QUICK=1
+
+requires() {
+ _have_fio &&
+ _have_module_param scsi_debug zone_cap_mb &&
+ _have_program mkfs.btrfs
+}
+
+test() {
+ echo "Running ${TEST_NAME}"
+
+ local params=(
+ delay=0
+ dev_size_mb=1024
+ sector_size=4096
+ zbc=host-managed
+ zone_cap_mb=3
+ zone_nr_conv=16
+ zone_size_mb=4
+ )
+ _init_scsi_debug "${params[@]}" || return 1
+
+ local dev="/dev/${SCSI_DEBUG_DEVICES[0]}" fail
+
+ mkfs.btrfs "${dev}" >>"${FULL}" 2>&1 &&
+ local mount_dir="$TMPDIR/mnt" &&
+ mkdir -p "${mount_dir}" &&
+ mount -t btrfs "${dev}" "${mount_dir}" &&
+ local fio_args=(
+ --size=1M
+ --directory="${mount_dir}"
+ --time_based
+ --runtime=10
+ ) &&
+ _run_fio_verify_io "${fio_args[@]}" >>"${FULL}" 2>&1 ||
+ fail=true
+
+ umount "${mount_dir}" >>"${FULL}" 2>&1
+
+ _exit_scsi_debug
+
+ if [ -z "$fail" ]; then
+ echo "Test complete"
+ else
+ echo "Test failed"
+ return 1
+ fi
+}
diff --git a/tests/scsi/009.out b/tests/scsi/009.out
new file mode 100644
index 000000000000..f6db2a371d9e
--- /dev/null
+++ b/tests/scsi/009.out
@@ -0,0 +1,2 @@
+Running scsi/009
+Test complete
diff --git a/tests/scsi/010 b/tests/scsi/010
new file mode 100644
index 000000000000..4fdc6f82e732
--- /dev/null
+++ b/tests/scsi/010
@@ -0,0 +1,70 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2022 Google LLC
+
+. tests/scsi/rc
+. common/null_blk
+. common/scsi_debug
+
+DESCRIPTION="test gap zone support with F2FS"
+QUICK=1
+
+requires() {
+ _have_fio &&
+ _have_modules null_blk &&
+ _have_module_param scsi_debug zone_cap_mb &&
+ _have_program mkfs.f2fs
+}
+
+test() {
+ echo "Running ${TEST_NAME}"
+
+ local mount_dir="$TMPDIR/mnt"
+
+ local null_blk_params=(
+ blocksize=4096
+ completion_nsec=0
+ memory_backed=1
+ size=1024 # MB
+ submit_queues=1
+ power=1
+ )
+ _init_null_blk nr_devices=0 queue_mode=2 &&
+ _configure_null_blk nullb0 "${null_blk_params[@]}" || return $?
+ local cdev=/dev/nullb0
+
+ local scsi_debug_params=(
+ delay=0
+ dev_size_mb=1024
+ sector_size=4096
+ zbc=host-managed
+ zone_cap_mb=3
+ zone_nr_conv=0
+ zone_size_mb=4
+ )
+ _init_scsi_debug "${scsi_debug_params[@]}" &&
+ local zdev="/dev/${SCSI_DEBUG_DEVICES[0]}" fail &&
+ ls -ld "${cdev}" "${zdev}" >>"${FULL}" &&
+ mkfs.f2fs -m "${cdev}" -c "${zdev}" >>"${FULL}" 2>&1 &&
+ mkdir -p "${mount_dir}" &&
+ mount -t f2fs "${cdev}" "${mount_dir}" &&
+ local fio_args=(
+ --size=1M
+ --directory="${mount_dir}"
+ --time_based
+ --runtime=10
+ ) &&
+ _run_fio_verify_io "${fio_args[@]}" >>"${FULL}" 2>&1 ||
+ fail=true
+
+ umount "${mount_dir}" >>"${FULL}" 2>&1
+ _exit_scsi_debug
+ _exit_null_blk
+
+ if [ -z "$fail" ]; then
+ echo "Test complete"
+ else
+ echo "Test failed"
+ return 1
+ fi
+}
diff --git a/tests/scsi/010.out b/tests/scsi/010.out
new file mode 100644
index 000000000000..6581d5eb2c5a
--- /dev/null
+++ b/tests/scsi/010.out
@@ -0,0 +1,2 @@
+Running scsi/010
+Test complete
^ permalink raw reply related [flat|nested] 11+ messages in thread