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>
This commit is contained in:
@ -602,13 +602,10 @@ static void end_io_acct(struct dm_io *io)
|
|||||||
struct mapped_device *md = io->md;
|
struct mapped_device *md = io->md;
|
||||||
struct bio *bio = io->bio;
|
struct bio *bio = io->bio;
|
||||||
unsigned long duration = jiffies - io->start_time;
|
unsigned long duration = jiffies - io->start_time;
|
||||||
int pending, cpu;
|
int pending;
|
||||||
int rw = bio_data_dir(bio);
|
int rw = bio_data_dir(bio);
|
||||||
|
|
||||||
cpu = part_stat_lock();
|
generic_end_io_acct(rw, &dm_disk(md)->part0, io->start_time);
|
||||||
part_round_stats(cpu, &dm_disk(md)->part0);
|
|
||||||
part_stat_add(cpu, &dm_disk(md)->part0, ticks[rw], duration);
|
|
||||||
part_stat_unlock();
|
|
||||||
|
|
||||||
if (unlikely(dm_stats_used(&md->stats)))
|
if (unlikely(dm_stats_used(&md->stats)))
|
||||||
dm_stats_account_io(&md->stats, bio->bi_rw, bio->bi_iter.bi_sector,
|
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)
|
|||||||
{
|
{
|
||||||
int rw = bio_data_dir(bio);
|
int rw = bio_data_dir(bio);
|
||||||
struct mapped_device *md = q->queuedata;
|
struct mapped_device *md = q->queuedata;
|
||||||
int cpu;
|
|
||||||
int srcu_idx;
|
int srcu_idx;
|
||||||
struct dm_table *map;
|
struct dm_table *map;
|
||||||
|
|
||||||
map = dm_get_live_table(md, &srcu_idx);
|
map = dm_get_live_table(md, &srcu_idx);
|
||||||
|
|
||||||
cpu = part_stat_lock();
|
generic_start_io_acct(rw, bio_sectors(bio), &dm_disk(md)->part0);
|
||||||
part_stat_inc(cpu, &dm_disk(md)->part0, ios[rw]);
|
|
||||||
part_stat_add(cpu, &dm_disk(md)->part0, sectors[rw], bio_sectors(bio));
|
|
||||||
part_stat_unlock();
|
|
||||||
|
|
||||||
/* if we're suspended, we have to queue this io for later */
|
/* if we're suspended, we have to queue this io for later */
|
||||||
if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags))) {
|
if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags))) {
|
||||||
|
@ -247,7 +247,6 @@ static void md_make_request(struct request_queue *q, struct bio *bio)
|
|||||||
{
|
{
|
||||||
const int rw = bio_data_dir(bio);
|
const int rw = bio_data_dir(bio);
|
||||||
struct mddev *mddev = q->queuedata;
|
struct mddev *mddev = q->queuedata;
|
||||||
int cpu;
|
|
||||||
unsigned int sectors;
|
unsigned int sectors;
|
||||||
|
|
||||||
if (mddev == NULL || mddev->pers == NULL
|
if (mddev == NULL || mddev->pers == NULL
|
||||||
@ -284,10 +283,7 @@ static void md_make_request(struct request_queue *q, struct bio *bio)
|
|||||||
sectors = bio_sectors(bio);
|
sectors = bio_sectors(bio);
|
||||||
mddev->pers->make_request(mddev, bio);
|
mddev->pers->make_request(mddev, bio);
|
||||||
|
|
||||||
cpu = part_stat_lock();
|
generic_start_io_acct(rw, sectors, &mddev->gendisk->part0);
|
||||||
part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]);
|
|
||||||
part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], sectors);
|
|
||||||
part_stat_unlock();
|
|
||||||
|
|
||||||
if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended)
|
if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended)
|
||||||
wake_up(&mddev->sb_wait);
|
wake_up(&mddev->sb_wait);
|
||||||
|
Reference in New Issue
Block a user