From: Paul Clements <paul.clements@steeleye.com>

There appears to be a small problem with the as-limit-queue-depth patch
that is in -mm latest.  That patch introduces a case where the next_request
function returns NULL, even though there are available queued requests.  It
looks like most, if not all, block drivers make the assumption that if
elv_next_request returns NULL, then the request queue is empty (and thus
the block layer will handle plugging the request queue for them).  With the
queue-depth patch, that assumption is no longer valid, which can lead to a
driver's request queue staying unplugged indefinitely, preventing the
driver's do_request function from ever getting called again.  The attached
(briefly tested) fixes this.

Signed-Off-By: Paul Clements <paul.clements@steeleye.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/block/as-iosched.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)

diff -puN drivers/block/as-iosched.c~as-limit-queue-depth-fix drivers/block/as-iosched.c
--- 25/drivers/block/as-iosched.c~as-limit-queue-depth-fix	2005-06-08 14:48:27.000000000 -0700
+++ 25-akpm/drivers/block/as-iosched.c	2005-06-08 14:48:27.000000000 -0700
@@ -1400,8 +1400,10 @@ static struct request *as_next_request(r
 	 */
 	if (arq->in_flight)
 		return rq;
-	else if (ad->in_flight >= ad->queue_depth)
+	else if (ad->in_flight >= ad->queue_depth) {
+		blk_plug_device(q); /* we're deferring this request so plug q */
 		return NULL;
+	}
 
 	arq->in_flight = 1;
 	ad->in_flight++;
_