If ADDITIONAL_DISKSTAT is enabled carelessly, then it is bad to people who don't want the additional overhead. Now add check before call blk_additional_{latency,sector}, which guarntee only those who really know about the attribute can account the additional data. Signed-off-by: Guoqing Jiang <guoqing.jiang@xxxxxxxxxxxxxxx> --- block/blk-core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 719595578bc8..c38287d34825 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1326,7 +1326,8 @@ static void blk_account_io_completion(struct request *req, unsigned int bytes) const int sgrp = op_stat_group(req_op(req)); part_stat_lock(); - blk_additional_sector(req->part, sgrp, bytes >> SECTOR_SHIFT); + if (blk_queue_io_extra_stat(req->q)) + blk_additional_sector(req->part, sgrp, bytes >> SECTOR_SHIFT); part_stat_add(req->part, sectors[sgrp], bytes >> 9); part_stat_unlock(); } @@ -1345,7 +1346,8 @@ void blk_account_io_done(struct request *req, u64 now) part_stat_lock(); update_io_ticks(req->part, jiffies, true); - blk_additional_latency(req->part, sgrp, req, 0); + if (blk_queue_io_extra_stat(req->q)) + blk_additional_latency(req->part, sgrp, req, 0); part_stat_inc(req->part, ios[sgrp]); part_stat_add(req->part, nsecs[sgrp], now - req->start_time_ns); part_stat_unlock(); @@ -1374,7 +1376,8 @@ static unsigned long __part_start_io_acct(struct block_device *part, update_io_ticks(part, now, false); part_stat_inc(part, ios[sgrp]); part_stat_add(part, sectors[sgrp], sectors); - blk_additional_sector(part, sgrp, sectors); + if (blk_queue_io_extra_stat(part->bd_disk->queue)) + blk_additional_sector(part, sgrp, sectors); part_stat_local_inc(part, in_flight[op_is_write(op)]); part_stat_unlock(); @@ -1406,7 +1409,8 @@ static void __part_end_io_acct(struct block_device *part, unsigned int op, part_stat_lock(); update_io_ticks(part, now, true); - blk_additional_latency(part, sgrp, NULL, start_time); + if (blk_queue_io_extra_stat(part->bd_disk->queue)) + blk_additional_latency(part, sgrp, NULL, start_time); part_stat_add(part, nsecs[sgrp], jiffies_to_nsecs(duration)); part_stat_local_dec(part, in_flight[op_is_write(op)]); part_stat_unlock(); -- 2.17.1