Commit aae4933d authored by Gu Zheng's avatar Gu Zheng Committed by Jens Axboe

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: default avatarGu Zheng <guz.fnst@cn.fujitsu.com>
Acked-by: default avatarKent Overstreet <kmo@datera.io>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent f74cd637
...@@ -601,13 +601,8 @@ static void request_endio(struct bio *bio, int error) ...@@ -601,13 +601,8 @@ static void request_endio(struct bio *bio, int error)
static void bio_complete(struct search *s) static void bio_complete(struct search *s)
{ {
if (s->orig_bio) { if (s->orig_bio) {
int cpu, rw = bio_data_dir(s->orig_bio); generic_end_io_acct(bio_data_dir(s->orig_bio),
unsigned long duration = jiffies - s->start_time; &s->d->disk->part0, s->start_time);
cpu = part_stat_lock();
part_round_stats(cpu, &s->d->disk->part0);
part_stat_add(cpu, &s->d->disk->part0, ticks[rw], duration);
part_stat_unlock();
trace_bcache_request_end(s->d, s->orig_bio); trace_bcache_request_end(s->d, s->orig_bio);
bio_endio(s->orig_bio, s->iop.error); 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,12 +954,9 @@ static void cached_dev_make_request(struct request_queue *q, struct bio *bio)
struct search *s; struct search *s;
struct bcache_device *d = bio->bi_bdev->bd_disk->private_data; struct bcache_device *d = bio->bi_bdev->bd_disk->private_data;
struct cached_dev *dc = container_of(d, struct cached_dev, disk); struct cached_dev *dc = container_of(d, struct cached_dev, disk);
int cpu, rw = bio_data_dir(bio); int rw = bio_data_dir(bio);
cpu = part_stat_lock(); generic_start_io_acct(rw, bio_sectors(bio), &d->disk->part0);
part_stat_inc(cpu, &d->disk->part0, ios[rw]);
part_stat_add(cpu, &d->disk->part0, sectors[rw], bio_sectors(bio));
part_stat_unlock();
bio->bi_bdev = dc->bdev; bio->bi_bdev = dc->bdev;
bio->bi_iter.bi_sector += dc->sb.data_offset; 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,12 +1066,9 @@ static void flash_dev_make_request(struct request_queue *q, struct bio *bio)
struct search *s; struct search *s;
struct closure *cl; struct closure *cl;
struct bcache_device *d = bio->bi_bdev->bd_disk->private_data; struct bcache_device *d = bio->bi_bdev->bd_disk->private_data;
int cpu, rw = bio_data_dir(bio); int rw = bio_data_dir(bio);
cpu = part_stat_lock(); generic_start_io_acct(rw, bio_sectors(bio), &d->disk->part0);
part_stat_inc(cpu, &d->disk->part0, ios[rw]);
part_stat_add(cpu, &d->disk->part0, sectors[rw], bio_sectors(bio));
part_stat_unlock();
s = search_alloc(bio, d); s = search_alloc(bio, d);
cl = &s->cl; cl = &s->cl;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment