All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: shinichiro.kawasaki@wdc.com
Cc: linux-block@vger.kernel.org, hare@suse.de,
	patches@lists.linux.dev, gost.dev@samsung.com, mcgrof@kernel.org
Subject: [PATCH blktests v2 1/4] common: add and use min io for fio
Date: Tue,  4 Feb 2025 14:57:26 -0800	[thread overview]
Message-ID: <20250204225729.422949-2-mcgrof@kernel.org> (raw)
In-Reply-To: <20250204225729.422949-1-mcgrof@kernel.org>

When using fio we should not issue IOs smaller than the device supports.
Today a lot of places have in place 4k, but soon we will have devices
which support bs > ps. For those devices we should check the minimum
supported IO.

However, since we also have a min optimal IO, we might as well use that
as well. By using this we can also leverage the same lookup with stat
whether or not the target file is a block device or a file.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 common/fio | 23 +++++++++++++++++++++--
 common/rc  | 21 +++++++++++++++++++++
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/common/fio b/common/fio
index b9ea087fc6c5..557150656b29 100644
--- a/common/fio
+++ b/common/fio
@@ -189,15 +189,34 @@ _run_fio() {
 	return $rc
 }
 
+_fio_opts_to_min_io() {
+        local arg path
+        local -i min_io=4096
+
+        for arg in "$@"; do
+                [[ "$arg" =~ ^--filename= || "$arg" =~ --directory= ]] || continue
+                path="${arg##*=}"
+		min_io=$(_min_io "$path")
+                # Keep 4K minimum IO size for historical consistency
+                ((min_io < 4096)) && min_io=4096
+                break
+        done
+
+        echo "$min_io"
+}
+
+
 # Wrapper around _run_fio used if you need some I/O but don't really care much
 # about the details
 _run_fio_rand_io() {
-	_run_fio --bs=4k --rw=randread --norandommap --numjobs="$(nproc)" \
+	local bs=$(_fio_opts_to_min_io "$@") || return 1
+	_run_fio --bs=$bs --rw=randread --norandommap --numjobs="$(nproc)" \
 		--name=reads --direct=1 "$@"
 }
 
 _run_fio_verify_io() {
-	_run_fio --name=verify --rw=randwrite --direct=1 --ioengine=libaio --bs=4k \
+	local bs=$(_fio_opts_to_min_io "$@") || return 1
+	_run_fio --name=verify --rw=randwrite --direct=1 --ioengine=libaio --bs=$bs \
 		--iodepth=16 --verify=crc32c --verify_state_save=0 "$@"
 }
 
diff --git a/common/rc b/common/rc
index bcb215d35114..e12ecd025868 100644
--- a/common/rc
+++ b/common/rc
@@ -387,6 +387,27 @@ _test_dev_is_partition() {
 	[[ -n ${TEST_DEV_PART_SYSFS} ]]
 }
 
+_min_io() {
+	local path_or_dev=$1
+        if [ -z "$path_or_dev" ]; then
+		echo "path for min_io does not exist"
+		return 1
+	fi
+
+	if [ -c "$path_or_dev" ]; then
+		if [[ "$path_or_dev" == /dev/ng* ]]; then
+			path_or_dev="${path_or_dev/ng/nvme}"
+		fi
+	fi
+
+        if [ -e "$path_or_dev" ]; then
+                stat --printf=%o "$path_or_dev"
+        else
+                echo "Error: '$path_or_dev' does not exist or is not accessible"
+                return 1
+        fi
+}
+
 # Return max open zones or max active zones of the test target device.
 # If the device has both, return smaller value.
 _test_dev_max_open_active_zones() {
-- 
2.45.2


  reply	other threads:[~2025-02-04 22:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04 22:57 [PATCH blktests v2 0/4] enable bs > ps device testing Luis Chamberlain
2025-02-04 22:57 ` Luis Chamberlain [this message]
2025-02-07 11:26   ` [PATCH blktests v2 1/4] common: add and use min io for fio Shinichiro Kawasaki
2025-02-07 20:47     ` Luis Chamberlain
2025-02-04 22:57 ` [PATCH blktests v2 2/4] common/xfs: use min io for fs blocksize Luis Chamberlain
2025-02-04 22:57 ` [PATCH blktests v2 3/4] tests: use test device min io to support bs > ps Luis Chamberlain
2025-02-04 22:57 ` [PATCH blktests v2 4/4] common/xfs: check for max supported sector size Luis Chamberlain
2025-02-07 11:58   ` Shinichiro Kawasaki
2025-02-07 20:46     ` Luis Chamberlain
2025-02-07 11:24 ` [PATCH blktests v2 0/4] enable bs > ps device testing Shinichiro Kawasaki
2025-02-10 15:32   ` Luis Chamberlain

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=20250204225729.422949-2-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=gost.dev@samsung.com \
    --cc=hare@suse.de \
    --cc=linux-block@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=shinichiro.kawasaki@wdc.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.