From 074fa32636d9034c93e3bd42ee6d141e63dada94 Mon Sep 17 00:00:00 2001 From: Maciej Szwed Date: Wed, 12 Jun 2019 10:06:35 +0200 Subject: [PATCH] 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 Change-Id: Idd13edccd0929574f2914a71e841e67871dd2e9f Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457762 Tested-by: SPDK CI Jenkins Reviewed-by: Karol Latecki Reviewed-by: Darek Stojaczyk Reviewed-by: Shuhei Matsumoto --- scripts/setup.sh | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index 139309d46..cda302936 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -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" - fi - if [ "$mountpoints" = "0" ]; then + if [ "$mountpoints" != "0" ]; then + mount=true + blknames+=($blkname) + fi + 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