Skip to content

Commit 255bb49

Browse files
htejunJens Axboe
authored andcommitted
block: blk-flush shouldn't call directly into q->request_fn() __blk_run_queue()
blk-flush decomposes a flush into sequence of multiple requests. On completion of a request, the next one is queued; however, block layer must not implicitly call into q->request_fn() directly from completion path. This makes the queue behave unexpectedly when seen from the drivers and violates the assumption that q->request_fn() is called with process context + queue_lock. This patch makes blk-flush the following two changes to make sure q->request_fn() is not called directly from request completion path. - blk_flush_complete_seq_end_io() now asks __blk_run_queue() to always use kblockd instead of calling directly into q->request_fn(). - queue_next_fseq() uses ELEVATOR_INSERT_REQUEUE instead of ELEVATOR_INSERT_FRONT so that elv_insert() doesn't try to unplug the request queue directly. Reported by Jan in the following threads. http://thread.gmane.org/gmane.linux.ide/48778 http://thread.gmane.org/gmane.linux.ide/48786 stable: applicable to v2.6.37. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Jan Beulich <JBeulich@novell.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: stable@kernel.org Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
1 parent 1654e74 commit 255bb49

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎block/blk-flush.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ static void blk_flush_complete_seq_end_io(struct request_queue *q,
6666

6767
/*
6868
* Moving a request silently to empty queue_head may stall the
69-
* queue. Kick the queue in those cases.
69+
* queue. Kick the queue in those cases. This function is called
70+
* from request completion path and calling directly into
71+
* request_fn may confuse the driver. Always use kblockd.
7072
*/
7173
if (was_empty && next_rq)
72-
__blk_run_queue(q, false);
74+
__blk_run_queue(q, true);
7375
}
7476

7577
static void pre_flush_end_io(struct request *rq, int error)
@@ -130,7 +132,7 @@ static struct request *queue_next_fseq(struct request_queue *q)
130132
BUG();
131133
}
132134

133-
elv_insert(q, rq, ELEVATOR_INSERT_FRONT);
135+
elv_insert(q, rq, ELEVATOR_INSERT_REQUEUE);
134136
return rq;
135137
}
136138

0 commit comments

Comments
 (0)