Commit 074fa326 authored by Maciej Szwed's avatar Maciej Szwed Committed by Darek Stojaczyk
Browse files

scripts: Fix setup.sh to take into consideration other namespaces



Currently we do not switch driver for NVMe that is mounted.
The problem is that we take into consideration only the
first namespace, but any other namespace can be still mounted.
In such case we should not switch driver.

Signed-off-by: default avatarMaciej Szwed <maciej.szwed@intel.com>
Change-Id: Idd13edccd0929574f2914a71e841e67871dd2e9f
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457762


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent a8a53c7c
Loading
Loading
Loading
Loading
+20 −11
Original line number Diff line number Diff line
@@ -135,6 +135,8 @@ function linux_hugetlbfs_mounts() {
}

function get_nvme_name_from_bdf {
	local blknames=()

	set +e
	nvme_devs=$(lsblk -d --output NAME | grep "^nvme")
	set -e
@@ -145,10 +147,11 @@ function get_nvme_name_from_bdf {
		fi
		link_bdf=$(basename "$link_name")
		if [ "$link_bdf" = "$1" ]; then
			eval "$2=$dev"
			return
			blknames+=($dev)
		fi
	done

	printf '%s\n' "${blknames[@]}"
}

function get_virtio_names_from_bdf {
@@ -200,21 +203,27 @@ function configure_linux_pci {

	# NVMe
	for bdf in $(iter_all_pci_class_code 01 08 02); do
		blkname=''
		get_nvme_name_from_bdf "$bdf" blkname
		blknames=()
		if ! pci_can_use $bdf; then
			pci_dev_echo "$bdf" "Skipping un-whitelisted NVMe controller $blkname"
			pci_dev_echo "$bdf" "Skipping un-whitelisted NVMe controller at $bdf"
			continue
		fi
		if [ "$blkname" != "" ]; then

		mount=false
		for blkname in $(get_nvme_name_from_bdf $bdf); do
			mountpoints=$(lsblk /dev/$blkname --output MOUNTPOINT -n | wc -w)
		else
			mountpoints="0"
			if [ "$mountpoints" != "0" ]; then
				mount=true
				blknames+=($blkname)
			fi
		if [ "$mountpoints" = "0" ]; then
		done

		if ! $mount; then
			linux_bind_driver "$bdf" "$driver_name"
		else
			pci_dev_echo "$bdf" "Active mountpoints on /dev/$blkname, so not binding PCI dev"
			for name in ${blknames[@]}; do
				pci_dev_echo "$bdf" "Active mountpoints on /dev/$name, so not binding PCI dev"
			done
		fi
	done