From 44775a8062df84fa008db58217f276430e905030 Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Wed, 2 Sep 2020 15:08:38 +0200 Subject: [PATCH] scripts/setup: Add env switch for block dev sync Make sure that setup.sh waits for block devices during the tests. This is to make sure that the underlying controllers are ready to be talked to and minimize the amount of their flakiness. Change-Id: Id09445de7ac7ccf4c9f679ee2b6c4bdd14c89733 Signed-off-by: Michal Berger Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4029 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki --- scripts/setup.sh | 33 +++++++++++++++++++++++++++++++++ test/common/autotest_common.sh | 3 +++ 2 files changed, 36 insertions(+) diff --git a/scripts/setup.sh b/scripts/setup.sh index 820e19ee9..82d6d2092 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -65,6 +65,9 @@ function usage() { echo "DRIVER_OVERRIDE Disable automatic vfio-pci/uio_pci_generic selection and forcefully" echo " bind devices to the given driver." echo " E.g. DRIVER_OVERRIDE=uio_pci_generic or DRIVER_OVERRIDE=/home/public/dpdk/build/kmod/igb_uio.ko" + echo "PCI_BLOCK_SYNC_ON_RESET" + echo " If set in the environment, the attempt to wait for block devices associated" + echo " with given PCI device will be made upon reset" exit 0 } @@ -660,6 +663,32 @@ if [ -z "$TARGET_USER" ]; then fi collect_devices "$mode" + +if [[ $mode == reset && $PCI_BLOCK_SYNC_ON_RESET == yes ]]; then + # Note that this will wait only for the first block device attached to + # a given storage controller. For nvme this may miss some of the devs + # in case multiple namespaces are being in place. + # FIXME: Wait for nvme controller(s) to be in live state and determine + # number of configured namespaces, build list of potential block devs + # and pass them to sync_dev_uevents. Is it worth the effort? + bdfs_to_wait_for=() + for bdf in "${!all_devices_d[@]}"; do + ((all_devices_d["$bdf"] == 0)) || continue + if [[ -n ${nvme_d["$bdf"]} || -n ${virtio_d["$bdf"]} ]]; then + [[ $(collect_driver "$bdf") != "${drivers_d["$bdf"]}" ]] || continue + bdfs_to_wait_for+=("$bdf") + fi + done + if ((${#bdfs_to_wait_for[@]} > 0)); then + echo "Waiting for block devices as requested" + export UEVENT_TIMEOUT=5 DEVPATH_LOOKUP=yes DEVPATH_SUBSYSTEM=pci + "$rootdir/scripts/sync_dev_uevents.sh" \ + block/disk \ + "${bdfs_to_wait_for[@]}" & + sync_pid=$! + fi +fi + if [[ $os == Linux ]]; then HUGEPGSZ=$(($(grep Hugepagesize /proc/meminfo | cut -d : -f 2 | tr -dc '0-9'))) HUGEPGSZ_MB=$((HUGEPGSZ / 1024)) @@ -693,3 +722,7 @@ else usage $0 "Invalid argument '$mode'" fi fi + +if [[ -e /proc/$sync_pid/status ]]; then + wait "$sync_pid" +fi diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index fedbaf23c..01b5d2c17 100755 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -127,6 +127,9 @@ export SPDK_TEST_RAID5 : ${SPDK_TEST_URING=0} export SPDK_TEST_URING +# Tell setup.sh to wait for block devices upon each reset +export PCI_BLOCK_SYNC_ON_RESET=yes + # Export PYTHONPATH with addition of RPC framework. New scripts can be created # specific use cases for tests. export PYTHONPATH=$PYTHONPATH:$rootdir/scripts