diff options
author | Gu Zheng <guz.fnst@cn.fujitsu.com> | 2014-11-23 22:05:24 -0500 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-11-24 10:05:12 -0500 |
commit | aae4933da9488827d341c31b970b2f62ac45a496 (patch) | |
tree | fcf7dd0cc039322493f4dc79a819e35ac0cfb378 | |
parent | f74cd637b249dd96445e872813072401ef6e5fa6 (diff) |
md/bcache: 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>
Acked-by: Kent Overstreet <kmo@datera.io>
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | drivers/md/bcache/request.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index 62e6e98186b5..ab43faddb447 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c | |||
@@ -601,13 +601,8 @@ static void request_endio(struct bio *bio, int error) | |||
601 | static void bio_complete(struct search *s) | 601 | static void bio_complete(struct search *s) |
602 | { | 602 | { |
603 | if (s->orig_bio) { | 603 | if (s->orig_bio) { |
604 | int cpu, rw = bio_data_dir(s->orig_bio); | 604 | generic_end_io_acct(bio_data_dir(s->orig_bio), |
605 | unsigned long duration = jiffies - s->start_time; | 605 | &s->d->disk->part0, s->start_time); |
606 | |||
607 | cpu = part_stat_lock(); | ||
608 | part_round_stats(cpu, &s->d->disk->part0); | ||
609 | part_stat_add(cpu, &s->d->disk->part0, ticks[rw], duration); | ||
610 | part_stat_unlock(); | ||
611 | 606 | ||
612 | trace_bcache_request_end(s->d, s->orig_bio); | 607 | trace_bcache_request_end(s->d, s->orig_bio); |
613 | bio_endio(s->orig_bio, s->iop.error); | 608 | bio_endio(s->orig_bio, s->iop.error); |
@@ -959,12 +954,9 @@ static void cached_dev_make_request(struct request_queue *q, struct bio *bio) | |||
959 | struct search *s; | 954 | struct search *s; |
960 | struct bcache_device *d = bio->bi_bdev->bd_disk->private_data; | 955 | struct bcache_device *d = bio->bi_bdev->bd_disk->private_data; |
961 | struct cached_dev *dc = container_of(d, struct cached_dev, disk); | 956 | struct cached_dev *dc = container_of(d, struct cached_dev, disk); |
962 | int cpu, rw = bio_data_dir(bio); | 957 | int rw = bio_data_dir(bio); |
963 | 958 | ||
964 | cpu = part_stat_lock(); | 959 | generic_start_io_acct(rw, bio_sectors(bio), &d->disk->part0); |
965 | part_stat_inc(cpu, &d->disk->part0, ios[rw]); | ||
966 | part_stat_add(cpu, &d->disk->part0, sectors[rw], bio_sectors(bio)); | ||
967 | part_stat_unlock(); | ||
968 | 960 | ||
969 | bio->bi_bdev = dc->bdev; | 961 | bio->bi_bdev = dc->bdev; |
970 | bio->bi_iter.bi_sector += dc->sb.data_offset; | 962 | bio->bi_iter.bi_sector += dc->sb.data_offset; |
@@ -1074,12 +1066,9 @@ static void flash_dev_make_request(struct request_queue *q, struct bio *bio) | |||
1074 | struct search *s; | 1066 | struct search *s; |
1075 | struct closure *cl; | 1067 | struct closure *cl; |
1076 | struct bcache_device *d = bio->bi_bdev->bd_disk->private_data; | 1068 | struct bcache_device *d = bio->bi_bdev->bd_disk->private_data; |
1077 | int cpu, rw = bio_data_dir(bio); | 1069 | int rw = bio_data_dir(bio); |
1078 | 1070 | ||
1079 | cpu = part_stat_lock(); | 1071 | generic_start_io_acct(rw, bio_sectors(bio), &d->disk->part0); |
1080 | part_stat_inc(cpu, &d->disk->part0, ios[rw]); | ||
1081 | part_stat_add(cpu, &d->disk->part0, sectors[rw], bio_sectors(bio)); | ||
1082 | part_stat_unlock(); | ||
1083 | 1072 | ||
1084 | s = search_alloc(bio, d); | 1073 | s = search_alloc(bio, d); |
1085 | cl = &s->cl; | 1074 | cl = &s->cl; |