From: James Bottomley <James.Bottomley@SteelEye.com>
To: Mike Christie <michaelc@cs.wisc.edu>
Cc: device-mapper development <dm-devel@redhat.com>,
Jens Axboe <axboe@suse.de>,
linux-scsi <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH RFC 0/4] use scatter lists for all block pc requests and simplify hw handlers
Date: Sat, 04 Jun 2005 11:07:14 -0500 [thread overview]
Message-ID: <1117901234.5005.9.camel@mulgrave> (raw)
In-Reply-To: <1117847972.23638.62.camel@mina>
On Fri, 2005-06-03 at 18:19 -0700, Mike Christie wrote:
> The goal is next convert the scsi 'special' requests to use these
> functions, so scsi will be able to use block layer functions for scatter
> lists setup for all requests. And then hopefully one day we will not
> need those stinking "if (sc->use_sg)" paths all over our scsi drivers.
Here's the proof of concept for this one. It converts scsi_wait_req to
do correct REQ_BLOCK_PC submission (and works nicely in my setup).
The final goal should be to eliminate struct scsi_request, but that
can't be done until the character submission paths of sg and st are also
modified.
There's some loss of functionality to this: retries are no longer
controllable (except by setting REQ_FASTFAIL) and the wait_req API needs
to be altered, but it looks very nice.
Thanks,
James
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -238,23 +238,6 @@ void scsi_do_req(struct scsi_request *sr
}
EXPORT_SYMBOL(scsi_do_req);
-static void scsi_wait_done(struct scsi_cmnd *cmd)
-{
- struct request *req = cmd->request;
- struct request_queue *q = cmd->device->request_queue;
- unsigned long flags;
-
- req->rq_status = RQ_SCSI_DONE; /* Busy, but indicate request done */
-
- spin_lock_irqsave(q->queue_lock, flags);
- if (blk_rq_tagged(req))
- blk_queue_end_tag(q, req);
- spin_unlock_irqrestore(q->queue_lock, flags);
-
- if (req->waiting)
- complete(req->waiting);
-}
-
/* This is the end routine we get to if a command was never attached
* to the request. Simply complete the request without changing
* rq_status; this will cause a DRIVER_ERROR. */
@@ -269,19 +252,36 @@ void scsi_wait_req(struct scsi_request *
unsigned bufflen, int timeout, int retries)
{
DECLARE_COMPLETION(wait);
-
- sreq->sr_request->waiting = &wait;
- sreq->sr_request->rq_status = RQ_SCSI_BUSY;
- sreq->sr_request->end_io = scsi_wait_req_end_io;
- scsi_do_req(sreq, cmnd, buffer, bufflen, scsi_wait_done,
- timeout, retries);
+ struct request *req;
+
+ if (bufflen)
+ req = blk_rq_map_kern(sreq->sr_device->request_queue,
+ sreq->sr_data_direction == DMA_TO_DEVICE,
+ buffer, bufflen, __GFP_WAIT);
+ else
+ req = blk_get_request(sreq->sr_device->request_queue, READ,
+ __GFP_WAIT);
+ req->flags |= REQ_NOMERGE;
+ req->waiting = &wait;
+ req->end_io = scsi_wait_req_end_io;
+ req->cmd_len = COMMAND_SIZE(((u8 *)cmnd)[0]);
+ req->sense = sreq->sr_sense_buffer;
+ req->sense_len = 0;
+ memcpy(req->cmd, cmnd, req->cmd_len);
+ req->timeout = timeout;
+ req->flags |= REQ_BLOCK_PC;
+ req->rq_disk = NULL;
+ blk_insert_request(sreq->sr_device->request_queue, req,
+ sreq->sr_data_direction == DMA_TO_DEVICE, NULL);
wait_for_completion(&wait);
sreq->sr_request->waiting = NULL;
- if (sreq->sr_request->rq_status != RQ_SCSI_DONE)
+ sreq->sr_result = req->errors;
+ if (req->errors)
sreq->sr_result |= (DRIVER_ERROR << 24);
- __scsi_release_request(sreq);
+ blk_put_request(req);
}
+
EXPORT_SYMBOL(scsi_wait_req);
/*
@@ -889,11 +889,12 @@ void scsi_io_completion(struct scsi_cmnd
return;
}
if (result) {
- printk(KERN_INFO "SCSI error : <%d %d %d %d> return code "
- "= 0x%x\n", cmd->device->host->host_no,
- cmd->device->channel,
- cmd->device->id,
- cmd->device->lun, result);
+ if (!(req->flags & REQ_SPECIAL))
+ printk(KERN_INFO "SCSI error : <%d %d %d %d> return code "
+ "= 0x%x\n", cmd->device->host->host_no,
+ cmd->device->channel,
+ cmd->device->id,
+ cmd->device->lun, result);
if (driver_byte(result) & DRIVER_SENSE)
scsi_print_sense("", cmd);
@@ -1026,6 +1027,12 @@ static int scsi_issue_flush_fn(request_q
return -EOPNOTSUPP;
}
+static void scsi_generic_done(struct scsi_cmnd *cmd)
+{
+ BUG_ON(!blk_pc_request(cmd->request));
+ scsi_io_completion(cmd, cmd->result == 0 ? cmd->bufflen : 0, 0);
+}
+
static int scsi_prep_fn(struct request_queue *q, struct request *req)
{
struct scsi_device *sdev = q->queuedata;
@@ -1067,7 +1074,7 @@ static int scsi_prep_fn(struct request_q
* these two cases differently. We differentiate by looking
* at request->cmd, as this tells us the real story.
*/
- if (req->flags & REQ_SPECIAL) {
+ if (req->flags & REQ_SPECIAL && req->special) {
struct scsi_request *sreq = req->special;
if (sreq->sr_magic == SCSI_REQ_MAGIC) {
@@ -1079,7 +1086,7 @@ static int scsi_prep_fn(struct request_q
cmd = req->special;
} else if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) {
- if(unlikely(specials_only)) {
+ if(unlikely(specials_only) && !(req->flags & REQ_SPECIAL)) {
if(specials_only == SDEV_QUIESCE ||
specials_only == SDEV_BLOCK)
return BLKPREP_DEFER;
@@ -1148,11 +1155,26 @@ static int scsi_prep_fn(struct request_q
/*
* Initialize the actual SCSI command for this request.
*/
- drv = *(struct scsi_driver **)req->rq_disk->private_data;
- if (unlikely(!drv->init_command(cmd))) {
- scsi_release_buffers(cmd);
- scsi_put_command(cmd);
- return BLKPREP_KILL;
+ if (req->rq_disk) {
+ drv = *(struct scsi_driver **)req->rq_disk->private_data;
+ if (unlikely(!drv->init_command(cmd))) {
+ scsi_release_buffers(cmd);
+ scsi_put_command(cmd);
+ return BLKPREP_KILL;
+ }
+ } else {
+ memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
+ if (rq_data_dir(req) == WRITE)
+ cmd->sc_data_direction = DMA_TO_DEVICE;
+ else if (req->data_len)
+ cmd->sc_data_direction = DMA_FROM_DEVICE;
+ else
+ cmd->sc_data_direction = DMA_NONE;
+
+ cmd->transfersize = req->data_len;
+ cmd->allowed = 3;
+ cmd->timeout_per_command = req->timeout;
+ cmd->done = scsi_generic_done;
}
}
next prev parent reply other threads:[~2005-06-04 16:07 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-04 1:19 [PATCH RFC 0/4] use scatter lists for all block pc requests and simplify hw handlers Mike Christie
2005-06-04 16:07 ` James Bottomley [this message]
2005-06-05 7:15 ` Mike Christie
2005-06-05 9:41 ` [dm-devel] " christophe varoqui
2005-06-06 13:31 ` Lars Marowsky-Bree
2005-06-07 0:04 ` Michael Christie
2005-06-07 7:01 ` [dm-devel] " Lars Marowsky-Bree
2005-06-05 14:40 ` James Bottomley
2005-06-05 19:11 ` James Bottomley
2005-06-06 5:43 ` Douglas Gilbert
2005-06-06 14:19 ` James Bottomley
2005-06-07 13:08 ` Douglas Gilbert
2005-06-07 13:34 ` Tony Battersby
2005-06-07 16:34 ` James Bottomley
2005-06-07 18:38 ` [PATCH RFC 0/4] use scatter lists for all blockpc " Tony Battersby
2005-06-07 18:43 ` Jens Axboe
2005-06-07 15:59 ` [PATCH RFC 0/4] use scatter lists for all block pc " James Bottomley
2005-06-07 18:07 ` Jens Axboe
2005-06-07 19:26 ` James Bottomley
2005-06-08 7:09 ` Jens Axboe
2005-06-06 19:02 ` Patrick Mansfield
2005-06-07 15:26 ` Michael Christie
2005-06-07 18:23 ` Patrick Mansfield
2005-06-08 15:41 ` Mike Christie
2005-06-09 0:08 ` Patrick Mansfield
2005-06-09 6:18 ` Jens Axboe
2005-06-09 11:51 ` James Bottomley
2005-06-09 11:54 ` Jens Axboe
2005-06-07 12:10 ` Christoph Hellwig
2005-06-07 12:20 ` James Bottomley
2005-06-07 15:36 ` Michael Christie
2005-06-07 15:45 ` [dm-devel] " Michael Christie
2005-06-07 16:26 ` Kai Makisara
2005-06-07 19:23 ` James Bottomley
2005-06-07 18:09 ` Jens Axboe
2005-06-08 12:46 ` Mike Christie
2005-06-07 18:07 ` Jens Axboe
2005-06-07 19:38 ` James Bottomley
2005-06-08 3:00 ` Douglas Gilbert
2005-06-08 12:59 ` James Bottomley
2005-06-08 14:50 ` Luben Tuikov
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=1117901234.5005.9.camel@mulgrave \
--to=james.bottomley@steeleye.com \
--cc=axboe@suse.de \
--cc=dm-devel@redhat.com \
--cc=linux-scsi@vger.kernel.org \
--cc=michaelc@cs.wisc.edu \
/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