From: Jerome Marchand <jmarchand@redhat.com> Date: Tue, 15 Jul 2008 15:55:49 +0200 Subject: [block] Enhanced Partition Statistics: retain old stats Message-id: 20080715135911.219563310@redhat.com O-Subject: [Patch RHEL5.3 8/9] Enhanced Partition Statistics: maintain old partition statistics Bugzilla: 224322 RH-Acked-by: Anton Arapov <aarapov@redhat.com> bz224322 Maintains old partition statistic fields of hd_struct for external modules which may use them. commit: c3c930d93365c495fbc1df28649da7cd4b97f4af (upstream code just get rid of them) diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 66da02a..e7431f4 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c @@ -3070,10 +3070,6 @@ static inline void blk_partition_remap(struct bio *bio) if (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/include/linux/genhd.h b/include/linux/genhd.h index 5f1478e..c7da74e 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -175,6 +175,29 @@ static inline struct hd_struct *get_part(struct gendisk *gendiskp, return NULL; } +#define disk_stats_index(field) (offsetof(struct disk_stats, field)) +/* + * Maintain old stats field of struct hd_struct to avoid kABI breakage + */ +static inline void part_stat_add_old(struct hd_struct *part, int addnd, + int offset) +{ + switch( offset ) { + case disk_stats_index(ios[0]): + part->ios[0] += addnd; + break; + case disk_stats_index(ios[1]): + part->ios[1] += addnd; + break; + case disk_stats_index(sectors[0]): + part->sectors[0] += addnd; + break; + case disk_stats_index(sectors[1]): + part->sectors[1] += addnd; + break; + } +} + #ifdef CONFIG_SMP #define __disk_stat_add(gendiskp, field, addnd) \ (per_cpu_ptr(gendiskp->dkstats, smp_processor_id())->field += addnd) @@ -202,6 +225,7 @@ static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) { ps = get_partstats(part); \ per_cpu_ptr(ps->dkstats, smp_processor_id())->field += addnd; \ rcu_read_unlock(); \ + part_stat_add_old(part, addnd, disk_stats_index(field)); \ }) #define __all_stat_add(gendiskp, field, addnd, sector) \ @@ -253,11 +277,12 @@ static inline void part_stat_reset(struct hd_struct *part) static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) { memset(&gendiskp->dkstats, value, sizeof (struct disk_stats)); } -#define part_stat_add(part, field, addnd) \ -({ \ - rcu_read_lock(); \ - get_partstats(part)->dkstats.field += addnd; \ - rcu_read_unlock(); \ +#define part_stat_add(part, field, addnd) \ +({ \ + rcu_read_lock(); \ + get_partstats(part)->dkstats.field += addnd; \ + rcu_read_unlock(); \ + part_stat_add_old(part, addnd, disk_stats_index(field));\ }) #define __all_stat_add(gendiskp, field, addnd, sector) \