block: Move the second call to get_request to the end of the loop
In function get_request_wait, the second call to get_request could be moved to the end of the while loop, because if the first call to get_request fails, the second call will fail without sleep. Signed-off-by: Zhang Yanmin <yanmin.zhang@intel.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
This commit is contained in:
parent
ca39d651d1
commit
05caf8dbc1
|
@ -806,35 +806,32 @@ static struct request *get_request_wait(struct request_queue *q, int rw_flags,
|
||||||
rq = get_request(q, rw_flags, bio, GFP_NOIO);
|
rq = get_request(q, rw_flags, bio, GFP_NOIO);
|
||||||
while (!rq) {
|
while (!rq) {
|
||||||
DEFINE_WAIT(wait);
|
DEFINE_WAIT(wait);
|
||||||
|
struct io_context *ioc;
|
||||||
struct request_list *rl = &q->rq;
|
struct request_list *rl = &q->rq;
|
||||||
|
|
||||||
prepare_to_wait_exclusive(&rl->wait[rw], &wait,
|
prepare_to_wait_exclusive(&rl->wait[rw], &wait,
|
||||||
TASK_UNINTERRUPTIBLE);
|
TASK_UNINTERRUPTIBLE);
|
||||||
|
|
||||||
rq = get_request(q, rw_flags, bio, GFP_NOIO);
|
blk_add_trace_generic(q, bio, rw, BLK_TA_SLEEPRQ);
|
||||||
|
|
||||||
if (!rq) {
|
__generic_unplug_device(q);
|
||||||
struct io_context *ioc;
|
spin_unlock_irq(q->queue_lock);
|
||||||
|
io_schedule();
|
||||||
|
|
||||||
blk_add_trace_generic(q, bio, rw, BLK_TA_SLEEPRQ);
|
/*
|
||||||
|
* After sleeping, we become a "batching" process and
|
||||||
|
* will be able to allocate at least one request, and
|
||||||
|
* up to a big batch of them for a small period time.
|
||||||
|
* See ioc_batching, ioc_set_batching
|
||||||
|
*/
|
||||||
|
ioc = current_io_context(GFP_NOIO, q->node);
|
||||||
|
ioc_set_batching(q, ioc);
|
||||||
|
|
||||||
__generic_unplug_device(q);
|
spin_lock_irq(q->queue_lock);
|
||||||
spin_unlock_irq(q->queue_lock);
|
|
||||||
io_schedule();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* After sleeping, we become a "batching" process and
|
|
||||||
* will be able to allocate at least one request, and
|
|
||||||
* up to a big batch of them for a small period time.
|
|
||||||
* See ioc_batching, ioc_set_batching
|
|
||||||
*/
|
|
||||||
ioc = current_io_context(GFP_NOIO, q->node);
|
|
||||||
ioc_set_batching(q, ioc);
|
|
||||||
|
|
||||||
spin_lock_irq(q->queue_lock);
|
|
||||||
}
|
|
||||||
finish_wait(&rl->wait[rw], &wait);
|
finish_wait(&rl->wait[rw], &wait);
|
||||||
}
|
|
||||||
|
rq = get_request(q, rw_flags, bio, GFP_NOIO);
|
||||||
|
};
|
||||||
|
|
||||||
return rq;
|
return rq;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user