blk-mq: fix initializing request's start time
authorMing Lei <tom.leiming@gmail.com>
Fri, 3 Jan 2014 17:00:08 +0000 (10:00 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 3 Jan 2014 17:00:08 +0000 (10:00 -0700)
blk_rq_init() is called in req's complete handler to initialize
the request, so the members of start_time and start_time_ns might
become inaccurate when it is allocated in future.

The patch initializes the two members in blk_mq_rq_ctx_init() to
fix the problem.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.c

index 6914f9bd470ac2bf48de797f1ddd53ad27dd6604..473ce403906055f56d81b99641cf9181d99ba71e 100644 (file)
@@ -190,6 +190,8 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
 
        rq->mq_ctx = ctx;
        rq->cmd_flags = rw_flags;
+       rq->start_time = jiffies;
+       set_start_time_ns(rq);
        ctx->rq_dispatched[rw_is_sync(rw_flags)]++;
 }