Commit d2fe6d7d authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

test/nvme/zns: Add simple fio test for zoned nvme devices



Signed-off-by: default avatarMichal Berger <michalx.berger@intel.com>
Change-Id: I2ecad040bcaa573ace5ea2adfb1c0735d8388ce2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9182


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 0231fdc7
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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
+4 −0
Original line number Diff line number Diff line
@@ -82,3 +82,7 @@ vhost_scsi_cores_2ctrl
busy
balanced
core_load
# Waiting for CI support
nvme_zns
is_zoned
zoned_fio

test/nvme/zns/zns.sh

0 → 100755
+92 −0
Original line number Diff line number Diff line
#!/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