mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-13 01:44:28 +00:00
block: only call ->request_fn when the queue is not stopped
Callers should use either blk_run_queue/__blk_run_queue, or blk_start_queueing() to invoke request handling instead of calling ->request_fn() directly as that does not take the queue stopped flag into account. Also add appropriate comments on the above functions to detail their usage. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
This commit is contained in:
parent
ee2e992cc2
commit
80a4b58e36
2 changed files with 20 additions and 6 deletions
|
@ -325,6 +325,9 @@ EXPORT_SYMBOL(blk_unplug);
|
||||||
|
|
||||||
static void blk_invoke_request_fn(struct request_queue *q)
|
static void blk_invoke_request_fn(struct request_queue *q)
|
||||||
{
|
{
|
||||||
|
if (unlikely(blk_queue_stopped(q)))
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* one level of recursion is ok and is much faster than kicking
|
* one level of recursion is ok and is much faster than kicking
|
||||||
* the unplug handling
|
* the unplug handling
|
||||||
|
@ -399,8 +402,13 @@ void blk_sync_queue(struct request_queue *q)
|
||||||
EXPORT_SYMBOL(blk_sync_queue);
|
EXPORT_SYMBOL(blk_sync_queue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* blk_run_queue - run a single device queue
|
* __blk_run_queue - run a single device queue
|
||||||
* @q: The queue to run
|
* @q: The queue to run
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* See @blk_run_queue. This variant must be called with the queue lock
|
||||||
|
* held and interrupts disabled.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
void __blk_run_queue(struct request_queue *q)
|
void __blk_run_queue(struct request_queue *q)
|
||||||
{
|
{
|
||||||
|
@ -418,6 +426,12 @@ EXPORT_SYMBOL(__blk_run_queue);
|
||||||
/**
|
/**
|
||||||
* blk_run_queue - run a single device queue
|
* blk_run_queue - run a single device queue
|
||||||
* @q: The queue to run
|
* @q: The queue to run
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Invoke request handling on this queue, if it has pending work to do.
|
||||||
|
* May be used to restart queueing when a request has completed. Also
|
||||||
|
* See @blk_start_queueing.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
void blk_run_queue(struct request_queue *q)
|
void blk_run_queue(struct request_queue *q)
|
||||||
{
|
{
|
||||||
|
@ -884,7 +898,8 @@ EXPORT_SYMBOL(blk_get_request);
|
||||||
*
|
*
|
||||||
* This is basically a helper to remove the need to know whether a queue
|
* This is basically a helper to remove the need to know whether a queue
|
||||||
* is plugged or not if someone just wants to initiate dispatch of requests
|
* is plugged or not if someone just wants to initiate dispatch of requests
|
||||||
* for this queue.
|
* for this queue. Should be used to start queueing on a device outside
|
||||||
|
* of ->request_fn() context. Also see @blk_run_queue.
|
||||||
*
|
*
|
||||||
* The queue lock must be held with interrupts disabled.
|
* The queue lock must be held with interrupts disabled.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -612,7 +612,7 @@ void elv_insert(struct request_queue *q, struct request *rq, int where)
|
||||||
* processing.
|
* processing.
|
||||||
*/
|
*/
|
||||||
blk_remove_plug(q);
|
blk_remove_plug(q);
|
||||||
q->request_fn(q);
|
blk_start_queueing(q);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ELEVATOR_INSERT_SORT:
|
case ELEVATOR_INSERT_SORT:
|
||||||
|
@ -950,7 +950,7 @@ void elv_completed_request(struct request_queue *q, struct request *rq)
|
||||||
blk_ordered_cur_seq(q) == QUEUE_ORDSEQ_DRAIN &&
|
blk_ordered_cur_seq(q) == QUEUE_ORDSEQ_DRAIN &&
|
||||||
blk_ordered_req_seq(first_rq) > QUEUE_ORDSEQ_DRAIN) {
|
blk_ordered_req_seq(first_rq) > QUEUE_ORDSEQ_DRAIN) {
|
||||||
blk_ordered_complete_seq(q, QUEUE_ORDSEQ_DRAIN, 0);
|
blk_ordered_complete_seq(q, QUEUE_ORDSEQ_DRAIN, 0);
|
||||||
q->request_fn(q);
|
blk_start_queueing(q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1109,8 +1109,7 @@ static int elevator_switch(struct request_queue *q, struct elevator_type *new_e)
|
||||||
elv_drain_elevator(q);
|
elv_drain_elevator(q);
|
||||||
|
|
||||||
while (q->rq.elvpriv) {
|
while (q->rq.elvpriv) {
|
||||||
blk_remove_plug(q);
|
blk_start_queueing(q);
|
||||||
q->request_fn(q);
|
|
||||||
spin_unlock_irq(q->queue_lock);
|
spin_unlock_irq(q->queue_lock);
|
||||||
msleep(10);
|
msleep(10);
|
||||||
spin_lock_irq(q->queue_lock);
|
spin_lock_irq(q->queue_lock);
|
||||||
|
|
Loading…
Add table
Reference in a new issue