blk: fix possible queue stall in blk_do_ordered
PATCH 1/1 blk: fix possible queue stall in blk_do_ordered
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.
--
Jens, this fix is not very urgent. The bug is not likely to be triggered easily. I think pushing this to -mm first would be better.
Thanks.
block/ll_rw_blk.c +16 -22
@@ -494,7 +494,7 @@ static inline struct request *start_ordeint 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) {
@@ -518,32 +518,26 @@ int blk_do_ordered(request_queue_t *q, s } } +/* +* 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 ; }
Quoted 5 lines · Tejun Heo
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 makesblk_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.
What kernel(s) is this against? The patch seems to fail on 2.6.15.
Thanks
Quoted 9 lines · Mark Lord
Quoted 5 lines · Tejun Heo
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 makesblk_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.
Quoted 3 lines
What kernel(s) is this against? The patch seems to fail on 2.6.15.
Thanks
It's against v2.6.15-mm2. It's sort of a follow-up patch for the following.
http://marc.theaimsgroup.com/?l=linux-kernel&m=113707430626490&w=2
Signature · 1 line
tejun