[Devel] [PATCH RHEL7 COMMIT] ploop: update gendisk disk_stats

Konstantin Khorenko khorenko at virtuozzo.com
Wed Mar 16 06:14:42 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.10.1.vz7.12.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.10.1.vz7.12.2
------>
commit 67c3f482046485d6df3771d52c81476643d7213f
Author: Maxim Patlasov <mpatlasov at virtuozzo.com>
Date:   Wed Mar 16 17:14:42 2016 +0400

    ploop: update gendisk disk_stats
    
    ploop must update I/O statistics counters to make /sys/block/ploopN/stat
    looks reasonable. The patch do it similarly to dm/dm.c.
    
    https://jira.sw.ru/browse/PSBM-41247
    
    Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
    Acked-by: Dmitry Monakhov <dmonakhov at virtuozzo.com>
---
 drivers/block/ploop/dev.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index bad539a..feb56c7 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -791,7 +791,8 @@ static void ploop_make_request(struct request_queue *q, struct bio *bio)
 {
 	struct bio * nbio;
 	struct ploop_device * plo = q->queuedata;
-	unsigned long rw;
+	unsigned long rw = bio_data_dir(bio);
+	int cpu;
 	LIST_HEAD(drop_list);
 
 	trace_make_request(bio);
@@ -801,6 +802,11 @@ static void ploop_make_request(struct request_queue *q, struct bio *bio)
 	BUG_ON(bio->bi_idx);
 	BUG_ON(bio->bi_size & 511);
 
+	cpu = part_stat_lock();
+	part_stat_inc(cpu, &plo->disk->part0, ios[rw]);
+	part_stat_add(cpu, &plo->disk->part0, sectors[rw], bio_sectors(bio));
+	part_stat_unlock();
+
 	if (unlikely(bio->bi_size == 0)) {
 		/* Is it possible? This makes sense if the request is
 		 * marked as FLUSH, otherwise just warn and complete. */


More information about the Devel mailing list