* [PATCH] block/044, scsi/012: Add tests for support for segments smaller than the page size
@ 2026-03-23 20:07 Bart Van Assche
2026-03-25 11:52 ` Shinichiro Kawasaki
0 siblings, 1 reply; 4+ messages in thread
From: Bart Van Assche @ 2026-03-23 20:07 UTC (permalink / raw)
To: Shin'ichiro Kawasaki
Cc: Damien Le Moal, linux-block, Bart Van Assche, Ming Lei
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] block/044, scsi/012: Add tests for support for segments smaller than the page size
2026-03-23 20:07 [PATCH] block/044, scsi/012: Add tests for support for segments smaller than the page size Bart Van Assche
@ 2026-03-25 11:52 ` Shinichiro Kawasaki
2026-03-26 8:05 ` Shinichiro Kawasaki
0 siblings, 1 reply; 4+ messages in thread
From: Shinichiro Kawasaki @ 2026-03-25 11:52 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Damien Le Moal, linux-block@vger.kernel.org, Ming Lei
On Mar 23, 2026 / 13:07, Bart Van Assche wrote:
> 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>
Hi Bart, thanks for the patch. Please find my comments in line.
I think it's fine to keep the two new testcases in this single patch, but if
the kernel side patches go into upstream in different timings, it would be the
better to separate this patch into two patches for each testcase.
[...]
> 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
Nit: many of blktests files have license GPL-3.0+ or GPL-2.0+. If you do not
have specific reason, I suggest GPL-3.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
This new test case doesn't look referring to TIMEOUT. I suggest to drop
"TIMED=1". When I ran this test case, it completed within a second, so I think
QUICK=1 can be specified here.
> +
> +requires() {
> + _have_fio
> + _have_kver 6 14
Do we really need this kernel version check here? The test case checks
that the null_blk implements "max_segment_size" feature. Assuming this
feature is introeuced kernel versions 7.1+, I think we can drop the
check above.
> + _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
The five lines above can be replaced with below one line:
if ! _have_null_blk_feature max_segment_size; 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
When null_blk driver is built-in, null_blk device name nullb0 is not
available. I suggest to use nullb1 instead of nullb0.
> + 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 \
Same here: s/nullb0/nullb1/
> + --output="${RESULTS_DIR}/block/fio-output-block-044.txt" \
> + >>"$FULL"
> + local fio_status=$?
> + rmdir /sys/kernel/config/nullb/nullb0
The line aobve is not required since the directory is removed by the line below.
> + _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
Nit: in the same manner as the null_blk test case, I suggest GPL-3.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
s/TIMED/QUICK/
> +
> +requires() {
> + _have_fio
> + _have_kver 6 14
With the same reason as the null_blk test case, I suspect this kernel version
check is not required.
> + _have_scsi_debug
The line above checks that scsi_debug driver exists, regardless whether
it is built-in or lodable. When scsi_debug is built-in, the parameter
sector_size can not be modified, and this case won't work. I suggest to
replace the line above with "_have_module scsi_debug" to confirm that
loadable scsi_debug is available.
When the patch series "Skip tests if scsi_debug module is already loaded and
in use" [1] gets applied, the check above should be replaced with
"_have_loadable_scsi_debug". I can amend this change if it is required.
[1] https://lore.kernel.org/linux-block/20260324054949.3821569-1-shinichiro.kawasaki@wdc.com/
Also, I suggest to add one more check in requires().
_have_module_param scsi_debug max_segment_size
to simplify the parameter check in test().
> +}
> +
> +test() {
> + local bs=4096
> +
> + echo "Running ${TEST_NAME}"
> + local scsi_debug_params=(
> + add_host=1
> + clustering=1
> + delay=0
> + sector_size="$bs" # bytes
I suggest to add the paremeter below,
max_segment_size=512 # bytes
because the added _have_module_param check in requires() will ensure
that the parameter is available.
> + )
> + if _have_module_param scsi_debug max_segment_size; then
> + scsi_debug_params+=(max_segment_size=512) # bytes
> + echo "Segment size = 512" >>"$FULL"
> + fi
With the _have_module_param check in requires(), four lines above
will not be required.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block/044, scsi/012: Add tests for support for segments smaller than the page size
2026-03-25 11:52 ` Shinichiro Kawasaki
@ 2026-03-26 8:05 ` Shinichiro Kawasaki
2026-03-26 17:41 ` Bart Van Assche
0 siblings, 1 reply; 4+ messages in thread
From: Shinichiro Kawasaki @ 2026-03-26 8:05 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Damien Le Moal, linux-block@vger.kernel.org, Ming Lei
On Mar 25, 2026 / 20:52, Shin'ichiro Kawasaki wrote:
> On Mar 23, 2026 / 13:07, Bart Van Assche wrote:
> > 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>
>
> Hi Bart, thanks for the patch. Please find my comments in line.
>
> I think it's fine to keep the two new testcases in this single patch, but if
> the kernel side patches go into upstream in different timings, it would be the
> better to separate this patch into two patches for each testcase.
Today, I reran the new testcases and noticed they leave fio verify state files
in the current directory. It would be the better to add --verify_state_save=0
option, or use _run_fio_verify_io() helper function in common/fio.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block/044, scsi/012: Add tests for support for segments smaller than the page size
2026-03-26 8:05 ` Shinichiro Kawasaki
@ 2026-03-26 17:41 ` Bart Van Assche
0 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2026-03-26 17:41 UTC (permalink / raw)
To: Shinichiro Kawasaki; +Cc: Damien Le Moal, linux-block@vger.kernel.org, Ming Lei
On 3/26/26 1:05 AM, Shinichiro Kawasaki wrote:
> Today, I reran the new testcases and noticed they leave fio verify state files
> in the current directory. It would be the better to add --verify_state_save=0
> option, or use _run_fio_verify_io() helper function in common/fio.
Hi Shinichiro,
The detailed feedback is appreciated. I plan to address this feedback
after the kernel patches these tests rely on have been merged.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-26 17:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 20:07 [PATCH] block/044, scsi/012: Add tests for support for segments smaller than the page size Bart Van Assche
2026-03-25 11:52 ` Shinichiro Kawasaki
2026-03-26 8:05 ` Shinichiro Kawasaki
2026-03-26 17:41 ` Bart Van Assche
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox