Skip to content

Commit

Permalink
blk-mq: always initialize request->start_time
Browse files Browse the repository at this point in the history
The blk-mq core only initializes this if io stats are enabled, since
blk-mq only reads the field in that case. But drivers could
potentially use it internally, so ensure that we always set it to
the current time when the request is allocated.

Reported-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Jens Axboe committed Jun 9, 2014
1 parent de83953 commit 3ee3237
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
RB_CLEAR_NODE(&rq->rb_node);
rq->rq_disk = NULL;
rq->part = NULL;
rq->start_time = jiffies;
#ifdef CONFIG_BLK_CGROUP
rq->rl = NULL;
set_start_time_ns(rq);
Expand Down Expand Up @@ -1104,10 +1105,8 @@ static void blk_mq_bio_to_request(struct request *rq, struct bio *bio)
{
init_request_from_bio(rq, bio);

if (blk_do_io_stat(rq)) {
rq->start_time = jiffies;
if (blk_do_io_stat(rq))
blk_account_io_start(rq, 1);
}
}

static inline bool blk_mq_merge_queue_io(struct blk_mq_hw_ctx *hctx,
Expand Down

0 comments on commit 3ee3237

Please sign in to comment.