From: Tejun Heo tj@kernel.org
mainline inclusion from mainline-5.4-rc1 commit d3e65ffff61c329fb2d0bf15736c440c2d0cfc97 category: feature bugzilla: 38688 CVE: NA
---------------------------
Add a merge hook for rq_qos. This will be used by io.weight.
Signed-off-by: Tejun Heo tj@kernel.org Signed-off-by: Jens Axboe axboe@kernel.dk
Conflict: block/blk-rq-qos.c block/blk-core.c block/blk-rq-qos.h Signed-off-by: Yu Kuai yukuai3@huawei.com Reviewed-by: Hou Tao houtao1@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- block/blk-core.c | 4 ++++ block/blk-rq-qos.c | 11 +++++++++++ block/blk-rq-qos.h | 2 ++ 3 files changed, 17 insertions(+)
diff --git a/block/blk-core.c b/block/blk-core.c index 7afe44d097413..ba3b7ac5b4782 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1802,6 +1802,7 @@ bool bio_attempt_back_merge(struct request_queue *q, struct request *req, return false;
trace_block_bio_backmerge(q, req, bio); + rq_qos_merge(req->q, req, bio);
if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff) blk_rq_set_mixed_merge(req); @@ -1824,6 +1825,7 @@ bool bio_attempt_front_merge(struct request_queue *q, struct request *req, return false;
trace_block_bio_frontmerge(q, req, bio); + rq_qos_merge(req->q, req, bio);
if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff) blk_rq_set_mixed_merge(req); @@ -1850,6 +1852,8 @@ bool bio_attempt_discard_merge(struct request_queue *q, struct request *req, blk_rq_get_max_sectors(req, blk_rq_pos(req))) goto no_merge;
+ rq_qos_merge(q, req, bio); + req->biotail->bi_next = bio; req->biotail = bio; req->__data_len += bio->bi_iter.bi_size; diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c index 43bcd4e7a7f9a..7600c36f81220 100644 --- a/block/blk-rq-qos.c +++ b/block/blk-rq-qos.c @@ -88,6 +88,17 @@ void rq_qos_track(struct request_queue *q, struct request *rq, struct bio *bio) } }
+void rq_qos_merge(struct request_queue *q, struct request *rq, struct bio *bio) +{ + struct rq_qos *rqos; + + for (rqos = q->rq_qos; rqos; rqos = rqos->next) { + if (rqos->ops->merge) + rqos->ops->merge(rqos, rq, bio); + } +} + + void rq_qos_done_bio(struct request_queue *q, struct bio *bio) { struct rq_qos *rqos; diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index 98caba3e962ee..c4d798543f1a7 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -27,6 +27,7 @@ struct rq_qos { struct rq_qos_ops { void (*throttle)(struct rq_qos *, struct bio *, spinlock_t *); void (*track)(struct rq_qos *, struct request *, struct bio *); + void (*merge)(struct rq_qos *, struct request *, struct bio *); void (*issue)(struct rq_qos *, struct request *); void (*requeue)(struct rq_qos *, struct request *); void (*done)(struct rq_qos *, struct request *); @@ -102,5 +103,6 @@ void rq_qos_requeue(struct request_queue *, struct request *); void rq_qos_done_bio(struct request_queue *q, struct bio *bio); void rq_qos_throttle(struct request_queue *, struct bio *, spinlock_t *); void rq_qos_track(struct request_queue *q, struct request *, struct bio *); +void rq_qos_merge(struct request_queue *q, struct request *rq, struct bio *bio); void rq_qos_exit(struct request_queue *); #endif