Re: Q: Block drivers and the io_request_lock

From: Jonathan Corbet (corbet-lk@lwn.net)
Date: Tue Aug 08 2000 - 11:50:55 EST


Hi, Jens,

Thanks for responding to my mail.

> > - Once the lock has been dropped, it would seem that nothing prevents
> > the system from calling _request() again, should more requests be added
> > to the queue - perhaps even when the first invocation is still running.
> > Correct?
>
> The request fn will not be reinvoked until the queue has been plugged
> again, and that requires that the queue has been emptied. In 2.4
> devices use plugging by default.

I think that is not true. __make_request will call the request function
anytime a request is added and the queue is not plugged. Since plugging
only happens when the queue is empty, a block driver with requests sitting
on the queue can, in fact, see multiple calls to the request function. I
was able to demonstrate this to myself in a test driver by introducing a
suitably long delay before actually removing requests from the queue.

> If you exit before having processed all requests in
> the queue, you need to replug -- but I would consider doing that from
> the driver pretty hacky.

Really? From ll_rw_blk.c:

> @rfn is not required, or even expected, to remove all requests off the
> queue, but only as many as it can handle at a time. If it does leave
> requests on the queue, it is responsible for arranging that the requests
> get dealt with eventually.

>From that I had concluded that leaving requests on the queue was cool - as
long as they don't stay there forever. A number of drivers seem to work
that way - the floppy driver, for example, doesn't bother to dequeue
requests until they are done.

> You can get away with not holding io_request_lock when calling
> end_request (or end_that_request_*) if it is the first request on the
> queue.

One may be able to "get away" with it now - but should I advise people to
do things that way in the driver book? My inclination is to tell people to
be a bit more careful.

Thanks muhc for your help on this matter... with luck I'll actually get
all this stuff straight before long.

jon

Jonathan Corbet
Executive editor, LWN.net
corbet@eklektix.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Aug 15 2000 - 21:00:15 EST