From: Tejun Heo <htejun@gmail.com>
To: James.Bottomley@steeleye.com, axboe@suse.de
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH scsi-misc-2.6 08/13] scsi: move request preps in other places into prep_fn()
Date: Thu, 31 Mar 2005 18:08:30 +0900 (KST) [thread overview]
Message-ID: <20050331090647.94FFEC1E@htj.dyndns.org> (raw)
In-Reply-To: <20050331090647.FEDC3964@htj.dyndns.org>
08_scsi_move_preps_to_prep_fn.patch
Move request preparations scattered in scsi_request_fn() and
scsi_dispatch_cmd() into scsi_prep_fn().
* CDB_SIZE check in scsi_dispatch_cmd()
* SCSI-2 LUN preparation in scsi_dispatch_cmd()
* scsi_init_cmd_errh() in scsi_request_fn()
No invalid request reaches scsi_request_fn() anymore.
Signed-off-by: Tejun Heo <htejun@gmail.com>
scsi.c | 30 ------------------------------
scsi_lib.c | 25 +++++++++++++++++++------
2 files changed, 19 insertions(+), 36 deletions(-)
Index: scsi-export/drivers/scsi/scsi.c
===================================================================
--- scsi-export.orig/drivers/scsi/scsi.c 2005-03-31 18:06:21.000000000 +0900
+++ scsi-export/drivers/scsi/scsi.c 2005-03-31 18:06:22.000000000 +0900
@@ -79,15 +79,6 @@
#define MIN_RESET_PERIOD (15*HZ)
/*
- * Macro to determine the size of SCSI command. This macro takes vendor
- * unique commands into account. SCSI commands in groups 6 and 7 are
- * vendor unique and we will depend upon the command length being
- * supplied correctly in cmd_len.
- */
-#define CDB_SIZE(cmd) (((((cmd)->cmnd[0] >> 5) & 7) < 6) ? \
- COMMAND_SIZE((cmd)->cmnd[0]) : (cmd)->cmd_len)
-
-/*
* Note - the initial logging level can be set here to log events at boot time.
* After the system is up, you may enable logging via the /proc interface.
*/
@@ -566,14 +557,6 @@ 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->cmnd[1] = (cmd->cmnd[1] & 0x1f) |
- (cmd->device->lun << 5 & 0xe0);
- }
-
/*
* We will wait MIN_RESET_DELAY clock ticks after the last reset so
* we can avoid the drive not being ready.
@@ -614,19 +597,6 @@ int scsi_dispatch_cmd(struct scsi_cmnd *
atomic_inc(&cmd->device->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) {
- SCSI_LOG_MLQUEUE(3,
- printk("queuecommand : command too long.\n"));
- cmd->result = (DID_ABORT << 16);
-
- scsi_done(cmd);
- goto out;
- }
-
spin_lock_irqsave(host->host_lock, flags);
scsi_cmd_get_serial(host, cmd);
Index: scsi-export/drivers/scsi/scsi_lib.c
===================================================================
--- scsi-export.orig/drivers/scsi/scsi_lib.c 2005-03-31 18:06:21.000000000 +0900
+++ scsi-export/drivers/scsi/scsi_lib.c 2005-03-31 18:06:22.000000000 +0900
@@ -28,6 +28,14 @@
#include "scsi_priv.h"
#include "scsi_logging.h"
+/*
+ * Macro to determine the size of SCSI command. This macro takes vendor
+ * unique commands into account. SCSI commands in groups 6 and 7 are
+ * vendor unique and we will depend upon the command length being
+ * supplied correctly in cmd_len.
+ */
+#define CDB_SIZE(cmd) (((((cmd)->cmnd[0] >> 5) & 7) < 6) ? \
+ COMMAND_SIZE((cmd)->cmnd[0]) : (cmd)->cmd_len)
#define SG_MEMPOOL_NR (sizeof(scsi_sg_pools)/sizeof(struct scsi_host_sg_pool))
#define SG_MEMPOOL_SIZE 32
@@ -1140,6 +1148,17 @@ static int scsi_prep_fn(struct request_q
goto kill;
}
+ /* Check command length. */
+ if (CDB_SIZE(cmd) > sdev->host->max_cmd_len)
+ goto kill;
+
+ scsi_init_cmd_errh(cmd);
+
+ /* If SCSI-2 or lower, store the LUN value in cmnd. */
+ if (cmd->device->scsi_level <= SCSI_2)
+ cmd->cmnd[1] = (cmd->cmnd[1] & 0x1f) |
+ (cmd->device->lun << 5 & 0xe0);
+
/*
* The request is now prepped, no need to come back here
*/
@@ -1316,12 +1335,6 @@ static void scsi_request_fn(struct reque
}
/*
- * Finally, initialize any error handling parameters, and set up
- * the timers for timeouts.
- */
- scsi_init_cmd_errh(cmd);
-
- /*
* Dispatch the command to the low-level driver.
*/
rtn = scsi_dispatch_cmd(cmd);
next prev parent reply other threads:[~2005-03-31 9:26 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-31 9:07 [PATCH scsi-misc-2.6 00/13] scsi: scsi_request_fn() rewrite & stuff Tejun Heo
2005-03-31 9:07 ` [PATCH scsi-misc-2.6 01/13] scsi: don't use blk_insert_request() for requeueing Tejun Heo
2005-03-31 10:12 ` Christoph Hellwig
2005-04-01 4:18 ` Tejun Heo
2005-03-31 17:53 ` James Bottomley
2005-04-01 5:01 ` Tejun Heo
2005-04-01 18:09 ` James Bottomley
2005-04-01 22:21 ` Tejun Heo
2005-03-31 9:08 ` [PATCH scsi-misc-2.6 02/13] scsi: don't turn on REQ_SPECIAL on sgtable allocation failure Tejun Heo
2005-03-31 17:53 ` James Bottomley
2005-04-01 5:14 ` Tejun Heo
2005-03-31 9:08 ` [PATCH scsi-misc-2.6 03/13] scsi: remove unused scsi_cmnd->internal_timeout field Tejun Heo
2005-03-31 9:08 ` [PATCH scsi-misc-2.6 04/13] scsi: remove meaningless volatile qualifiers from structure definitions Tejun Heo
2005-03-31 10:11 ` Christoph Hellwig
2005-04-01 5:15 ` Tejun Heo
2005-03-31 9:08 ` [PATCH scsi-misc-2.6 05/13] scsi: remove a timer race from scsi_queue_insert() and cleanup timer Tejun Heo
2005-03-31 10:13 ` Christoph Hellwig
2005-04-01 5:15 ` Tejun Heo
2005-03-31 9:08 ` [PATCH scsi-misc-2.6 06/13] scsi: remove meaningless scsi_cmnd->serial_number_at_timeout field Tejun Heo
2005-03-31 9:08 ` [PATCH scsi-misc-2.6 07/13] scsi: move error handling out of scsi_init_io() into scsi_prep_fn() Tejun Heo
2005-04-01 18:23 ` James Bottomley
2005-04-01 23:07 ` Tejun Heo
2005-03-31 9:08 ` Tejun Heo [this message]
2005-03-31 10:20 ` [PATCH scsi-misc-2.6 08/13] scsi: move request preps in other places into prep_fn() Christoph Hellwig
2005-04-01 5:20 ` Tejun Heo
2005-03-31 18:07 ` James Bottomley
2005-04-01 5:25 ` Tejun Heo
2005-04-04 18:39 ` James Bottomley
2005-04-05 6:19 ` Tejun Heo
2005-04-05 14:20 ` James Bottomley
2005-03-31 9:08 ` [PATCH scsi-misc-2.6 09/13] scsi: in scsi_prep_fn(), remove bogus comments & clean up Tejun Heo
2005-03-31 10:22 ` Christoph Hellwig
2005-03-31 18:02 ` James Bottomley
2005-04-01 5:29 ` Tejun Heo
2005-03-31 9:08 ` [PATCH scsi-misc-2.6 10/13] scsi: rewrite scsi_request_fn() Tejun Heo
2005-03-31 11:14 ` Christoph Hellwig
2005-04-01 5:44 ` Tejun Heo
2005-03-31 9:08 ` [PATCH scsi-misc-2.6 11/13] scsi: add reprep arg to scsi_requeue_command() and make it public Tejun Heo
2005-03-31 10:32 ` Christoph Hellwig
2005-04-01 5:35 ` Tejun Heo
2005-03-31 9:08 ` [PATCH scsi-misc-2.6 12/13] scsi: replace scsi_queue_insert() with scsi_requeue_command() Tejun Heo
2005-03-31 9:08 ` [PATCH scsi-misc-2.6 13/13] scsi: consolidate scsi_cmd_retry() calls in scsi_error.c Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050331090647.94FFEC1E@htj.dyndns.org \
--to=htejun@gmail.com \
--cc=James.Bottomley@steeleye.com \
--cc=axboe@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®