Skip to content

Commit

Permalink
blkcg: consolidate bio_issue_init to be a part of core
Browse files Browse the repository at this point in the history
bio_issue_init among other things initializes the timestamp for an IO.
Rather than have this logic handled by policies, this consolidates it to
be on the init paths (normal, clone, bounce clone).

Signed-off-by: Dennis Zhou <dennisszhou@gmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Liu Bo <bo.liu@linux.alibaba.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
dennisszhou authored and axboe committed Sep 22, 2018
1 parent a7b39b4 commit 5bf9a1f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions block/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,8 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
bio->bi_io_vec = bio_src->bi_io_vec;

bio_clone_blkcg_association(bio, bio_src);

blkcg_bio_issue_init(bio);
}
EXPORT_SYMBOL(__bio_clone_fast);

Expand Down
2 changes: 0 additions & 2 deletions block/blk-iolatency.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,6 @@ static void blkcg_iolatency_throttle(struct rq_qos *rqos, struct bio *bio,
if (!blk_iolatency_enabled(blkiolat))
return;

bio_issue_init(&bio->bi_issue, bio_sectors(bio));

while (blkg && blkg->parent) {
struct iolatency_grp *iolat = blkg_to_lat(blkg);
if (!iolat) {
Expand Down
8 changes: 0 additions & 8 deletions block/blk-throttle.c
Original file line number Diff line number Diff line change
Expand Up @@ -2115,13 +2115,6 @@ static inline void throtl_update_latency_buckets(struct throtl_data *td)
}
#endif

static void blk_throtl_assoc_bio(struct throtl_grp *tg, struct bio *bio)
{
#ifdef CONFIG_BLK_DEV_THROTTLING_LOW
bio_issue_init(&bio->bi_issue, bio_sectors(bio));
#endif
}

bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
struct bio *bio)
{
Expand All @@ -2145,7 +2138,6 @@ bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
if (unlikely(blk_queue_bypass(q)))
goto out_unlock;

blk_throtl_assoc_bio(tg, bio);
blk_throtl_update_idletime(tg);

sq = &tg->service_queue;
Expand Down
2 changes: 2 additions & 0 deletions block/bounce.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask,

bio_clone_blkcg_association(bio, bio_src);

blkcg_bio_issue_init(bio);

return bio;
}

Expand Down
9 changes: 9 additions & 0 deletions include/linux/blk-cgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,12 @@ static inline bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg
struct bio *bio) { return false; }
#endif


static inline void blkcg_bio_issue_init(struct bio *bio)
{
bio_issue_init(&bio->bi_issue, bio_sectors(bio));
}

static inline bool blkcg_bio_issue_check(struct request_queue *q,
struct bio *bio)
{
Expand All @@ -922,6 +928,8 @@ static inline bool blkcg_bio_issue_check(struct request_queue *q,
blkg_rwstat_add(&blkg->stat_ios, bio->bi_opf, 1);
}

blkcg_bio_issue_init(bio);

rcu_read_unlock();
return !throtl;
}
Expand Down Expand Up @@ -1034,6 +1042,7 @@ static inline void blk_put_rl(struct request_list *rl) { }
static inline void blk_rq_set_rl(struct request *rq, struct request_list *rl) { }
static inline struct request_list *blk_rq_rl(struct request *rq) { return &rq->q->root_rl; }

static inline void blkcg_bio_issue_init(struct bio *bio) { }
static inline bool blkcg_bio_issue_check(struct request_queue *q,
struct bio *bio) { return true; }

Expand Down

0 comments on commit 5bf9a1f

Please sign in to comment.