From: Bart Van Assche <bvanassche@acm.org>
To: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Cc: Damien Le Moal <dlemoal@kernel.org>,
linux-block@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
Ming Lei <ming.lei@redhat.com>
Subject: [PATCH] block/044, scsi/012: Add tests for support for segments smaller than the page size
Date: Mon, 23 Mar 2026 13:07:51 -0700 [thread overview]
Message-ID: <20260323200751.1238583-1-bvanassche@acm.org> (raw)
Linux kernel commit 889c57066cee ("block: make segment size limit workable
for > 4K PAGE_SIZE") was merged about one year ago and adds support for
DMA segments that are smaller than the virtual memory page size. This is
important for devices that do not support DMA segments larger. This patch
tests the code paths added by that Linux kernel commit.
Cc: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
Please note that this patch depends on two block layer and one SCSI
patches that have not yet been merged.
tests/block/044 | 58 +++++++++++++++++++++++++++++++++++++++++++++
tests/block/044.out | 2 ++
tests/scsi/012 | 56 +++++++++++++++++++++++++++++++++++++++++++
tests/scsi/012.out | 4 ++++
4 files changed, 120 insertions(+)
create mode 100755 tests/block/044
create mode 100644 tests/block/044.out
create mode 100755 tests/scsi/012
create mode 100644 tests/scsi/012.out
diff --git a/tests/block/044 b/tests/block/044
new file mode 100755
index 000000000000..e2ca2d9aea3a
--- /dev/null
+++ b/tests/block/044
@@ -0,0 +1,58 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright 2026 Google LLC
+#
+# Test support for DMA segment sizes less than 4096 bytes. See also commit
+# 889c57066cee ("block: make segment size limit workable for > 4K PAGE_SIZE").
+
+. tests/block/rc
+. common/null_blk
+
+DESCRIPTION="do IO on null-blk with 512 byte segments"
+TIMED=1
+
+requires() {
+ _have_fio
+ _have_kver 6 14
+ _have_null_blk
+}
+
+test() {
+ local bs=4096
+
+ echo "Running ${TEST_NAME}"
+
+ if ! _init_null_blk nr_devices=0; then
+ echo "Loading null_blk failed"
+ return 1
+ fi
+ if ! grep -qw max_segment_size /sys/kernel/config/nullb/features; then
+ SKIP_REASONS+=("max_segment_size parameter is not supported")
+ return 1
+ fi
+ local nullb_params=(
+ blocksize="$bs" # bytes
+ completion_nsec=0
+ max_segment_size=512 # bytes
+ memory_backed=1
+ size=1 # MiB
+ submit_queues=1
+ power=1
+ )
+ if ! _configure_null_blk nullb0 "${nullb_params[@]}"; then
+ echo "Configuring null_blk failed"
+ return 1
+ fi
+ fio --verify=md5 --rw=randwrite --bs=$bs --ioengine=psync --thread \
+ --group_reporting --sync=1 --direct=1 \
+ --name=block-044 --filename=/dev/nullb0 \
+ --output="${RESULTS_DIR}/block/fio-output-block-044.txt" \
+ >>"$FULL"
+ local fio_status=$?
+ rmdir /sys/kernel/config/nullb/nullb0
+ _exit_null_blk
+ case $fio_status in
+ 0) echo "Passed";;
+ *) echo "Failed (fio status = $fio_status)";;
+ esac
+}
diff --git a/tests/block/044.out b/tests/block/044.out
new file mode 100644
index 000000000000..4718ff7bd595
--- /dev/null
+++ b/tests/block/044.out
@@ -0,0 +1,2 @@
+Running block/044
+Passed
diff --git a/tests/scsi/012 b/tests/scsi/012
new file mode 100755
index 000000000000..a2043f95deaa
--- /dev/null
+++ b/tests/scsi/012
@@ -0,0 +1,56 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright 2026 Google LLC
+#
+# Test support for DMA segment sizes less than 4096 bytes. See also commit
+# 889c57066cee ("block: make segment size limit workable for > 4K PAGE_SIZE").
+
+. tests/block/rc
+. common/scsi_debug
+
+DESCRIPTION="do IO on scsi_debug with 512 byte segments"
+TIMED=1
+
+requires() {
+ _have_fio
+ _have_kver 6 14
+ _have_scsi_debug
+}
+
+test() {
+ local bs=4096
+
+ echo "Running ${TEST_NAME}"
+ local scsi_debug_params=(
+ add_host=1
+ clustering=1
+ delay=0
+ sector_size="$bs" # bytes
+ )
+ if _have_module_param scsi_debug max_segment_size; then
+ scsi_debug_params+=(max_segment_size=512) # bytes
+ echo "Segment size = 512" >>"$FULL"
+ fi
+ if ! _init_scsi_debug "${scsi_debug_params[@]}"; then
+ echo "Initializing scsi_debug failed"
+ return 1
+ fi
+ local blkdev=/dev/${SCSI_DEBUG_DEVICES[0]}
+ [ -b "$blkdev" ] || return 1
+ local ioengine
+ for ioengine in psync sg; do
+ echo "$ioengine"
+ fio --verify=md5 --rw=randwrite --bs=$bs --ioengine=$ioengine \
+ --thread --group_reporting --sync=1 --direct=1 \
+ --name=scsi-012 --filename="$blkdev" \
+ --output="${RESULTS_DIR}/block/fio-output-scsi-012-$ioengine.txt" \
+ >>"$FULL"
+ local fio_status=$?
+ [ $fio_status = 0 ] || break
+ done
+ _exit_scsi_debug
+ case $fio_status in
+ 0) echo "Passed";;
+ *) echo "Failed (fio status = $fio_status)";;
+ esac
+}
diff --git a/tests/scsi/012.out b/tests/scsi/012.out
new file mode 100644
index 000000000000..9c85da01e04e
--- /dev/null
+++ b/tests/scsi/012.out
@@ -0,0 +1,4 @@
+Running scsi/012
+psync
+sg
+Passed
next reply other threads:[~2026-03-23 20:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-23 20:07 Bart Van Assche [this message]
2026-03-25 11:52 ` [PATCH] block/044, scsi/012: Add tests for support for segments smaller than the page size Shinichiro Kawasaki
2026-03-26 8:05 ` Shinichiro Kawasaki
2026-03-26 17:41 ` 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=20260323200751.1238583-1-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=dlemoal@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox