Skip to content

Commit e3c5a78

Browse files
John Garryaxboe
authored andcommitted
blk-mq: Properly init requests from blk_mq_alloc_request_hctx()
Function blk_mq_alloc_request_hctx() is missing zeroing/init of rq->bio, biotail, __sector, and __data_len members, which blk_mq_alloc_request() has, so duplicate what we do in blk_mq_alloc_request(). Fixes: 1f5bd33 ("blk-mq: add blk_mq_alloc_request_hctx") Signed-off-by: John Garry <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent dea3132 commit e3c5a78

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

block/blk-mq.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
611611
.nr_tags = 1,
612612
};
613613
u64 alloc_time_ns = 0;
614+
struct request *rq;
614615
unsigned int cpu;
615616
unsigned int tag;
616617
int ret;
@@ -660,8 +661,12 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
660661
tag = blk_mq_get_tag(&data);
661662
if (tag == BLK_MQ_NO_TAG)
662663
goto out_queue_exit;
663-
return blk_mq_rq_ctx_init(&data, blk_mq_tags_from_data(&data), tag,
664+
rq = blk_mq_rq_ctx_init(&data, blk_mq_tags_from_data(&data), tag,
664665
alloc_time_ns);
666+
rq->__data_len = 0;
667+
rq->__sector = (sector_t) -1;
668+
rq->bio = rq->biotail = NULL;
669+
return rq;
665670

666671
out_queue_exit:
667672
blk_queue_exit(q);

0 commit comments

Comments
 (0)