Enhanced partition statistics: update partition statitics

Updates the enhanced partition statistics in generic block layer
besides the disk statistics.

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

authored by Jerome Marchand and committed by Jens Axboe 6f2576af ea5c48ab

+44 -4
+30 -4
block/blk-core.c
··· 60 60 return; 61 61 62 62 if (!new_io) { 63 - __disk_stat_inc(rq->rq_disk, merges[rw]); 63 + __all_stat_inc(rq->rq_disk, merges[rw], rq->sector); 64 64 } else { 65 + struct hd_struct *part = get_part(rq->rq_disk, rq->sector); 65 66 disk_round_stats(rq->rq_disk); 66 67 rq->rq_disk->in_flight++; 68 + if (part) { 69 + part_round_stats(part); 70 + part->in_flight++; 71 + } 67 72 } 68 73 } 69 74 ··· 1002 997 } 1003 998 EXPORT_SYMBOL_GPL(disk_round_stats); 1004 999 1000 + void part_round_stats(struct hd_struct *part) 1001 + { 1002 + unsigned long now = jiffies; 1003 + 1004 + if (now == part->stamp) 1005 + return; 1006 + 1007 + if (part->in_flight) { 1008 + __part_stat_add(part, time_in_queue, 1009 + part->in_flight * (now - part->stamp)); 1010 + __part_stat_add(part, io_ticks, (now - part->stamp)); 1011 + } 1012 + part->stamp = now; 1013 + } 1014 + 1005 1015 /* 1006 1016 * queue lock must be held 1007 1017 */ ··· 1550 1530 if (blk_fs_request(req) && req->rq_disk) { 1551 1531 const int rw = rq_data_dir(req); 1552 1532 1553 - disk_stat_add(req->rq_disk, sectors[rw], nr_bytes >> 9); 1533 + all_stat_add(req->rq_disk, sectors[rw], 1534 + nr_bytes >> 9, req->sector); 1554 1535 } 1555 1536 1556 1537 total_bytes = bio_nbytes = 0; ··· 1736 1715 if (disk && blk_fs_request(req) && req != &req->q->bar_rq) { 1737 1716 unsigned long duration = jiffies - req->start_time; 1738 1717 const int rw = rq_data_dir(req); 1718 + struct hd_struct *part = get_part(disk, req->sector); 1739 1719 1740 - __disk_stat_inc(disk, ios[rw]); 1741 - __disk_stat_add(disk, ticks[rw], duration); 1720 + __all_stat_inc(disk, ios[rw], req->sector); 1721 + __all_stat_add(disk, ticks[rw], duration, req->sector); 1742 1722 disk_round_stats(disk); 1743 1723 disk->in_flight--; 1724 + if (part) { 1725 + part_round_stats(part); 1726 + part->in_flight--; 1727 + } 1744 1728 } 1745 1729 1746 1730 if (req->end_io)
+6
block/blk-merge.c
··· 454 454 elv_merge_requests(q, req, next); 455 455 456 456 if (req->rq_disk) { 457 + struct hd_struct *part 458 + = get_part(req->rq_disk, req->sector); 457 459 disk_round_stats(req->rq_disk); 458 460 req->rq_disk->in_flight--; 461 + if (part) { 462 + part_round_stats(part); 463 + part->in_flight--; 464 + } 459 465 } 460 466 461 467 req->ioprio = ioprio_best(req->ioprio, next->ioprio);
+7
fs/partitions/check.c
··· 18 18 #include <linux/fs.h> 19 19 #include <linux/kmod.h> 20 20 #include <linux/ctype.h> 21 + #include <linux/genhd.h> 21 22 22 23 #include "check.h" 23 24 ··· 274 273 static void part_release(struct device *dev) 275 274 { 276 275 struct hd_struct *p = dev_to_part(dev); 276 + free_part_stats(p); 277 277 kfree(p); 278 278 } 279 279 ··· 316 314 p->nr_sects = 0; 317 315 p->ios[0] = p->ios[1] = 0; 318 316 p->sectors[0] = p->sectors[1] = 0; 317 + part_stat_set_all(p, 0); 319 318 kobject_put(p->holder_dir); 320 319 device_del(&p->dev); 321 320 put_device(&p->dev); ··· 339 336 if (!p) 340 337 return; 341 338 339 + if (!init_part_stats(p)) { 340 + kfree(p); 341 + return; 342 + } 342 343 p->start_sect = start; 343 344 p->nr_sects = len; 344 345 p->partno = part;
+1
include/linux/genhd.h
··· 365 365 366 366 /* drivers/block/ll_rw_blk.c */ 367 367 extern void disk_round_stats(struct gendisk *disk); 368 + extern void part_round_stats(struct hd_struct *part); 368 369 369 370 /* drivers/block/genhd.c */ 370 371 extern int get_blkdev_list(char *, int);