Skip to content

Commit

Permalink
bcache: use bio_{start,end}_io_acct
Browse files Browse the repository at this point in the history
Switch bcache to use the nicer bio accounting helpers, and call the
routines where we also sample the start time to give coherent accounting
results.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed May 27, 2020
1 parent a8e4565 commit 85750ae
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions drivers/md/bcache/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,7 @@ static void backing_request_endio(struct bio *bio)
static void bio_complete(struct search *s)
{
if (s->orig_bio) {
generic_end_io_acct(s->d->disk->queue, bio_op(s->orig_bio),
&s->d->disk->part0, s->start_time);

bio_end_io_acct(s->orig_bio, s->start_time);
trace_bcache_request_end(s->d, s->orig_bio);
s->orig_bio->bi_status = s->iop.status;
bio_endio(s->orig_bio);
Expand Down Expand Up @@ -730,7 +728,7 @@ static inline struct search *search_alloc(struct bio *bio,
s->recoverable = 1;
s->write = op_is_write(bio_op(bio));
s->read_dirty_data = 0;
s->start_time = jiffies;
s->start_time = bio_start_io_acct(bio);

s->iop.c = d->c;
s->iop.bio = NULL;
Expand Down Expand Up @@ -1082,8 +1080,7 @@ static void detached_dev_end_io(struct bio *bio)
bio->bi_end_io = ddip->bi_end_io;
bio->bi_private = ddip->bi_private;

generic_end_io_acct(ddip->d->disk->queue, bio_op(bio),
&ddip->d->disk->part0, ddip->start_time);
bio_end_io_acct(bio, ddip->start_time);

if (bio->bi_status) {
struct cached_dev *dc = container_of(ddip->d,
Expand All @@ -1108,7 +1105,7 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio)
*/
ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO);
ddip->d = d;
ddip->start_time = jiffies;
ddip->start_time = bio_start_io_acct(bio);
ddip->bi_end_io = bio->bi_end_io;
ddip->bi_private = bio->bi_private;
bio->bi_end_io = detached_dev_end_io;
Expand Down Expand Up @@ -1190,11 +1187,6 @@ blk_qc_t cached_dev_make_request(struct request_queue *q, struct bio *bio)
}
}

generic_start_io_acct(q,
bio_op(bio),
bio_sectors(bio),
&d->disk->part0);

bio_set_dev(bio, dc->bdev);
bio->bi_iter.bi_sector += dc->sb.data_offset;

Expand Down Expand Up @@ -1311,8 +1303,6 @@ blk_qc_t flash_dev_make_request(struct request_queue *q, struct bio *bio)
return BLK_QC_T_NONE;
}

generic_start_io_acct(q, bio_op(bio), bio_sectors(bio), &d->disk->part0);

s = search_alloc(bio, d);
cl = &s->cl;
bio = &s->bio.bio;
Expand Down

0 comments on commit 85750ae

Please sign in to comment.