public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [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

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