diff options
| -rw-r--r-- | block/blk-core.c | 42 | ||||
| -rw-r--r-- | block/blk-throttle.c | 3 |
2 files changed, 15 insertions, 30 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 080204a10fcf..71894e143b91 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
| @@ -855,15 +855,11 @@ static struct request *__get_request(struct request_queue *q, int rw_flags, | |||
| 855 | { | 855 | { |
| 856 | struct request *rq; | 856 | struct request *rq; |
| 857 | struct request_list *rl = &q->rq; | 857 | struct request_list *rl = &q->rq; |
| 858 | struct elevator_type *et; | 858 | struct elevator_type *et = q->elevator->type; |
| 859 | struct io_context *ioc; | 859 | struct io_context *ioc = rq_ioc(bio); |
| 860 | struct io_cq *icq = NULL; | 860 | struct io_cq *icq = NULL; |
| 861 | const bool is_sync = rw_is_sync(rw_flags) != 0; | 861 | const bool is_sync = rw_is_sync(rw_flags) != 0; |
| 862 | bool retried = false; | ||
| 863 | int may_queue; | 862 | int may_queue; |
| 864 | retry: | ||
| 865 | et = q->elevator->type; | ||
| 866 | ioc = rq_ioc(bio); | ||
| 867 | 863 | ||
| 868 | if (unlikely(blk_queue_dead(q))) | 864 | if (unlikely(blk_queue_dead(q))) |
| 869 | return NULL; | 865 | return NULL; |
| @@ -875,20 +871,6 @@ retry: | |||
| 875 | if (rl->count[is_sync]+1 >= queue_congestion_on_threshold(q)) { | 871 | if (rl->count[is_sync]+1 >= queue_congestion_on_threshold(q)) { |
| 876 | if (rl->count[is_sync]+1 >= q->nr_requests) { | 872 | if (rl->count[is_sync]+1 >= q->nr_requests) { |
| 877 | /* | 873 | /* |
| 878 | * We want ioc to record batching state. If it's | ||
| 879 | * not already there, creating a new one requires | ||
| 880 | * dropping queue_lock, which in turn requires | ||
| 881 | * retesting conditions to avoid queue hang. | ||
| 882 | */ | ||
| 883 | if (!ioc && !retried) { | ||
| 884 | spin_unlock_irq(q->queue_lock); | ||
| 885 | create_io_context(gfp_mask, q->node); | ||
| 886 | spin_lock_irq(q->queue_lock); | ||
| 887 | retried = true; | ||
| 888 | goto retry; | ||
| 889 | } | ||
| 890 | |||
| 891 | /* | ||
| 892 | * The queue will fill after this allocation, so set | 874 | * The queue will fill after this allocation, so set |
| 893 | * it as full, and mark this process as "batching". | 875 | * it as full, and mark this process as "batching". |
| 894 | * This process will be allowed to complete a batch of | 876 | * This process will be allowed to complete a batch of |
| @@ -955,12 +937,8 @@ retry: | |||
| 955 | /* init elvpriv */ | 937 | /* init elvpriv */ |
| 956 | if (rw_flags & REQ_ELVPRIV) { | 938 | if (rw_flags & REQ_ELVPRIV) { |
| 957 | if (unlikely(et->icq_cache && !icq)) { | 939 | if (unlikely(et->icq_cache && !icq)) { |
| 958 | create_io_context(gfp_mask, q->node); | 940 | if (ioc) |
| 959 | ioc = rq_ioc(bio); | 941 | icq = ioc_create_icq(ioc, q, gfp_mask); |
| 960 | if (!ioc) | ||
| 961 | goto fail_elvpriv; | ||
| 962 | |||
| 963 | icq = ioc_create_icq(ioc, q, gfp_mask); | ||
| 964 | if (!icq) | 942 | if (!icq) |
| 965 | goto fail_elvpriv; | 943 | goto fail_elvpriv; |
| 966 | } | 944 | } |
| @@ -1071,7 +1049,6 @@ retry: | |||
| 1071 | * to allocate at least one request, and up to a big batch of them | 1049 | * to allocate at least one request, and up to a big batch of them |
| 1072 | * for a small period time. See ioc_batching, ioc_set_batching | 1050 | * for a small period time. See ioc_batching, ioc_set_batching |
| 1073 | */ | 1051 | */ |
| 1074 | create_io_context(GFP_NOIO, q->node); | ||
| 1075 | ioc_set_batching(q, current->io_context); | 1052 | ioc_set_batching(q, current->io_context); |
| 1076 | 1053 | ||
| 1077 | spin_lock_irq(q->queue_lock); | 1054 | spin_lock_irq(q->queue_lock); |
| @@ -1086,6 +1063,9 @@ struct request *blk_get_request(struct request_queue *q, int rw, gfp_t gfp_mask) | |||
| 1086 | 1063 | ||
| 1087 | BUG_ON(rw != READ && rw != WRITE); | 1064 | BUG_ON(rw != READ && rw != WRITE); |
| 1088 | 1065 | ||
| 1066 | /* create ioc upfront */ | ||
| 1067 | create_io_context(gfp_mask, q->node); | ||
| 1068 | |||
| 1089 | spin_lock_irq(q->queue_lock); | 1069 | spin_lock_irq(q->queue_lock); |
| 1090 | rq = get_request(q, rw, NULL, gfp_mask); | 1070 | rq = get_request(q, rw, NULL, gfp_mask); |
| 1091 | if (!rq) | 1071 | if (!rq) |
| @@ -1698,6 +1678,14 @@ generic_make_request_checks(struct bio *bio) | |||
| 1698 | goto end_io; | 1678 | goto end_io; |
| 1699 | } | 1679 | } |
| 1700 | 1680 | ||
| 1681 | /* | ||
| 1682 | * Various block parts want %current->io_context and lazy ioc | ||
| 1683 | * allocation ends up trading a lot of pain for a small amount of | ||
| 1684 | * memory. Just allocate it upfront. This may fail and block | ||
| 1685 | * layer knows how to live with it. | ||
| 1686 | */ | ||
| 1687 | create_io_context(GFP_ATOMIC, q->node); | ||
| 1688 | |||
| 1701 | if (blk_throtl_bio(q, bio)) | 1689 | if (blk_throtl_bio(q, bio)) |
| 1702 | return false; /* throttled, will be resubmitted later */ | 1690 | return false; /* throttled, will be resubmitted later */ |
| 1703 | 1691 | ||
diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 5b0659512047..e287c19908c8 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c | |||
| @@ -1123,9 +1123,6 @@ bool blk_throtl_bio(struct request_queue *q, struct bio *bio) | |||
| 1123 | goto out; | 1123 | goto out; |
| 1124 | } | 1124 | } |
| 1125 | 1125 | ||
| 1126 | /* bio_associate_current() needs ioc, try creating */ | ||
| 1127 | create_io_context(GFP_ATOMIC, q->node); | ||
| 1128 | |||
| 1129 | /* | 1126 | /* |
| 1130 | * A throtl_grp pointer retrieved under rcu can be used to access | 1127 | * A throtl_grp pointer retrieved under rcu can be used to access |
| 1131 | * basic fields like stats and io rates. If a group has no rules, | 1128 | * basic fields like stats and io rates. If a group has no rules, |
