From 6f2576af5ba5913538fda7dfb7c6a17771025477 Mon Sep 17 00:00:00 2001 From: Jerome Marchand Date: Fri, 8 Feb 2008 11:04:35 +0100 Subject: Enhanced partition statistics: update partition statitics Updates the enhanced partition statistics in generic block layer besides the disk statistics. Signed-off-by: Jerome Marchand Signed-off-by: Jens Axboe --- fs/partitions/check.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'fs') diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 9a64045ff84..f2ec7f1b0ec 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "check.h" @@ -273,6 +274,7 @@ static struct attribute_group *part_attr_groups[] = { static void part_release(struct device *dev) { struct hd_struct *p = dev_to_part(dev); + free_part_stats(p); kfree(p); } @@ -314,6 +316,7 @@ void delete_partition(struct gendisk *disk, int part) p->nr_sects = 0; p->ios[0] = p->ios[1] = 0; p->sectors[0] = p->sectors[1] = 0; + part_stat_set_all(p, 0); kobject_put(p->holder_dir); device_del(&p->dev); put_device(&p->dev); @@ -336,6 +339,10 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, if (!p) return; + if (!init_part_stats(p)) { + kfree(p); + return; + } p->start_sect = start; p->nr_sects = len; p->partno = part; -- cgit v1.2.3-70-g09d2 From 34e8beac92c27d292938065f8375842d2840767c Mon Sep 17 00:00:00 2001 From: Jerome Marchand Date: Fri, 8 Feb 2008 11:04:55 +0100 Subject: Enhanced partition statistics: sysfs Reports enhanced partition statistics in sysfs. Signed-off-by: Jerome Marchand --- fs/partitions/check.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'fs') diff --git a/fs/partitions/check.c b/fs/partitions/check.c index f2ec7f1b0ec..950bdb4b8f5 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -216,9 +216,25 @@ static ssize_t part_stat_show(struct device *dev, { struct hd_struct *p = dev_to_part(dev); - return sprintf(buf, "%8u %8llu %8u %8llu\n", - p->ios[0], (unsigned long long)p->sectors[0], - p->ios[1], (unsigned long long)p->sectors[1]); + preempt_disable(); + part_round_stats(p); + preempt_enable(); + return sprintf(buf, + "%8lu %8lu %8llu %8u " + "%8lu %8lu %8llu %8u " + "%8u %8u %8u" + "\n", + part_stat_read(p, ios[READ]), + part_stat_read(p, merges[READ]), + (unsigned long long)part_stat_read(p, sectors[READ]), + jiffies_to_msecs(part_stat_read(p, ticks[READ])), + part_stat_read(p, ios[WRITE]), + part_stat_read(p, merges[WRITE]), + (unsigned long long)part_stat_read(p, sectors[WRITE]), + jiffies_to_msecs(part_stat_read(p, ticks[WRITE])), + p->in_flight, + jiffies_to_msecs(part_stat_read(p, io_ticks)), + jiffies_to_msecs(part_stat_read(p, time_in_queue))); } #ifdef CONFIG_FAIL_MAKE_REQUEST -- cgit v1.2.3-70-g09d2 From c3c930d93365c495fbc1df28649da7cd4b97f4af Mon Sep 17 00:00:00 2001 From: Jerome Marchand Date: Fri, 8 Feb 2008 12:06:21 +0100 Subject: Enhanced partition statistics: remove old partition statistics Removes the now unused old partition statistic code. Signed-off-by: Jerome Marchand Signed-off-by: Jens Axboe --- block/blk-core.c | 4 ---- fs/partitions/check.c | 2 -- include/linux/genhd.h | 1 - 3 files changed, 7 deletions(-) (limited to 'fs') diff --git a/block/blk-core.c b/block/blk-core.c index 2358fc5de5a..e9754dc98ec 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1219,10 +1219,6 @@ static inline void blk_partition_remap(struct bio *bio) if (bio_sectors(bio) && bdev != bdev->bd_contains) { struct hd_struct *p = bdev->bd_part; - const int rw = bio_data_dir(bio); - - p->sectors[rw] += bio_sectors(bio); - p->ios[rw]++; bio->bi_sector += p->start_sect; bio->bi_bdev = bdev->bd_contains; diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 950bdb4b8f5..03f808c5b79 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -330,8 +330,6 @@ void delete_partition(struct gendisk *disk, int part) disk->part[part-1] = NULL; p->start_sect = 0; p->nr_sects = 0; - p->ios[0] = p->ios[1] = 0; - p->sectors[0] = p->sectors[1] = 0; part_stat_set_all(p, 0); kobject_put(p->holder_dir); device_del(&p->dev); diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 4cf25a5f415..09a3b18918c 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -105,7 +105,6 @@ struct hd_struct { sector_t nr_sects; struct device dev; struct kobject *holder_dir; - unsigned ios[2], sectors[2]; /* READs and WRITEs */ int policy, partno; #ifdef CONFIG_FAIL_MAKE_REQUEST int make_it_fail; -- cgit v1.2.3-70-g09d2