[SCSI] hpsa: retry driver initiated commands on busy status
authorMatt Bondurant <Matthew.dav.bondurant@hp.com>
Tue, 1 May 2012 16:42:35 +0000 (11:42 -0500)
committerJames Bottomley <JBottomley@Parallels.com>
Thu, 10 May 2012 08:12:10 +0000 (09:12 +0100)
In shared SAS configurations we might get a busy status
during driver initiated commands (e.g. during rescan for
devices).  We should retry the command in such cases rather
than giving up.

Signed-off-by: Matt Bondurant <Matthew.dav.bondurant@hp.com>
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/hpsa.c

index 5e8c7ca..cc58697 100644 (file)
@@ -234,6 +234,16 @@ static int check_for_unit_attention(struct ctlr_info *h,
        return 1;
 }
 
+static int check_for_busy(struct ctlr_info *h, struct CommandList *c)
+{
+       if (c->err_info->CommandStatus != CMD_TARGET_STATUS ||
+               (c->err_info->ScsiStatus != SAM_STAT_BUSY &&
+                c->err_info->ScsiStatus != SAM_STAT_TASK_SET_FULL))
+               return 0;
+       dev_warn(&h->pdev->dev, HPSA "device busy");
+       return 1;
+}
+
 static ssize_t host_store_rescan(struct device *dev,
                                 struct device_attribute *attr,
                                 const char *buf, size_t count)
@@ -1379,7 +1389,8 @@ static void hpsa_scsi_do_simple_cmd_with_retry(struct ctlr_info *h,
                memset(c->err_info, 0, sizeof(*c->err_info));
                hpsa_scsi_do_simple_cmd_core(h, c);
                retry_count++;
-       } while (check_for_unit_attention(h, c) && retry_count <= 3);
+       } while ((check_for_unit_attention(h, c) ||
+                       check_for_busy(h, c)) && retry_count <= 3);
        hpsa_pci_unmap(h->pdev, c, 1, data_direction);
 }