diff options
author | Dan Williams <dan.j.williams@intel.com> | 2015-05-16 12:28:53 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2015-06-26 11:23:38 -0400 |
commit | f0dc089ce217e7b98e0d2077c548ff08129e7911 (patch) | |
tree | c1cd5a098b2ada1f55134fd1c59ad94263cf37ac /drivers/nvdimm/core.c | |
parent | edc870e54696beb9f3835ecb41a4e1c84ee4584d (diff) | |
download | linux-f0dc089ce217e7b98e0d2077c548ff08129e7911.tar.gz linux-f0dc089ce217e7b98e0d2077c548ff08129e7911.tar.bz2 linux-f0dc089ce217e7b98e0d2077c548ff08129e7911.zip |
libnvdimm: enable iostat
This is disabled by default as the overhead is prohibitive, but if the
user takes the action to turn it on we'll oblige.
Reviewed-by: Vishal Verma <vishal.l.verma@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm/core.c')
-rw-r--r-- | drivers/nvdimm/core.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c index 4288169432de..cb62ec6a12d0 100644 --- a/drivers/nvdimm/core.c +++ b/drivers/nvdimm/core.c @@ -214,6 +214,35 @@ ssize_t nd_sector_size_store(struct device *dev, const char *buf, } } +void __nd_iostat_start(struct bio *bio, unsigned long *start) +{ + struct gendisk *disk = bio->bi_bdev->bd_disk; + const int rw = bio_data_dir(bio); + int cpu = part_stat_lock(); + + *start = jiffies; + part_round_stats(cpu, &disk->part0); + part_stat_inc(cpu, &disk->part0, ios[rw]); + part_stat_add(cpu, &disk->part0, sectors[rw], bio_sectors(bio)); + part_inc_in_flight(&disk->part0, rw); + part_stat_unlock(); +} +EXPORT_SYMBOL(__nd_iostat_start); + +void nd_iostat_end(struct bio *bio, unsigned long start) +{ + struct gendisk *disk = bio->bi_bdev->bd_disk; + unsigned long duration = jiffies - start; + const int rw = bio_data_dir(bio); + int cpu = part_stat_lock(); + + part_stat_add(cpu, &disk->part0, ticks[rw], duration); + part_round_stats(cpu, &disk->part0); + part_dec_in_flight(&disk->part0, rw); + part_stat_unlock(); +} +EXPORT_SYMBOL(nd_iostat_end); + static ssize_t commands_show(struct device *dev, struct device_attribute *attr, char *buf) { |