[Devel] [PATCH RHEL7 COMMIT] ploop: fix gendisk disk_stats to be seen on partition

Konstantin Khorenko khorenko at virtuozzo.com
Wed Jun 15 01:38:54 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.18.2.vz7.14.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.18.2.vz7.14.14
------>
commit fc4dd8e6d4df14e5e09b6dacac74fe903d95c929
Author: Maxim Patlasov <mpatlasov at virtuozzo.com>
Date:   Wed Jun 15 12:38:54 2016 +0400

    ploop: fix gendisk disk_stats to be seen on partition
    
    Before this patch, an I/O on top of /dev/ploopNp1 was always accounted
    on main partition (/sys/block/ploopN/stat). The counters for p1 remained
    zero. The patch fixes the problem by calculating partition properly.
    
    https://jira.sw.ru/browse/PSBM-48266
    
    Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
 drivers/block/ploop/dev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index f87209d..01a5189 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -800,6 +800,7 @@ static void ploop_make_request(struct request_queue *q, struct bio *bio)
 	struct bio * nbio;
 	struct ploop_device * plo = q->queuedata;
 	unsigned long rw = bio_data_dir(bio);
+	struct hd_struct *part;
 	int cpu;
 	LIST_HEAD(drop_list);
 
@@ -811,8 +812,9 @@ static void ploop_make_request(struct request_queue *q, struct bio *bio)
 	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 = disk_map_sector_rcu(plo->disk, bio->bi_sector);
+	part_stat_inc(cpu, part, ios[rw]);
+	part_stat_add(cpu, part, sectors[rw], bio_sectors(bio));
 	part_stat_unlock();
 
 	if (unlikely(bio->bi_size == 0)) {


More information about the Devel mailing list