]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[SCSI] libsas: fix sas_queuecommand return values
authorChristoph Hellwig <hch@infradead.org>
Sat, 16 Jul 2011 19:00:35 +0000 (15:00 -0400)
committerJames Bottomley <JBottomley@Parallels.com>
Tue, 30 Aug 2011 19:13:46 +0000 (12:13 -0700)
->queuecommand must return either 0, or one of the SCSI_MLQUEUE_* return
values.  Non-transient errors are indicated by setting cmd->result before
calling ->scsi_done and returning 0.  Fix libsas to adhere to this calling
convention.  Note that the DID_ERROR for returns from the low-level driver
might not be correct for all cases, but it's the best we can do with
the current layering in libsas.  I also suspect that the pre-existing
handling of -SAS_QUEUE_FULL should really be SCSI_MLQUEUE_HOST_BUSY, but
I'll leave that for a separate change.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/libsas/sas_scsi_host.c

index 9dd1e9eda19b0964ceb99a1d8bd962064a63ad59..d625577ed152f30005168e028bbe730f4487c775 100644 (file)
@@ -207,7 +207,7 @@ int sas_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 
        task = sas_create_task(cmd, dev, GFP_ATOMIC);
        if (!task)
-               return -ENOMEM;
+               return SCSI_MLQUEUE_HOST_BUSY;
 
        /* Queue up, Direct Mode or Task Collector Mode. */
        if (sas_ha->lldd_max_execute_num < 2)
@@ -223,9 +223,10 @@ out_free_task:
        SAS_DPRINTK("lldd_execute_task returned: %d\n", res);
        ASSIGN_SAS_TASK(cmd, NULL);
        sas_free_task(task);
-       if (res != -SAS_QUEUE_FULL)
-               return res;
-       cmd->result = DID_SOFT_ERROR << 16; /* retry */
+       if (res == -SAS_QUEUE_FULL)
+               cmd->result = DID_SOFT_ERROR << 16; /* retry */
+       else
+               cmd->result = DID_ERROR << 16;
 out_done:
        cmd->scsi_done(cmd);
        return 0;