common: _devmgt_add() to check if the device is back online
authorAnand Jain <anand.jain@oracle.com>
Wed, 13 Aug 2014 01:15:43 +0000 (11:15 +1000)
committerDave Chinner <david@fromorbit.com>
Wed, 13 Aug 2014 01:15:43 +0000 (11:15 +1000)
btrfs/003 uses a method to remove the device as part of the test
case, and after the test completes the removed device is added
back to the system. However on certain system, albeit the slow
running system the device comes back a bit later, and so the
latter occurring sub-test with in the btrfs/003 fails.

This patch adds script to wait and test if the device is back online,
and thus report the same to to the full log.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
common/rc

index b831d82d64e86c0383b993c6df2472d084eb9318..12eb989ee194527e58097363101df374cad49ce1 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -2141,6 +2141,31 @@ _devmgt_add()
        tdl=`echo ${1} | cut -d":" -f 2-|sed 's/:/ /g'`
 
        echo ${tdl} >  /sys/class/scsi_host/host${h}/scan || _fail "Add disk failed"
+
+       # ensure the device comes online
+       dev_back_oneline=0
+       for i in `seq 1 10`; do
+               if [ -d /sys/class/scsi_device/${1}/device/block ]; then
+                       dev=`ls /sys/class/scsi_device/${1}/device/block`
+                       for j in `seq 1 10`;
+                       do
+                               stat /dev/$dev > /dev/null 2>&1
+                               if [ $? -eq 0 ]; then
+                                       dev_back_oneline=1
+                                       break
+                               fi
+                               sleep 1
+                       done
+                       break
+               else
+                       sleep 1
+               fi
+       done
+       if [ $dev_back_oneline -eq 0 ]; then
+               echo "/dev/$dev online failed" >> $seqres.full
+       else
+               echo "/dev/$dev is back online" >> $seqres.full
+       fi
 }
 
 _require_fstrim()