From 57540c0d1866bd1ad76bcf275278f9b9b650b2bc Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 10 Jan 2023 15:17:34 -0800 Subject: [PATCH] zbd/090: Add a SCSI test for npo2 zone sizes Signed-off-by: Bart Van Assche --- common/scsi_debug | 15 ++++++++++++ tests/zbd/090 | 61 +++++++++++++++++++++++++++++++++++++++++++++++ tests/zbd/090.out | 2 ++ 3 files changed, 78 insertions(+) create mode 100644 tests/zbd/090 create mode 100644 tests/zbd/090.out diff --git a/common/scsi_debug b/common/scsi_debug index 788efc29..82b8c7ae 100644 --- a/common/scsi_debug +++ b/common/scsi_debug @@ -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 diff --git a/tests/zbd/090 b/tests/zbd/090 new file mode 100644 index 00000000..068a7ed6 --- /dev/null +++ b/tests/zbd/090 @@ -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 +} diff --git a/tests/zbd/090.out b/tests/zbd/090.out new file mode 100644 index 00000000..c3b9883b --- /dev/null +++ b/tests/zbd/090.out @@ -0,0 +1,2 @@ +Running zbd/090 +Test complete