Skip to content

Commit 18c0b22

Browse files
Gu Zhengaxboe
authored andcommitted
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 <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 2448085 commit 18c0b22

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

drivers/md/dm.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -602,13 +602,10 @@ static void end_io_acct(struct dm_io *io)
602602
struct mapped_device *md = io->md;
603603
struct bio *bio = io->bio;
604604
unsigned long duration = jiffies - io->start_time;
605-
int pending, cpu;
605+
int pending;
606606
int rw = bio_data_dir(bio);
607607

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);
612609

613610
if (unlikely(dm_stats_used(&md->stats)))
614611
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)
16481645
{
16491646
int rw = bio_data_dir(bio);
16501647
struct mapped_device *md = q->queuedata;
1651-
int cpu;
16521648
int srcu_idx;
16531649
struct dm_table *map;
16541650

16551651
map = dm_get_live_table(md, &srcu_idx);
16561652

1657-
cpu = part_stat_lock();
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();
1653+
generic_start_io_acct(rw, bio_sectors(bio), &dm_disk(md)->part0);
16611654

16621655
/* if we're suspended, we have to queue this io for later */
16631656
if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags))) {

drivers/md/md.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ static void md_make_request(struct request_queue *q, struct bio *bio)
247247
{
248248
const int rw = bio_data_dir(bio);
249249
struct mddev *mddev = q->queuedata;
250-
int cpu;
251250
unsigned int sectors;
252251

253252
if (mddev == NULL || mddev->pers == NULL
@@ -284,10 +283,7 @@ static void md_make_request(struct request_queue *q, struct bio *bio)
284283
sectors = bio_sectors(bio);
285284
mddev->pers->make_request(mddev, bio);
286285

287-
cpu = part_stat_lock();
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();
286+
generic_start_io_acct(rw, sectors, &mddev->gendisk->part0);
291287

292288
if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended)
293289
wake_up(&mddev->sb_wait);

0 commit comments

Comments
 (0)