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: Maciej Szwed <maciej.szwed@intel.com>
Change-Id: Idd13edccd0929574f2914a71e841e67871dd2e9f
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457762
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Maciej Szwed 2019-06-12 10:06:35 +02:00 committed by Darek Stojaczyk
parent a8a53c7c4b
commit 074fa32636

View File

@ -135,6 +135,8 @@ function linux_hugetlbfs_mounts() {
} }
function get_nvme_name_from_bdf { function get_nvme_name_from_bdf {
local blknames=()
set +e set +e
nvme_devs=$(lsblk -d --output NAME | grep "^nvme") nvme_devs=$(lsblk -d --output NAME | grep "^nvme")
set -e set -e
@ -145,10 +147,11 @@ function get_nvme_name_from_bdf {
fi fi
link_bdf=$(basename "$link_name") link_bdf=$(basename "$link_name")
if [ "$link_bdf" = "$1" ]; then if [ "$link_bdf" = "$1" ]; then
eval "$2=$dev" blknames+=($dev)
return
fi fi
done done
printf '%s\n' "${blknames[@]}"
} }
function get_virtio_names_from_bdf { function get_virtio_names_from_bdf {
@ -200,21 +203,27 @@ function configure_linux_pci {
# NVMe # NVMe
for bdf in $(iter_all_pci_class_code 01 08 02); do for bdf in $(iter_all_pci_class_code 01 08 02); do
blkname='' blknames=()
get_nvme_name_from_bdf "$bdf" blkname
if ! pci_can_use $bdf; then 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 continue
fi 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) mountpoints=$(lsblk /dev/$blkname --output MOUNTPOINT -n | wc -w)
else if [ "$mountpoints" != "0" ]; then
mountpoints="0" mount=true
fi blknames+=($blkname)
if [ "$mountpoints" = "0" ]; then fi
done
if ! $mount; then
linux_bind_driver "$bdf" "$driver_name" linux_bind_driver "$bdf" "$driver_name"
else 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 fi
done done