Commit bfd343aa authored by Keith Busch's avatar Keith Busch Committed by Jens Axboe

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: default avatarKeith Busch <keith.busch@intel.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent b94ec296
...@@ -77,7 +77,7 @@ static void blk_mq_hctx_clear_pending(struct blk_mq_hw_ctx *hctx, ...@@ -77,7 +77,7 @@ static void blk_mq_hctx_clear_pending(struct blk_mq_hw_ctx *hctx,
clear_bit(CTX_TO_BIT(hctx, ctx), &bm->word); clear_bit(CTX_TO_BIT(hctx, ctx), &bm->word);
} }
static int blk_mq_queue_enter(struct request_queue *q) static int blk_mq_queue_enter(struct request_queue *q, gfp_t gfp)
{ {
while (true) { while (true) {
int ret; int ret;
...@@ -85,6 +85,9 @@ static int blk_mq_queue_enter(struct request_queue *q) ...@@ -85,6 +85,9 @@ static int blk_mq_queue_enter(struct request_queue *q)
if (percpu_ref_tryget_live(&q->mq_usage_counter)) if (percpu_ref_tryget_live(&q->mq_usage_counter))
return 0; return 0;
if (!(gfp & __GFP_WAIT))
return -EBUSY;
ret = wait_event_interruptible(q->mq_freeze_wq, ret = wait_event_interruptible(q->mq_freeze_wq,
!q->mq_freeze_depth || blk_queue_dying(q)); !q->mq_freeze_depth || blk_queue_dying(q));
if (blk_queue_dying(q)) if (blk_queue_dying(q))
...@@ -256,7 +259,7 @@ struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp, ...@@ -256,7 +259,7 @@ struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp,
struct blk_mq_alloc_data alloc_data; struct blk_mq_alloc_data alloc_data;
int ret; int ret;
ret = blk_mq_queue_enter(q); ret = blk_mq_queue_enter(q, gfp);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
...@@ -1186,7 +1189,7 @@ static struct request *blk_mq_map_request(struct request_queue *q, ...@@ -1186,7 +1189,7 @@ static struct request *blk_mq_map_request(struct request_queue *q,
int rw = bio_data_dir(bio); int rw = bio_data_dir(bio);
struct blk_mq_alloc_data alloc_data; struct blk_mq_alloc_data alloc_data;
if (unlikely(blk_mq_queue_enter(q))) { if (unlikely(blk_mq_queue_enter(q, GFP_KERNEL))) {
bio_endio(bio, -EIO); bio_endio(bio, -EIO);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment