Skip to content

Commit

Permalink
zbd/090: Add a SCSI test for npo2 zone sizes
Browse files Browse the repository at this point in the history
Signed-off-by: Bart Van Assche <[email protected]>
  • Loading branch information
bvanassche committed Nov 13, 2024
1 parent 689b043 commit 57540c0
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
15 changes: 15 additions & 0 deletions common/scsi_debug
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ _have_scsi_debug() {
SD_PARAM_PATH=/sys/module/scsi_debug/parameters
SD_PSEUDO_PATH=/sys/bus/pseudo/drivers/scsi_debug

# Test whether the scsi_debug driver supports zone sizes that are not a power
# of two.
_have_scsi_debug_npo2() {
modprobe -r scsi_debug >&/dev/null
if modprobe scsi_debug delay=0 zbc=host-managed zone_size_mb=3 >&/dev/null &&
[[ -e /sys/bus/pseudo/drivers/scsi_debug/adapter0 ]]
then
modprobe -r scsi_debug >&/dev/null
return 0
fi
SKIP_REASONS+=("scsi_debug does not support npo2 zone sizes")
modprobe -r scsi_debug >&/dev/null
return 1
}

# shellcheck disable=SC2317 # Don't warn about unreachable commands in this function
_have_scsi_debug_group_number_stats() {
modprobe -r scsi_debug >&/dev/null
Expand Down
61 changes: 61 additions & 0 deletions tests/zbd/090
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0+
# Copyright (C) 2023 Google LLC

. tests/zbd/rc
. common/null_blk
. common/scsi_debug

DESCRIPTION="test npo2 zone size support"
QUICK=1

requires() {
_have_fio
_have_module_param scsi_debug zone_size_mb
_have_scsi_debug_npo2
}

test() {
echo "Running ${TEST_NAME}"

local fail
local scsi_debug_params=(
delay=0
dev_size_mb=1024
sector_size=4096
zbc=host-managed
zone_nr_conv=0
zone_size_mb=3
)
_init_scsi_debug "${scsi_debug_params[@]}" &&
local zdev="${SCSI_DEBUG_DEVICES[0]}" &&
local zpath="/dev/${zdev}" &&
ls -ld "${zpath}" >>"${FULL}" &&
head -n9 /sys/class/block/"${zdev}"/queue/{chunk_sectors,nr_zones} >>"${FULL}" &&
local fio_args=(
--direct=1
--filename="${zpath}"
--gtod_reduce=1
--ioengine=pvsync
--ioscheduler=none
--name=npo2zs
--runtime=10
--rw=randwrite
--time_based=1
--verify=crc32c
--zonemode=zbd
) &&
fio "${fio_args[@]}" >>"${FULL}" 2>&1 ||
fail=true

rm -f ./local-*-verify.state

_exit_scsi_debug

if [ -z "$fail" ]; then
echo "Test complete"
else
echo "Test failed"
return 1
fi
}
2 changes: 2 additions & 0 deletions tests/zbd/090.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Running zbd/090
Test complete

0 comments on commit 57540c0

Please sign in to comment.