[PATCH] fix ordering on requeued request drainage

Previously, if a fs request which was being drained failed and got
requeued, blk_do_ordered() didn't allow it to be reissued, which causes
queue stall.  This patch makes blk_do_ordered() use the sequence of each
request to determine whether a request can be issued or not.  This fixes
the bug and simplifies code.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Acked-by: Jens Axboe <axboe@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Jens Axboe 2006-02-04 23:27:38 -08:00 committed by Linus Torvalds
parent 88a2a4ac6b
commit 9a7a67af8b
1 changed files with 16 additions and 22 deletions

View File

@ -508,7 +508,7 @@ static inline struct request *start_ordered(request_queue_t *q,
int blk_do_ordered(request_queue_t *q, struct request **rqp)
{
struct request *rq = *rqp, *allowed_rq;
struct request *rq = *rqp;
int is_barrier = blk_fs_request(rq) && blk_barrier_rq(rq);
if (!q->ordseq) {
@ -532,32 +532,26 @@ int blk_do_ordered(request_queue_t *q, struct request **rqp)
}
}
/*
* Ordered sequence in progress
*/
/* Special requests are not subject to ordering rules. */
if (!blk_fs_request(rq) &&
rq != &q->pre_flush_rq && rq != &q->post_flush_rq)
return 1;
if (q->ordered & QUEUE_ORDERED_TAG) {
/* Ordered by tag. Blocking the next barrier is enough. */
if (is_barrier && rq != &q->bar_rq)
*rqp = NULL;
return 1;
} else {
/* Ordered by draining. Wait for turn. */
WARN_ON(blk_ordered_req_seq(rq) < blk_ordered_cur_seq(q));
if (blk_ordered_req_seq(rq) > blk_ordered_cur_seq(q))
*rqp = NULL;
}
switch (blk_ordered_cur_seq(q)) {
case QUEUE_ORDSEQ_PREFLUSH:
allowed_rq = &q->pre_flush_rq;
break;
case QUEUE_ORDSEQ_BAR:
allowed_rq = &q->bar_rq;
break;
case QUEUE_ORDSEQ_POSTFLUSH:
allowed_rq = &q->post_flush_rq;
break;
default:
allowed_rq = NULL;
break;
}
if (rq != allowed_rq &&
(blk_fs_request(rq) || rq == &q->pre_flush_rq ||
rq == &q->post_flush_rq))
*rqp = NULL;
return 1;
}