[Patch 3/5] I/O statistics through request queues: small SCSI cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



improving readability of code by using a local struct scsi_device
pointer in scsi_dispatch_cmd()

Signed-off-by: Martin Peschke <[email protected]>
---

 scsi.c |   32 ++++++++++++++------------------
 1 files changed, 14 insertions(+), 18 deletions(-)

diff -urp a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
--- a/drivers/scsi/scsi.c	2006-10-03 16:25:51.000000000 +0200
+++ b/drivers/scsi/scsi.c	2006-10-08 22:28:01.000000000 +0200
@@ -481,25 +481,26 @@ static inline void scsi_cmd_get_serial(s
  */
 int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
 {
-	struct Scsi_Host *host = cmd->device->host;
+	struct scsi_device *sdev = cmd->device;
+	struct Scsi_Host *host = sdev->host;
 	unsigned long flags = 0;
 	unsigned long timeout;
 	int rtn = 0;
 
 	/* check if the device is still usable */
-	if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
+	if (unlikely(sdev->sdev_state == SDEV_DEL)) {
 		/* in SDEV_DEL we error all commands. DID_NO_CONNECT
 		 * returns an immediate error upwards, and signals
 		 * that the device is no longer present */
 		cmd->result = DID_NO_CONNECT << 16;
-		atomic_inc(&cmd->device->iorequest_cnt);
+		atomic_inc(&sdev->iorequest_cnt);
 		__scsi_done(cmd);
 		/* return 0 (because the command has been processed) */
 		goto out;
 	}
 
 	/* Check to see if the scsi lld put this device into state SDEV_BLOCK. */
-	if (unlikely(cmd->device->sdev_state == SDEV_BLOCK)) {
+	if (unlikely(sdev->sdev_state == SDEV_BLOCK)) {
 		/* 
 		 * in SDEV_BLOCK, the command is just put back on the device
 		 * queue.  The suspend state has already blocked the queue so
@@ -517,14 +518,9 @@ int scsi_dispatch_cmd(struct scsi_cmnd *
 		goto out;
 	}
 
-	/* 
-	 * If SCSI-2 or lower, store the LUN value in cmnd.
-	 */
-	if (cmd->device->scsi_level <= SCSI_2 &&
-	    cmd->device->scsi_level != SCSI_UNKNOWN) {
-		cmd->cmnd[1] = (cmd->cmnd[1] & 0x1f) |
-			       (cmd->device->lun << 5 & 0xe0);
-	}
+	/* If SCSI-2 or lower, store the LUN value in cmnd. */
+	if (sdev->scsi_level <= SCSI_2 && sdev->scsi_level != SCSI_UNKNOWN)
+		cmd->cmnd[1] = (cmd->cmnd[1] & 0x1f) | (sdev->lun << 5 & 0xe0);
 
 	/*
 	 * We will wait MIN_RESET_DELAY clock ticks after the last reset so
@@ -560,17 +556,16 @@ int scsi_dispatch_cmd(struct scsi_cmnd *
 	 * We will use a queued command if possible, otherwise we will
 	 * emulate the queuing and calling of completion function ourselves.
 	 */
-	atomic_inc(&cmd->device->iorequest_cnt);
+	atomic_inc(&sdev->iorequest_cnt);
 
 	/*
 	 * Before we queue this command, check if the command
 	 * length exceeds what the host adapter can handle.
 	 */
-	if (CDB_SIZE(cmd) > cmd->device->host->max_cmd_len) {
+	if (CDB_SIZE(cmd) > host->max_cmd_len) {
 		SCSI_LOG_MLQUEUE(3,
 				printk("queuecommand : command too long.\n"));
 		cmd->result = (DID_ABORT << 16);
-
 		scsi_done(cmd);
 		goto out;
 	}
@@ -587,7 +582,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *
 	spin_unlock_irqrestore(host->host_lock, flags);
 	if (rtn) {
 		if (scsi_delete_timer(cmd)) {
-			atomic_inc(&cmd->device->iodone_cnt);
+			atomic_inc(&sdev->iodone_cnt);
 			scsi_queue_insert(cmd,
 					  (rtn == SCSI_MLQUEUE_DEVICE_BUSY) ?
 					  rtn : SCSI_MLQUEUE_HOST_BUSY);
@@ -651,6 +646,7 @@ static void scsi_done(struct scsi_cmnd *
  * isn't running --- used by scsi_times_out */
 void __scsi_done(struct scsi_cmnd *cmd)
 {
+	struct scsi_device *sdev = cmd->device;
 	struct request *rq = cmd->request;
 
 	/*
@@ -658,9 +654,9 @@ void __scsi_done(struct scsi_cmnd *cmd)
 	 */
 	cmd->serial_number = 0;
 
-	atomic_inc(&cmd->device->iodone_cnt);
+	atomic_inc(&sdev->iodone_cnt);
 	if (cmd->result)
-		atomic_inc(&cmd->device->ioerr_cnt);
+		atomic_inc(&sdev->ioerr_cnt);
 
 	BUG_ON(!rq);
 



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux