]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
common/rc: search harder for pci device
authorJohannes Thumshirn <jthumshirn@suse.de>
Wed, 4 Jul 2018 11:40:12 +0000 (13:40 +0200)
committerOmar Sandoval <osandov@fb.com>
Mon, 16 Jul 2018 22:04:49 +0000 (15:04 -0700)
Some multipathed NVMe devices have a bit of a different sysfs layout
then we've expoected them to have in the first place.

Try harder searching for a pci device if we encounter such a device.

This fixes issue #26.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
common/rc

index e414fa3fb11bdffeb49294887ccbc1ad69bc407b..3c3e91f1fa9a62feb436f293582843b0c00d29b5 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -165,6 +165,19 @@ _test_dev_queue_set() {
 
 _test_dev_is_pci() {
        if ! readlink -f "$TEST_DEV_SYSFS/device" | grep -q pci; then
+               # nvme needs some special casing
+               if readlink -f "$TEST_DEV_SYSFS/device" | grep -q nvme; then
+                       local blkdev
+                       local ctrldev
+                       # First get the controller device from the namespace blockdev
+                       blkdev="$(echo "$TEST_DEV_SYSFS" | cut -d '/' -f 7)"
+                       ctrldev="$(echo "$blkdev" | grep -Eo 'nvme[0-9]+')"
+                       # Then get the pci device from the controller device
+                       if readlink -f "$ctrldev/device" | grep -1 pci; then
+                               return 0
+                       fi
+               fi
+
                SKIP_REASON="$TEST_DEV is not a PCI device"
                return 1
        fi