]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[SCSI] iscsi: Prettify resid handling and some extra checks
authorBoaz Harrosh <bharrosh@panasas.com>
Thu, 13 Dec 2007 18:43:22 +0000 (12:43 -0600)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Sat, 12 Jan 2008 00:28:22 +0000 (18:28 -0600)
  - Check to see that OVERFLOW is not negative indicating
    a bug.
  - Unify handling of UNDERFLOW and OVERFLOW to the same
    code.
  - Also handle BIDI_OVERFLOW.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
drivers/scsi/iscsi_tcp.c
drivers/scsi/libiscsi.c

index 1b540e03f5bffe56353010d22f226444ef7d2294..fd88777df28bc440b07eeb07244a8471ccd7f4d0 100644 (file)
@@ -507,22 +507,20 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
        }
 
        if (rhdr->flags & ISCSI_FLAG_DATA_STATUS) {
+               sc->result = (DID_OK << 16) | rhdr->cmd_status;
                conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
-               if (rhdr->flags & ISCSI_FLAG_DATA_UNDERFLOW) {
+               if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW |
+                                  ISCSI_FLAG_DATA_OVERFLOW)) {
                        int res_count = be32_to_cpu(rhdr->residual_count);
 
                        if (res_count > 0 &&
-                           res_count <= scsi_bufflen(sc)) {
+                           (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
+                            res_count <= scsi_bufflen(sc)))
                                scsi_set_resid(sc, res_count);
-                               sc->result = (DID_OK << 16) | rhdr->cmd_status;
-                       } else
+                       else
                                sc->result = (DID_BAD_TARGET << 16) |
                                        rhdr->cmd_status;
-               } else if (rhdr->flags & ISCSI_FLAG_DATA_OVERFLOW) {
-                       scsi_set_resid(sc, be32_to_cpu(rhdr->residual_count));
-                       sc->result = (DID_OK << 16) | rhdr->cmd_status;
-               } else
-                       sc->result = (DID_OK << 16) | rhdr->cmd_status;
+               }
        }
 
        conn->datain_pdus_cnt++;
index 176458f3531641c91aee31fa52c9190377af4337..0beb4c6209621be5ee87237ed52e99675e0a036b 100644 (file)
@@ -291,17 +291,19 @@ invalid_datalen:
                           min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE));
        }
 
-       if (rhdr->flags & ISCSI_FLAG_CMD_UNDERFLOW) {
+       if (rhdr->flags & (ISCSI_FLAG_CMD_UNDERFLOW |
+                          ISCSI_FLAG_CMD_OVERFLOW)) {
                int res_count = be32_to_cpu(rhdr->residual_count);
 
-               if (res_count > 0 && res_count <= scsi_bufflen(sc))
+               if (res_count > 0 &&
+                   (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
+                    res_count <= scsi_bufflen(sc)))
                        scsi_set_resid(sc, res_count);
                else
                        sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
-       } else if (rhdr->flags & ISCSI_FLAG_CMD_BIDI_UNDERFLOW)
+       } else if (rhdr->flags & (ISCSI_FLAG_CMD_BIDI_UNDERFLOW |
+                                 ISCSI_FLAG_CMD_BIDI_OVERFLOW))
                sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
-       else if (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW)
-               scsi_set_resid(sc, be32_to_cpu(rhdr->residual_count));
 
 out:
        debug_scsi("done [sc %lx res %d itt 0x%x]\n",