public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] SCSI: rearrange code in scsi_io_completion
@ 2008-09-29 21:11 Alan Stern
  2008-09-30 14:41 ` James Bottomley
  0 siblings, 1 reply; 11+ messages in thread
From: Alan Stern @ 2008-09-29 21:11 UTC (permalink / raw)
  To: James Bottomley; +Cc: SCSI development list

This patch (as1142) consolidates some repetitious code in
scsi_io_completion().  Multiple calls to scsi_end_request() and to
scsi_requeue_command() are combined together and moved to the end of
the function.

This is simple mechanical code motion, with no change in behavior.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

---

Index: usb-2.6/drivers/scsi/scsi_lib.c
===================================================================
--- usb-2.6.orig/drivers/scsi/scsi_lib.c
+++ usb-2.6/drivers/scsi/scsi_lib.c
@@ -910,9 +910,6 @@ void scsi_io_completion(struct scsi_cmnd
 		return;
 	this_count = blk_rq_bytes(req);
 
-	/* good_bytes = 0, or (inclusive) there were leftovers and
-	 * result = 0, so scsi_end_request couldn't retry.
-	 */
 	if (sense_valid && !sense_deferred) {
 		switch (sshdr.sense_key) {
 		case UNIT_ATTENTION:
@@ -921,18 +918,15 @@ void scsi_io_completion(struct scsi_cmnd
 				 * and quietly refuse further access.
 				 */
 				cmd->device->changed = 1;
-				scsi_end_request(cmd, -EIO, this_count, 1);
-				return;
+				goto retry2;
 			} else {
 				/* Must have been a power glitch, or a
 				 * bus reset.  Could not have been a
 				 * media change, so we just retry the
 				 * request and see what happens.
 				 */
-				scsi_requeue_command(q, cmd);
-				return;
+				goto requeue;
 			}
-			break;
 		case ILLEGAL_REQUEST:
 			/* If we had an ILLEGAL REQUEST returned, then
 			 * we may have performed an unsupported
@@ -950,17 +944,14 @@ void scsi_io_completion(struct scsi_cmnd
 				/* This will cause a retry with a
 				 * 6-byte command.
 				 */
-				scsi_requeue_command(q, cmd);
+				goto requeue;
 			} else if (sshdr.asc == 0x10) /* DIX */
-				scsi_end_request(cmd, -EIO, this_count, 0);
+				goto fail;
 			else
-				scsi_end_request(cmd, -EIO, this_count, 1);
-			return;
+				goto retry2;
 		case ABORTED_COMMAND:
-			if (sshdr.asc == 0x10) { /* DIF */
-				scsi_end_request(cmd, -EIO, this_count, 0);
-				return;
-			}
+			if (sshdr.asc == 0x10)  /* DIF */
+				goto fail;
 			break;
 		case NOT_READY:
 			/* If the device is in the process of becoming
@@ -975,8 +966,7 @@ void scsi_io_completion(struct scsi_cmnd
 				case 0x07: /* operation in progress */
 				case 0x08: /* Long write in progress */
 				case 0x09: /* self test in progress */
-					scsi_requeue_command(q, cmd);
-					return;
+					goto requeue;
 				default:
 					break;
 				}
@@ -985,9 +975,7 @@ void scsi_io_completion(struct scsi_cmnd
 				scsi_cmd_print_sense_hdr(cmd,
 							 "Device not ready",
 							 &sshdr);
-
-			scsi_end_request(cmd, -EIO, this_count, 1);
-			return;
+			goto retry2;
 		case VOLUME_OVERFLOW:
 			if (!(req->cmd_flags & REQ_QUIET)) {
 				scmd_printk(KERN_INFO, cmd,
@@ -996,8 +984,7 @@ void scsi_io_completion(struct scsi_cmnd
 				scsi_print_sense("", cmd);
 			}
 			/* See SSC3rXX or current. */
-			scsi_end_request(cmd, -EIO, this_count, 1);
-			return;
+			goto retry2;
 		default:
 			break;
 		}
@@ -1007,8 +994,7 @@ void scsi_io_completion(struct scsi_cmnd
 		 * reasons.  Just retry the request and see what
 		 * happens.
 		 */
-		scsi_requeue_command(q, cmd);
-		return;
+		goto requeue;
 	}
 	if (result) {
 		if (!(req->cmd_flags & REQ_QUIET)) {
@@ -1016,8 +1002,18 @@ void scsi_io_completion(struct scsi_cmnd
 			if (driver_byte(result) & DRIVER_SENSE)
 				scsi_print_sense("", cmd);
 		}
+		goto fail;
 	}
-	scsi_end_request(cmd, -EIO, this_count, !result);
+
+ retry2:
+	scsi_end_request(cmd, -EIO, this_count, 1);
+	return;
+ fail:
+	scsi_end_request(cmd, -EIO, this_count, 0);
+	return;
+ requeue:
+	scsi_requeue_command(q, cmd);
+	return;
 }
 
 static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb,


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-10-01 14:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-29 21:11 [PATCH 1/3] SCSI: rearrange code in scsi_io_completion Alan Stern
2008-09-30 14:41 ` James Bottomley
2008-09-30 15:08   ` Alan Stern
2008-09-30 15:43     ` James Bottomley
2008-09-30 17:11       ` Mike Anderson
2008-09-30 18:07         ` James Bottomley
2008-09-30 19:34           ` Alan Stern
2008-09-30 19:49       ` Alan Stern
2008-09-30 23:24         ` Martin K. Petersen
2008-10-01 13:50           ` Alan Stern
2008-10-01 14:08             ` Douglas Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox