summaryrefslogtreecommitdiffstats
path: root/block/blk-mq.c
diff options
context:
space:
mode:
authorJoe Lawrence <joe.lawrence@stratus.com>2014-08-28 10:15:21 -0400
committerJens Axboe <axboe@fb.com>2014-08-28 12:03:46 -0400
commita492f075450f3ba87de36e5ffe92a9d0c7af9723 (patch)
tree61960a71c7fde0eee3d77cda460154d2f7715d2f /block/blk-mq.c
parenteb571eeade2598635f813b3284d02c13a380301e (diff)
block,scsi: fixup blk_get_request dead queue scenarios
The blk_get_request function may fail in low-memory conditions or during device removal (even if __GFP_WAIT is set). To distinguish between these errors, modify the blk_get_request call stack to return the appropriate ERR_PTR. Verify that all callers check the return status and consider IS_ERR instead of a simple NULL pointer check. For consistency, make a similar change to the blk_mq_alloc_request leg of blk_get_request. It may fail if the queue is dead, or the caller was unwilling to wait. Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com> Acked-by: Jiri Kosina <jkosina@suse.cz> [for pktdvd] Acked-by: Boaz Harrosh <bharrosh@panasas.com> [for osd] Reviewed-by: Jeff Moyer <jmoyer@redhat.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-mq.c')
-rw-r--r--block/blk-mq.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 5189cb1e478a..940aa8a34b70 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -218,9 +218,11 @@ struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp,
218 struct blk_mq_hw_ctx *hctx; 218 struct blk_mq_hw_ctx *hctx;
219 struct request *rq; 219 struct request *rq;
220 struct blk_mq_alloc_data alloc_data; 220 struct blk_mq_alloc_data alloc_data;
221 int ret;
221 222
222 if (blk_mq_queue_enter(q)) 223 ret = blk_mq_queue_enter(q);
223 return NULL; 224 if (ret)
225 return ERR_PTR(ret);
224 226
225 ctx = blk_mq_get_ctx(q); 227 ctx = blk_mq_get_ctx(q);
226 hctx = q->mq_ops->map_queue(q, ctx->cpu); 228 hctx = q->mq_ops->map_queue(q, ctx->cpu);
@@ -240,6 +242,8 @@ struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp,
240 ctx = alloc_data.ctx; 242 ctx = alloc_data.ctx;
241 } 243 }
242 blk_mq_put_ctx(ctx); 244 blk_mq_put_ctx(ctx);
245 if (!rq)
246 return ERR_PTR(-EWOULDBLOCK);
243 return rq; 247 return rq;
244} 248}
245EXPORT_SYMBOL(blk_mq_alloc_request); 249EXPORT_SYMBOL(blk_mq_alloc_request);