[PATCH V2 4/4] block: call blk_additional_{latency,sector} only when io_extra_stats is true

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now add check before call blk_additional_{latency,sector}, which guarntee
only those who really know about the attribute can account the additional
data.

Reviewed-by: Jack Wang <jinpu.wang@xxxxxxxxxxxxxxx>
Signed-off-by: Guoqing Jiang <guoqing.jiang@xxxxxxxxxxxxxxx>
---
 block/blk-core.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index bdd5fe6f92a0..a44684033382 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1265,10 +1265,14 @@ static void update_io_ticks(struct block_device *part, unsigned long now,
 }
 
 static void blk_additional_latency(struct block_device *part, const int sgrp,
+				   struct request_queue *q,
 				   unsigned long duration)
 {
 	unsigned int idx;
 
+	if (!blk_queue_io_extra_stat(q))
+		return;
+
 	duration /= NSEC_PER_MSEC;
 	duration /= HZ_TO_MSEC_NUM;
 	if (likely(duration > 0)) {
@@ -1281,10 +1285,13 @@ static void blk_additional_latency(struct block_device *part, const int sgrp,
 }
 
 static void blk_additional_sector(struct block_device *part, const int sgrp,
-				  unsigned int sectors)
+				  struct request_queue *q, unsigned int sectors)
 {
 	unsigned int idx;
 
+	if (!blk_queue_io_extra_stat(q))
+		return;
+
 	if (sectors == 1)
 		idx = 0;
 	else
@@ -1300,7 +1307,7 @@ 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);
+		blk_additional_sector(req->part, sgrp, req->q, bytes >> SECTOR_SHIFT);
 		part_stat_add(req->part, sectors[sgrp], bytes >> 9);
 		part_stat_unlock();
 	}
@@ -1319,7 +1326,7 @@ 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,
+		blk_additional_latency(req->part, sgrp, req->q,
 				       now - req->start_time_ns);
 		part_stat_inc(req->part, ios[sgrp]);
 		part_stat_add(req->part, nsecs[sgrp], now - req->start_time_ns);
@@ -1353,7 +1360,7 @@ 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);
+	blk_additional_sector(part, sgrp, part->bd_disk->queue, sectors);
 	part_stat_local_inc(part, in_flight[op_is_write(op)]);
 	part_stat_unlock();
 
@@ -1388,7 +1395,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, jiffies_to_nsecs(duration));
+	blk_additional_latency(part, sgrp, part->bd_disk->queue,
+			       jiffies_to_nsecs(duration));
 	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




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux