[Devel] [PATCH rh7] ploop: fix gendisk disk_stats

Maxim Patlasov mpatlasov at virtuozzo.com
Mon Jun 13 14:24:00 PDT 2016


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 db55be3..50c3ea9 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -793,6 +793,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);
 
@@ -804,8 +805,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