Commit 05caf8dbc1880415df3378cfd114d832c9618b60
Committed by
Jens Axboe
1 parent
ca39d651d1
Exists in
master
and in
7 other branches
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>
Showing 1 changed file with 17 additions and 20 deletions Side-by-side Diff
block/blk-core.c
... | ... | @@ -806,35 +806,32 @@ |
806 | 806 | rq = get_request(q, rw_flags, bio, GFP_NOIO); |
807 | 807 | while (!rq) { |
808 | 808 | DEFINE_WAIT(wait); |
809 | + struct io_context *ioc; | |
809 | 810 | struct request_list *rl = &q->rq; |
810 | 811 | |
811 | 812 | prepare_to_wait_exclusive(&rl->wait[rw], &wait, |
812 | 813 | TASK_UNINTERRUPTIBLE); |
813 | 814 | |
814 | - rq = get_request(q, rw_flags, bio, GFP_NOIO); | |
815 | + blk_add_trace_generic(q, bio, rw, BLK_TA_SLEEPRQ); | |
815 | 816 | |
816 | - if (!rq) { | |
817 | - struct io_context *ioc; | |
817 | + __generic_unplug_device(q); | |
818 | + spin_unlock_irq(q->queue_lock); | |
819 | + io_schedule(); | |
818 | 820 | |
819 | - blk_add_trace_generic(q, bio, rw, BLK_TA_SLEEPRQ); | |
821 | + /* | |
822 | + * After sleeping, we become a "batching" process and | |
823 | + * will be able to allocate at least one request, and | |
824 | + * up to a big batch of them for a small period time. | |
825 | + * See ioc_batching, ioc_set_batching | |
826 | + */ | |
827 | + ioc = current_io_context(GFP_NOIO, q->node); | |
828 | + ioc_set_batching(q, ioc); | |
820 | 829 | |
821 | - __generic_unplug_device(q); | |
822 | - spin_unlock_irq(q->queue_lock); | |
823 | - io_schedule(); | |
824 | - | |
825 | - /* | |
826 | - * After sleeping, we become a "batching" process and | |
827 | - * will be able to allocate at least one request, and | |
828 | - * up to a big batch of them for a small period time. | |
829 | - * See ioc_batching, ioc_set_batching | |
830 | - */ | |
831 | - ioc = current_io_context(GFP_NOIO, q->node); | |
832 | - ioc_set_batching(q, ioc); | |
833 | - | |
834 | - spin_lock_irq(q->queue_lock); | |
835 | - } | |
830 | + spin_lock_irq(q->queue_lock); | |
836 | 831 | finish_wait(&rl->wait[rw], &wait); |
837 | - } | |
832 | + | |
833 | + rq = get_request(q, rw_flags, bio, GFP_NOIO); | |
834 | + }; | |
838 | 835 | |
839 | 836 | return rq; |
840 | 837 | } |