Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Gu Zheng and committed by
Jens Axboe
18c0b223 24480854

+4 -15
+3 -10
drivers/md/dm.c
··· 602 602 struct mapped_device *md = io->md; 603 603 struct bio *bio = io->bio; 604 604 unsigned long duration = jiffies - io->start_time; 605 - int pending, cpu; 605 + int pending; 606 606 int rw = bio_data_dir(bio); 607 607 608 - cpu = part_stat_lock(); 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(); 608 + generic_end_io_acct(rw, &dm_disk(md)->part0, io->start_time); 612 609 613 610 if (unlikely(dm_stats_used(&md->stats))) 614 611 dm_stats_account_io(&md->stats, bio->bi_rw, bio->bi_iter.bi_sector, ··· 1645 1648 { 1646 1649 int rw = bio_data_dir(bio); 1647 1650 struct mapped_device *md = q->queuedata; 1648 - int cpu; 1649 1651 int srcu_idx; 1650 1652 struct dm_table *map; 1651 1653 1652 1654 map = dm_get_live_table(md, &srcu_idx); 1653 1655 1654 - cpu = part_stat_lock(); 1655 - part_stat_inc(cpu, &dm_disk(md)->part0, ios[rw]); 1656 - part_stat_add(cpu, &dm_disk(md)->part0, sectors[rw], bio_sectors(bio)); 1657 - part_stat_unlock(); 1656 + generic_start_io_acct(rw, bio_sectors(bio), &dm_disk(md)->part0); 1658 1657 1659 1658 /* if we're suspended, we have to queue this io for later */ 1660 1659 if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags))) {
+1 -5
drivers/md/md.c
··· 247 247 { 248 248 const int rw = bio_data_dir(bio); 249 249 struct mddev *mddev = q->queuedata; 250 - int cpu; 251 250 unsigned int sectors; 252 251 253 252 if (mddev == NULL || mddev->pers == NULL ··· 283 284 sectors = bio_sectors(bio); 284 285 mddev->pers->make_request(mddev, bio); 285 286 286 - cpu = part_stat_lock(); 287 - part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]); 288 - part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], sectors); 289 - part_stat_unlock(); 287 + generic_start_io_acct(rw, sectors, &mddev->gendisk->part0); 290 288 291 289 if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended) 292 290 wake_up(&mddev->sb_wait);