From d2fe6d7d9685ed150765c2d56073f030e8a0e0d4 Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Fri, 13 Aug 2021 12:55:43 +0200 Subject: [PATCH] test/nvme/zns: Add simple fio test for zoned nvme devices Signed-off-by: Michal Berger Change-Id: I2ecad040bcaa573ace5ea2adfb1c0735d8388ce2 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9182 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris --- autotest.sh | 5 ++ test/common/skipped_tests.txt | 4 ++ test/nvme/zns/zns.sh | 92 +++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100755 test/nvme/zns/zns.sh diff --git a/autotest.sh b/autotest.sh index b559bdd2d..d8faef387 100755 --- a/autotest.sh +++ b/autotest.sh @@ -95,6 +95,7 @@ if ((${#zoned_devs[@]} > 0)); then # concern here are fio workloads where specific configuration # must be in place for it to work with the zoned device. export PCI_BLOCKED="${zoned_devs[*]}" + export PCI_ZONED="${zoned_devs[*]}" fi # Delete all leftover lvols and gpt partitions @@ -207,6 +208,10 @@ if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then run_test "nvme_cmb" test/nvme/cmb/cmb.sh fi + if [[ $SPDK_TEST_NVME_ZNS -eq 1 ]]; then + run_test "nvme_zns" test/nvme/zns/zns.sh + fi + run_test "nvme_rpc" test/nvme/nvme_rpc.sh # Only test hotplug without ASAN enabled. Since if it is # enabled, it catches SEGV earlier than our handler which diff --git a/test/common/skipped_tests.txt b/test/common/skipped_tests.txt index d0c1c5273..f05aa8e19 100644 --- a/test/common/skipped_tests.txt +++ b/test/common/skipped_tests.txt @@ -82,3 +82,7 @@ vhost_scsi_cores_2ctrl busy balanced core_load +# Waiting for CI support +nvme_zns +is_zoned +zoned_fio diff --git a/test/nvme/zns/zns.sh b/test/nvme/zns/zns.sh new file mode 100755 index 000000000..5d48bd78b --- /dev/null +++ b/test/nvme/zns/zns.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash +testdir=$(readlink -f "$(dirname "$0")") +rootdir=$(readlink -f "$testdir/../../../") +source "$rootdir/test/common/autotest_common.sh" + +restore_pci_blocked() { + [[ -n $PCI_ZONED ]] || return 0 + + PCI_BLOCKED="" "$rootdir/scripts/setup.sh" reset + PCI_BLOCKED=$PCI_ZONED "$rootdir/scripts/setup.sh" +} + +gen_json_conf() { + cat <<- JSON + { + "subsystems": [ + { + "subsystem": "bdev", + "config": [ + { + "method": "bdev_nvme_attach_controller", + "params": { + "trtype": "PCIe", + "name":"$bdev", + "traddr":"$bdf" + } + } + ] + } + ] + } + JSON +} + +gen_fio_conf() { + local zone_bdev + + cat <<- FIO + [global] + ioengine=spdk_bdev + thread=1 + direct=1 + time_based + runtime=5 + rw=randwrite + bs=16K + zonemode=zbd + max_open_zones=8 + initial_zone_reset=1 + zone_append=1 + iodepth=64 + FIO + + for zone_bdev in "${!zoned_bdevs[@]}"; do + cat <<- FIO + [filename$zone_bdev] + filename=${zoned_bdevs[zone_bdev]} + FIO + done +} + +is_zoned() { + # At least one namespace must be zoned + ((${#zoned_bdevs[@]} > 0)) +} + +fio() { + fio_bdev --ioengine=spdk_bdev --spdk_json_conf <(gen_json_conf) <(gen_fio_conf) +} + +zoned_bdfs=($PCI_ZONED) +if ((${#zoned_bdfs[@]} == 0)); then + printf 'No ZNS nvme devices found, skipping\n' >&2 + exit 0 +fi + +PCI_BLOCKED="" PCI_ALLOWED="${zoned_bdfs[*]}" "$rootdir/scripts/setup.sh" +bdf=${zoned_bdfs[0]} bdev=zone0 + +trap 'kill $spdk_app_pid || :; restore_pci_blocked' EXIT + +"${SPDK_APP[@]}" & +spdk_app_pid=$! +waitforlisten "$spdk_app_pid" + +rpc_cmd bdev_nvme_attach_controller -t pcie -a "$bdf" -b "$bdev" +zoned_bdevs=($(rpc_cmd bdev_get_bdevs | jq -r ".[] | select(.zoned == true) | select(.driver_specific.nvme.pci_address == \"$bdf\") | .name")) + +killprocess "$spdk_app_pid" + +run_test "is_zoned" is_zoned +run_test "zoned_fio" fio