From: Bart Van Assche <bvanassche@acm.org>
To: Omar Sandoval <osandov@fb.com>
Cc: linux-block@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>
Subject: [PATCH blktests 1/3] Introduce the io_schedulers() function
Date: Wed, 27 Apr 2022 14:31:41 -0700 [thread overview]
Message-ID: <20220427213143.2490653-2-bvanassche@acm.org> (raw)
In-Reply-To: <20220427213143.2490653-1-bvanassche@acm.org>
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
next prev parent reply other threads:[~2022-04-27 21:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2022-04-28 3:50 ` [PATCH blktests 1/3] Introduce the io_schedulers() function Shinichiro Kawasaki
2022-04-28 19:53 ` 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-28 6:27 ` Shinichiro Kawasaki
2022-04-28 19:52 ` Bart Van Assche
2022-05-09 10:56 ` Shinichiro Kawasaki
2022-04-27 21:31 ` [PATCH blktests 3/3] tests/scsi: Add tests for SCSI devices with gap zones Bart Van Assche
2022-04-28 0:39 ` Shinichiro Kawasaki
2022-04-28 3:16 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220427213143.2490653-2-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=linux-block@vger.kernel.org \
--cc=osandov@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox