aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-core.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2016-07-19 05:31:50 -0400
committerJens Axboe <axboe@fb.com>2016-07-20 19:38:30 -0400
commit0c4de0f33b0a86a426c0c3958cd40d8c82ede8d2 (patch)
treed3666484b5a0f67400eacef1225826799390aa73 /block/blk-core.c
parentf9596695bee6a88d17118ee9f2f826f96b826644 (diff)
block: ensure bios return from blk_get_request are properly initialized
blk_get_request is used for BLOCK_PC and similar passthrough requests. Currently we always need to call blk_rq_set_block_pc or an open coded version of it to allow appending bios using the request mapping helpers later on, which is a somewhat awkward API. Instead move the initialization part of blk_rq_set_block_pc into blk_get_request, so that we always have a safe to use request. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-core.c')
-rw-r--r--block/blk-core.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index dd325638e102..4d8794925fe9 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1294,10 +1294,15 @@ static struct request *blk_old_get_request(struct request_queue *q, int rw,
1294 1294
1295 spin_lock_irq(q->queue_lock); 1295 spin_lock_irq(q->queue_lock);
1296 rq = get_request(q, rw, 0, NULL, gfp_mask); 1296 rq = get_request(q, rw, 0, NULL, gfp_mask);
1297 if (IS_ERR(rq)) 1297 if (IS_ERR(rq)) {
1298 spin_unlock_irq(q->queue_lock); 1298 spin_unlock_irq(q->queue_lock);
1299 /* q->queue_lock is unlocked at this point */ 1299 return rq;
1300 }
1300 1301
1302 /* q->queue_lock is unlocked at this point */
1303 rq->__data_len = 0;
1304 rq->__sector = (sector_t) -1;
1305 rq->bio = rq->biotail = NULL;
1301 return rq; 1306 return rq;
1302} 1307}
1303 1308
@@ -1377,9 +1382,6 @@ EXPORT_SYMBOL(blk_make_request);
1377void blk_rq_set_block_pc(struct request *rq) 1382void blk_rq_set_block_pc(struct request *rq)
1378{ 1383{
1379 rq->cmd_type = REQ_TYPE_BLOCK_PC; 1384 rq->cmd_type = REQ_TYPE_BLOCK_PC;
1380 rq->__data_len = 0;
1381 rq->__sector = (sector_t) -1;
1382 rq->bio = rq->biotail = NULL;
1383 memset(rq->__cmd, 0, sizeof(rq->__cmd)); 1385 memset(rq->__cmd, 0, sizeof(rq->__cmd));
1384} 1386}
1385EXPORT_SYMBOL(blk_rq_set_block_pc); 1387EXPORT_SYMBOL(blk_rq_set_block_pc);