aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2007-12-13 13:43:22 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-01-11 19:28:22 -0500
commit7207fea452cfdd2d4e2f4419e2c31f570edbade3 (patch)
treed240295f67ad9286295516dabc9949d5d3739700 /drivers
parentda32dd681f7a1a17073c42b375fc23cf73c92155 (diff)
[SCSI] iscsi: Prettify resid handling and some extra checks
- 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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/iscsi_tcp.c16
-rw-r--r--drivers/scsi/libiscsi.c12
2 files changed, 14 insertions, 14 deletions
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 1b540e03f5bf..fd88777df28b 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -507,22 +507,20 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
507 } 507 }
508 508
509 if (rhdr->flags & ISCSI_FLAG_DATA_STATUS) { 509 if (rhdr->flags & ISCSI_FLAG_DATA_STATUS) {
510 sc->result = (DID_OK << 16) | rhdr->cmd_status;
510 conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1; 511 conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
511 if (rhdr->flags & ISCSI_FLAG_DATA_UNDERFLOW) { 512 if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW |
513 ISCSI_FLAG_DATA_OVERFLOW)) {
512 int res_count = be32_to_cpu(rhdr->residual_count); 514 int res_count = be32_to_cpu(rhdr->residual_count);
513 515
514 if (res_count > 0 && 516 if (res_count > 0 &&
515 res_count <= scsi_bufflen(sc)) { 517 (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
518 res_count <= scsi_bufflen(sc)))
516 scsi_set_resid(sc, res_count); 519 scsi_set_resid(sc, res_count);
517 sc->result = (DID_OK << 16) | rhdr->cmd_status; 520 else
518 } else
519 sc->result = (DID_BAD_TARGET << 16) | 521 sc->result = (DID_BAD_TARGET << 16) |
520 rhdr->cmd_status; 522 rhdr->cmd_status;
521 } else if (rhdr->flags & ISCSI_FLAG_DATA_OVERFLOW) { 523 }
522 scsi_set_resid(sc, be32_to_cpu(rhdr->residual_count));
523 sc->result = (DID_OK << 16) | rhdr->cmd_status;
524 } else
525 sc->result = (DID_OK << 16) | rhdr->cmd_status;
526 } 524 }
527 525
528 conn->datain_pdus_cnt++; 526 conn->datain_pdus_cnt++;
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 176458f35316..0beb4c620962 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -291,17 +291,19 @@ invalid_datalen:
291 min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE)); 291 min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE));
292 } 292 }
293 293
294 if (rhdr->flags & ISCSI_FLAG_CMD_UNDERFLOW) { 294 if (rhdr->flags & (ISCSI_FLAG_CMD_UNDERFLOW |
295 ISCSI_FLAG_CMD_OVERFLOW)) {
295 int res_count = be32_to_cpu(rhdr->residual_count); 296 int res_count = be32_to_cpu(rhdr->residual_count);
296 297
297 if (res_count > 0 && res_count <= scsi_bufflen(sc)) 298 if (res_count > 0 &&
299 (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
300 res_count <= scsi_bufflen(sc)))
298 scsi_set_resid(sc, res_count); 301 scsi_set_resid(sc, res_count);
299 else 302 else
300 sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status; 303 sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
301 } else if (rhdr->flags & ISCSI_FLAG_CMD_BIDI_UNDERFLOW) 304 } else if (rhdr->flags & (ISCSI_FLAG_CMD_BIDI_UNDERFLOW |
305 ISCSI_FLAG_CMD_BIDI_OVERFLOW))
302 sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status; 306 sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
303 else if (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW)
304 scsi_set_resid(sc, be32_to_cpu(rhdr->residual_count));
305 307
306out: 308out:
307 debug_scsi("done [sc %lx res %d itt 0x%x]\n", 309 debug_scsi("done [sc %lx res %d itt 0x%x]\n",