[SCSI] libfc: Add debug statements when fc_fcp returns DID_ERROR to scsi-ml
authorRobert Love <robert.w.love@intel.com>
Sat, 13 Mar 2010 00:08:50 +0000 (16:08 -0800)
committerJames Bottomley <James.Bottomley@suse.de>
Sun, 11 Apr 2010 14:23:44 +0000 (09:23 -0500)
DID_ERROR cases can be ambigouos. Debugging FCP error cases
will be much easier if we have debug statements when we hit
these error conditions.

This patch simply adds debug messages using the FC_FCP_DBG
macro when we return DID_ERROR to SCSI. This way if a DID_ERROR
is reproducible turning on debug_logging will give a clue
to developers as to what the problem might be.

Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/scsi/libfc/fc_fcp.c

index 39f18e39125ca598f57a7457ea7fe25d65280b06..044c420a1371a1a3f088b200a8f96416d61c87b0 100644 (file)
@@ -1916,6 +1916,8 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
                }
                break;
        case FC_ERROR:
+               FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml "
+                          "due to FC_ERROR\n");
                sc_cmd->result = DID_ERROR << 16;
                break;
        case FC_DATA_UNDRUN:
@@ -1924,12 +1926,19 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
                         * scsi status is good but transport level
                         * underrun.
                         */
-                       sc_cmd->result = (fsp->state & FC_SRB_RCV_STATUS ?
-                                         DID_OK : DID_ERROR) << 16;
+                       if (fsp->state & FC_SRB_RCV_STATUS) {
+                               sc_cmd->result = DID_OK << 16;
+                       } else {
+                               FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml"
+                                          " due to FC_DATA_UNDRUN (trans)\n");
+                               sc_cmd->result = DID_ERROR << 16;
+                       }
                } else {
                        /*
                         * scsi got underrun, this is an error
                         */
+                       FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml "
+                                  "due to FC_DATA_UNDRUN (scsi)\n");
                        CMD_RESID_LEN(sc_cmd) = fsp->scsi_resid;
                        sc_cmd->result = (DID_ERROR << 16) | fsp->cdb_status;
                }
@@ -1938,9 +1947,13 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
                /*
                 * overrun is an error
                 */
+               FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml "
+                          "due to FC_DATA_OVRRUN\n");
                sc_cmd->result = (DID_ERROR << 16) | fsp->cdb_status;
                break;
        case FC_CMD_ABORTED:
+               FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml "
+                          "due to FC_CMD_ABORTED\n");
                sc_cmd->result = (DID_ERROR << 16) | fsp->io_status;
                break;
        case FC_CMD_RECOVERY:
@@ -1953,6 +1966,8 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
                sc_cmd->result = (DID_NO_CONNECT << 16);
                break;
        default:
+               FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml "
+                          "due to unknown error\n");
                sc_cmd->result = (DID_ERROR << 16);
                break;
        }