doug-gilbert/sg3_utils

rescan-scsi-bus.sh: when there is a logical lun-0, testonline will spend 30s to retry-check it

LiuXing108 opened this issue · 6 comments

In function testonline, this shell uses sg_turs to check sgdevice, but lun-0 is not always a real device, sometimes a logical one. it depends on Vendor's implementation. So could we ensure there is a real sd-device before we check it by sg_turs?

Would something like 'if sg_inq $DEVICE | grep -q -i "PQual=0" ' work in this situation?

it works:

testoneline() {
  ……
  sg_turs /dev/$SGDEV >/dev/null 2>&1
  RC=$?

  # Handle in progress of becoming ready and unit attention
  while [ $RC = 2 -o $RC = 6 ] && [ $ctr -le 30 ] ; do
    if [ $RC = 2 ] && [ "$RMB" != "1" ] && [ sg_inq /dev/$SGDEV | grep -q -i "PQual=0" ]; then
      echo -n "."
      let LN+=1
      sleep 1
    else
      sleep 0.02
    fi
    let ctr+=1
    sg_turs /dev/$SGDEV >/dev/null 2>&1
    RC=$?
……
}

sg3_utils revision 972 (subversion, as show in ChangeLog file) uploaded with the above change in it. Could you test it?

I'm so sorry and embarrassed for #24 (comment). it has a code error - we should not add "[ ]".

I'm so sorry and embarrassed for #24 (comment). it has a code error - we should not add "[ ]", I wrote it wrong.
it should be like this:
if [ $RC = 2 ] && [ "$RMB" != "1" ] && sg_inq /dev/$SGDEV | grep -q -i "PQual=0" ; then

and I tested this shell with "scsi-rescan -a -r ",there are two iscsi links on my server, as we expected, one link reduced 30 seconds。
after modificated:
real 0m12.165s
user 0m2.853s
sys 0m2.450s
before modificated:
real 1m12.874s
user 0m2.732s
sys 0m2.353s

Subversion revision 973, now mirrored here, has the above fix. Perhaps you might recheck it has been done properly. Also that revision contains the patch discussed in the issue #22 .