aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorGu Zheng <guz.fnst@cn.fujitsu.com>2014-11-23 22:05:26 -0500
committerJens Axboe <axboe@fb.com>2014-11-24 10:05:16 -0500
commit18c0b223cf9901727ef3b02da6711ac930b4e5d4 (patch)
tree4f1b835c2a1c97dbdfcadc69147e1178d60e6ca8 /drivers/md
parent244808543e6e9b46ea1135589877f4d4bd2925c5 (diff)
md: use generic io stats accounting functions to simplify io stat accounting
Use generic io stats accounting help functions (generic_{start,end}_io_acct) to simplify io stat accounting. Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm.c13
-rw-r--r--drivers/md/md.c6
2 files changed, 4 insertions, 15 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 58f3927fd7cc..b1cdf69b11e7 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -602,13 +602,10 @@ static void end_io_acct(struct dm_io *io)
602 struct mapped_device *md = io->md; 602 struct mapped_device *md = io->md;
603 struct bio *bio = io->bio; 603 struct bio *bio = io->bio;
604 unsigned long duration = jiffies - io->start_time; 604 unsigned long duration = jiffies - io->start_time;
605 int pending, cpu; 605 int pending;
606 int rw = bio_data_dir(bio); 606 int rw = bio_data_dir(bio);
607 607
608 cpu = part_stat_lock(); 608 generic_end_io_acct(rw, &dm_disk(md)->part0, io->start_time);
609 part_round_stats(cpu, &dm_disk(md)->part0);
610 part_stat_add(cpu, &dm_disk(md)->part0, ticks[rw], duration);
611 part_stat_unlock();
612 609
613 if (unlikely(dm_stats_used(&md->stats))) 610 if (unlikely(dm_stats_used(&md->stats)))
614 dm_stats_account_io(&md->stats, bio->bi_rw, bio->bi_iter.bi_sector, 611 dm_stats_account_io(&md->stats, bio->bi_rw, bio->bi_iter.bi_sector,
@@ -1648,16 +1645,12 @@ static void _dm_request(struct request_queue *q, struct bio *bio)
1648{ 1645{
1649 int rw = bio_data_dir(bio); 1646 int rw = bio_data_dir(bio);
1650 struct mapped_device *md = q->queuedata; 1647 struct mapped_device *md = q->queuedata;
1651 int cpu;
1652 int srcu_idx; 1648 int srcu_idx;
1653 struct dm_table *map; 1649 struct dm_table *map;
1654 1650
1655 map = dm_get_live_table(md, &srcu_idx); 1651 map = dm_get_live_table(md, &srcu_idx);
1656 1652
1657 cpu = part_stat_lock(); 1653 generic_start_io_acct(rw, bio_sectors(bio), &dm_disk(md)->part0);
1658 part_stat_inc(cpu, &dm_disk(md)->part0, ios[rw]);
1659 part_stat_add(cpu, &dm_disk(md)->part0, sectors[rw], bio_sectors(bio));
1660 part_stat_unlock();
1661 1654
1662 /* if we're suspended, we have to queue this io for later */ 1655 /* if we're suspended, we have to queue this io for later */
1663 if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags))) { 1656 if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags))) {
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 9233c71138f1..056ccd28c037 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -247,7 +247,6 @@ static void md_make_request(struct request_queue *q, struct bio *bio)
247{ 247{
248 const int rw = bio_data_dir(bio); 248 const int rw = bio_data_dir(bio);
249 struct mddev *mddev = q->queuedata; 249 struct mddev *mddev = q->queuedata;
250 int cpu;
251 unsigned int sectors; 250 unsigned int sectors;
252 251
253 if (mddev == NULL || mddev->pers == NULL 252 if (mddev == NULL || mddev->pers == NULL
@@ -284,10 +283,7 @@ static void md_make_request(struct request_queue *q, struct bio *bio)
284 sectors = bio_sectors(bio); 283 sectors = bio_sectors(bio);
285 mddev->pers->make_request(mddev, bio); 284 mddev->pers->make_request(mddev, bio);
286 285
287 cpu = part_stat_lock(); 286 generic_start_io_acct(rw, sectors, &mddev->gendisk->part0);
288 part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]);
289 part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], sectors);
290 part_stat_unlock();
291 287
292 if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended) 288 if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended)
293 wake_up(&mddev->sb_wait); 289 wake_up(&mddev->sb_wait);