hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/release-management/issues/IB4E8P CVE: NA
--------------------------------
The time will be reused for completing bio, to avoid getting ns time again.
Signed-off-by: Yu Kuai yukuai3@huawei.com --- block/blk-mq.c | 10 ++++++++-- include/linux/blk-mq.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c index 56d6d59f9735..1159a06e2543 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -379,6 +379,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
rq->part = NULL; rq->io_start_time_ns = 0; + rq->io_end_time_ns = 0; rq->stats_sectors = 0; rq->nr_phys_segments = 0; #if defined(CONFIG_BLK_DEV_INTEGRITY) @@ -1045,8 +1046,13 @@ static inline void __blk_mq_end_request_acct(struct request *rq, u64 now)
inline void __blk_mq_end_request(struct request *rq, blk_status_t error) { - if (blk_mq_need_time_stamp(rq)) - __blk_mq_end_request_acct(rq, blk_time_get_ns()); + if (blk_mq_need_time_stamp(rq)) { + u64 now = rq->io_end_time_ns; + + if (!now) + now = blk_time_get_ns(); + __blk_mq_end_request_acct(rq, now); + }
blk_mq_finish_request(rq);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index b301ebe67eb4..da56055731d6 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -200,7 +200,7 @@ struct request { #else KABI_RESERVE(2) #endif - KABI_RESERVE(3) + KABI_USE(3, u64 io_end_time_ns) KABI_RESERVE(4) KABI_RESERVE(5) KABI_RESERVE(6)