From: Jens Axboe <axboe@suse.de>
To: James Bottomley <James.Bottomley@steeleye.com>
Cc: Badari Pulavarty <pbadari@us.ibm.com>,
Andrew Morton <akpm@digeo.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"Martin J. Bligh" <Martin.Bligh@us.ibm.com>,
Doug Ledford <dledford@redhat.com>
Subject: Re: possible use-after-free in 2.5.44 scsi changes
Date: Sun, 27 Oct 2002 22:54:33 +0100 [thread overview]
Message-ID: <20021027215433.GA30429@suse.de> (raw)
In-Reply-To: <200210272137.g9RLbW413689@localhost.localdomain>
On Sun, Oct 27 2002, James Bottomley wrote:
> axboe@suse.de said:
> > Sure that would suffice, but lets just move to the prep approach right
> > away. First just the global one, later we can do one per device type.
>
> OK, will do. SCSI currently needs the ability to bail on a request
> preparation in such a way that the request will get re-queued for preparation
> (out of command blocks or other resource shortage), which I believe you're
> working on.
Oh sorry, just forgot to send that out. The change needed for this is
very small. Basically, in blkdev.h, add these types:
#define BLKPREP_OK 0 /* serve it */
#define BLKPREP_KILL 1 /* fatal error, kill */
#define BLKPREP_DEFER 2 /* leave on queue */
I've attached the elv_next_request(), sorry about this format but my
tree is just severly crowded with changes in the block area right now so
it's hard to diff.
Now you can just return BLKPREP_DEFER from the prep function, and it
should do what you want. We might need a bit more logic in there, mainly
to cover the case where we deferred the only request on the queue (your
usual plugging thing). Or I might leave that to the driver, dunno. But
at least this small change should make it possible for you to test.
> The per device type is more tricky because SCSI can have more than one
> upper level driver driving the device queue.
I was thinking more of doing device-type things, such as making the
sector into lba, rejecting write command on ro media, copy actual scsi
command, etc. But that might just fit into a generic function. And it
means we can basically kill the ->init_command() functions.
struct request *elv_next_request(request_queue_t *q)
{
struct request *rq;
int ret;
while ((rq = __elv_next_request(q))) {
/*
* just mark as started even if we don't start it, a request
* that has been delayed should not be passed by new incoming
* requests
*/
rq->flags |= REQ_STARTED;
if (&rq->queuelist == q->last_merge)
q->last_merge = NULL;
if ((rq->flags & REQ_DONTPREP) || !q->prep_rq_fn)
break;
ret = q->prep_rq_fn(q, rq);
if (ret == BLKPREP_OK) {
break;
} else if (ret == BLKPREP_DEFER) {
rq = NULL;
break;
} else if (ret == BLKPREP_KILL) {
blkdev_dequeue_request(rq);
rq->flags |= REQ_QUIET;
while (end_that_request_first(rq, 0, rq->nr_sectors))
;
end_that_request_last(rq);
} else {
printk("%s: bad return=%d\n", __FUNCTION__, ret);
break;
}
}
return rq;
}
--
Jens Axboe
next prev parent reply other threads:[~2002-10-27 21:54 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-25 1:39 possible use-after-free in 2.5.44 scsi changes Andrew Morton
2002-10-25 4:06 ` Doug Ledford
2002-10-25 4:40 ` Andrew Morton
2002-10-25 14:21 ` James Bottomley
2002-10-25 4:07 ` Patrick Mansfield
2002-10-25 14:16 ` James Bottomley
2002-10-25 18:34 ` James Bottomley
2002-10-25 18:49 ` Mike Anderson
2002-10-25 19:08 ` Patrick Mansfield
2002-10-25 19:41 ` Mike Anderson
2002-10-25 19:47 ` Jens Axboe
2002-10-25 22:14 ` James Bottomley
2002-10-25 22:18 ` Andrew Morton
2002-10-25 22:23 ` Badari Pulavarty
2002-10-26 0:13 ` James Bottomley
2002-10-26 0:18 ` Mike Anderson
2002-10-26 9:29 ` Jens Axboe
2002-10-27 0:50 ` James Bottomley
2002-10-27 21:20 ` Jens Axboe
2002-10-27 21:37 ` James Bottomley
2002-10-27 21:54 ` Jens Axboe [this message]
2002-10-30 17:39 ` Badari Pulavarty
2002-10-30 18:16 ` Jens Axboe
2002-10-30 19:31 ` Badari Pulavarty
2002-10-30 21:36 ` merlin hughes
2002-10-30 22:19 ` Badari Pulavarty
2002-10-31 2:17 ` merlin
2002-10-31 13:18 ` Jens Axboe
2002-10-31 14:41 ` merlin
2002-10-31 14:46 ` Jens Axboe
2002-10-31 15:04 ` Jens Axboe
2002-10-31 15:12 ` Jens Axboe
2002-10-31 17:41 ` merlin
2002-10-30 20:35 ` David S. Miller
2002-10-30 22:03 ` Badari Pulavarty
-- strict thread matches above, loose matches on Subject: below --
2002-10-31 17:57 Badari Pulavarty
2002-10-31 18:46 ` Jens Axboe
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=20021027215433.GA30429@suse.de \
--to=axboe@suse.de \
--cc=James.Bottomley@steeleye.com \
--cc=Martin.Bligh@us.ibm.com \
--cc=akpm@digeo.com \
--cc=dledford@redhat.com \
--cc=linux-scsi@vger.kernel.org \
--cc=pbadari@us.ibm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.