Skip to content

Commit

Permalink
Add tests for support for segments smaller than the page size
Browse files Browse the repository at this point in the history
Signed-off-by: Bart Van Assche <[email protected]>
  • Loading branch information
bvanassche committed Jan 9, 2024
1 parent 5033ef5 commit 0730d05
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 0 deletions.
8 changes: 8 additions & 0 deletions common/rc
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ _have_kernel_config_file() {
return 0
}

_have_sub_page_limit_support() {
if [[ -e /sys/debug/block/sub_page_limit_queues ]]; then
return 0
fi
SKIP_REASONS+=("The block layer does not have sub-page limit support")
return 1
}

# Check if the specified kernel option is defined.
_check_kernel_option() {
local f opt=$1
Expand Down
57 changes: 57 additions & 0 deletions tests/block/099
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright 2022 Google LLC
#
# Test support for segment sizes less than 4096 bytes.

. tests/block/rc
. common/null_blk

DESCRIPTION="do IO on null-blk with 512 byte segments"
TIMED=1

requires() {
_have_fio
_have_null_blk
_have_sub_page_limit_support
}

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-099 --filename=/dev/nullb0 \
--output="${RESULTS_DIR}/block/fio-output-block-099.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
}
2 changes: 2 additions & 0 deletions tests/block/099.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Running block/099
Passed
55 changes: 55 additions & 0 deletions tests/scsi/099
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright 2022 Google LLC
#
# Test support for segment sizes less than 4096 bytes.

. tests/block/rc
. common/scsi_debug

DESCRIPTION="do IO on scsi_debug with 512 byte segments"
TIMED=1

requires() {
_have_fio
_have_scsi_debug
_have_sub_page_limit_support
}

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-099 --filename="$blkdev" \
--output="${RESULTS_DIR}/block/fio-output-scsi-099-$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
}
4 changes: 4 additions & 0 deletions tests/scsi/099.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Running scsi/099
psync
sg
Passed

0 comments on commit 0730d05

Please sign in to comment.