Commit 61617956 authored by Michal Berger's avatar Michal Berger Committed by Ben Walker
Browse files

test/common: Make sure get_zoned_devs() picks all namespaces



In case given nvme ctrl mixes zoned and not-zoned namespaces, we need
to make sure we put ALL of them on the list to inform the caller that
they won't be available - this is necessary since the PCI_BLOCKED list
that's built based on the zoned_devs[] will prevent entire ctrl from
being used, hence making ALL of the namespaces unavailable for tests
in userspace.

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
parent b43c2605
Loading
Loading
Loading
Loading
+23 −5
Original line number Diff line number Diff line
@@ -1655,13 +1655,31 @@ function is_block_zoned() {

function get_zoned_devs() {
	local -gA zoned_devs=()
	local nvme bdf

	for nvme in /sys/block/nvme*; do
		if is_block_zoned "${nvme##*/}"; then
			zoned_devs["${nvme##*/}"]=$(< "$nvme/device/address")
	local -A zoned_ctrls=()
	local nvme bdf ns

	# When given ctrl has > 1 namespaces attached, we need to make
	# sure we pick up ALL of them, even if only one of them is zoned.
	# This is because the zoned_devs[] is mainly used for PCI_BLOCKED
	# which passed to setup.sh will skip entire ctrl, not a single
	# ns. FIXME: this should not be necessary. We need to find a way
	# to handle zoned devices more gracefully instead of hiding them
	# like that from all the other non-zns test suites.
	for nvme in /sys/class/nvme/nvme*; do
		bdf=$(< "$nvme/address")
		for ns in "$nvme/"nvme*n*; do
			if is_block_zoned "${ns##*/}"; then
				zoned_ctrls["$nvme"]=$bdf
				continue 2
			fi
		done
	done

	for nvme in "${!zoned_ctrls[@]}"; do
		for ns in "$nvme/"nvme*n*; do
			zoned_devs["${ns##*/}"]=${zoned_ctrls["$nvme"]}
		done
	done
}

function is_pid_child() {