multipath: Retry host transient errors for rdac checker
authorMoger, Babu <Babu.Moger@lsi.com>
Tue, 1 Mar 2011 19:08:24 +0000 (12:08 -0700)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Mon, 7 Mar 2011 22:57:26 +0000 (23:57 +0100)
Sometimes if the host is in transient state, we need to wait till the devloss timeout to
expire before switching path group. We have seen in some cases path group switch happens
even before the devloss timeout expire. This patch fixes the problem for rdac checker..

Signed-off-by: Babu Moger <babu.moger@lsi.com>
libmultipath/checkers/rdac.c

index fb39155..bcf09cb 100644 (file)
@@ -48,7 +48,9 @@ do_inq(int sg_fd, unsigned int pg_op, void *resp, int mx_resp_len,
        unsigned char inqCmdBlk[INQUIRY_CMDLEN] = { INQUIRY_CMD, 1, 0, 0, 0, 0 };
        unsigned char sense_b[SENSE_BUFF_LEN];
        struct sg_io_hdr io_hdr;
+       int retry_rdac = 5;
 
+retry:
        inqCmdBlk[2] = (unsigned char) pg_op;
        inqCmdBlk[4] = (unsigned char) (mx_resp_len & 0xff);
        memset(&io_hdr, 0, sizeof (struct sg_io_hdr));
@@ -72,6 +74,22 @@ do_inq(int sg_fd, unsigned int pg_op, void *resp, int mx_resp_len,
        if ((0 == io_hdr.status) && (0 == io_hdr.host_status) &&
            (0 == io_hdr.driver_status))
                return 0;
+
+       /* check if we need to retry this error */
+       if (io_hdr.info & SG_INFO_OK_MASK) {
+               switch (io_hdr.host_status) {
+               case DID_BUS_BUSY:
+               case DID_ERROR:
+               case DID_TRANSPORT_DISRUPTED:
+                       /* Transport error, retry */
+                       if (--retry_rdac)
+                               goto retry;
+                       break;
+               default:
+                       break;
+               }
+       }
+
        if ((SCSI_CHECK_CONDITION == io_hdr.status) ||
            (SCSI_COMMAND_TERMINATED == io_hdr.status) ||
            (SG_ERR_DRIVER_SENSE == (0xf & io_hdr.driver_status))) {