Commit bfd343aa1718457d34b99ce6573085ac340da288
Committed by
Jens Axboe
1 parent
b94ec29640
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
blk-mq: don't wait in blk_mq_queue_enter() if __GFP_WAIT isn't set
Return -EBUSY if we're unable to enter a queue immediately when allocating a blk-mq request without __GFP_WAIT. Signed-off-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Showing 1 changed file with 6 additions and 3 deletions Side-by-side Diff
block/blk-mq.c
... | ... | @@ -77,7 +77,7 @@ |
77 | 77 | clear_bit(CTX_TO_BIT(hctx, ctx), &bm->word); |
78 | 78 | } |
79 | 79 | |
80 | -static int blk_mq_queue_enter(struct request_queue *q) | |
80 | +static int blk_mq_queue_enter(struct request_queue *q, gfp_t gfp) | |
81 | 81 | { |
82 | 82 | while (true) { |
83 | 83 | int ret; |
... | ... | @@ -85,6 +85,9 @@ |
85 | 85 | if (percpu_ref_tryget_live(&q->mq_usage_counter)) |
86 | 86 | return 0; |
87 | 87 | |
88 | + if (!(gfp & __GFP_WAIT)) | |
89 | + return -EBUSY; | |
90 | + | |
88 | 91 | ret = wait_event_interruptible(q->mq_freeze_wq, |
89 | 92 | !q->mq_freeze_depth || blk_queue_dying(q)); |
90 | 93 | if (blk_queue_dying(q)) |
... | ... | @@ -256,7 +259,7 @@ |
256 | 259 | struct blk_mq_alloc_data alloc_data; |
257 | 260 | int ret; |
258 | 261 | |
259 | - ret = blk_mq_queue_enter(q); | |
262 | + ret = blk_mq_queue_enter(q, gfp); | |
260 | 263 | if (ret) |
261 | 264 | return ERR_PTR(ret); |
262 | 265 | |
... | ... | @@ -1186,7 +1189,7 @@ |
1186 | 1189 | int rw = bio_data_dir(bio); |
1187 | 1190 | struct blk_mq_alloc_data alloc_data; |
1188 | 1191 | |
1189 | - if (unlikely(blk_mq_queue_enter(q))) { | |
1192 | + if (unlikely(blk_mq_queue_enter(q, GFP_KERNEL))) { | |
1190 | 1193 | bio_endio(bio, -EIO); |
1191 | 1194 | return NULL; |
1192 | 1195 | } |