aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-core.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2014-06-06 09:57:37 -0400
committerJens Axboe <axboe@fb.com>2014-06-06 09:57:37 -0400
commitf27b087b81b70513b8c61ec20596c868f7b93474 (patch)
tree5dbdf3552f2289c28e65b0fee4490803bff87d42 /block/blk-core.c
parent762380ad9322951cea4ce9d24864265f9c66a916 (diff)
block: add blk_rq_set_block_pc()
With the optimizations around not clearing the full request at alloc time, we are leaving some of the needed init for REQ_TYPE_BLOCK_PC up to the user allocating the request. Add a blk_rq_set_block_pc() that sets the command type to REQ_TYPE_BLOCK_PC, and properly initializes the members associated with this type of request. Update callers to use this function instead of manipulating rq->cmd_type directly. Includes fixes from Christoph Hellwig <hch@lst.de> for my half-assed attempt. Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-core.c')
-rw-r--r--block/blk-core.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 40d654861c33..9aca8c71e70b 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1218,6 +1218,8 @@ struct request *blk_make_request(struct request_queue *q, struct bio *bio,
1218 if (unlikely(!rq)) 1218 if (unlikely(!rq))
1219 return ERR_PTR(-ENOMEM); 1219 return ERR_PTR(-ENOMEM);
1220 1220
1221 blk_rq_set_block_pc(rq);
1222
1221 for_each_bio(bio) { 1223 for_each_bio(bio) {
1222 struct bio *bounce_bio = bio; 1224 struct bio *bounce_bio = bio;
1223 int ret; 1225 int ret;
@@ -1235,6 +1237,22 @@ struct request *blk_make_request(struct request_queue *q, struct bio *bio,
1235EXPORT_SYMBOL(blk_make_request); 1237EXPORT_SYMBOL(blk_make_request);
1236 1238
1237/** 1239/**
1240 * blk_rq_set_block_pc - initialize a requeest to type BLOCK_PC
1241 * @rq: request to be initialized
1242 *
1243 */
1244void blk_rq_set_block_pc(struct request *rq)
1245{
1246 rq->cmd_type = REQ_TYPE_BLOCK_PC;
1247 rq->__data_len = 0;
1248 rq->__sector = (sector_t) -1;
1249 rq->bio = rq->biotail = NULL;
1250 memset(rq->__cmd, 0, sizeof(rq->__cmd));
1251 rq->cmd = rq->__cmd;
1252}
1253EXPORT_SYMBOL(blk_rq_set_block_pc);
1254
1255/**
1238 * blk_requeue_request - put a request back on queue 1256 * blk_requeue_request - put a request back on queue
1239 * @q: request queue where request should be inserted 1257 * @q: request queue where request should be inserted
1240 * @rq: request to be inserted 1258 * @rq: request to be inserted