提交 9726dea7 编写于 作者: T Tejun Heo 提交者: Joseph Qi

block/rq_qos: add rq_qos_merge()

commit d3e65ffff61c329fb2d0bf15736c440c2d0cfc97 upstream.

Add a merge hook for rq_qos.  This will be used by io.weight.
Signed-off-by: NTejun Heo <tj@kernel.org>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Signed-off-by: NJiufei Xue <jiufei.xue@linux.alibaba.com>
Reviewed-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
上级 cf569826
...@@ -1812,6 +1812,7 @@ bool bio_attempt_back_merge(struct request_queue *q, struct request *req, ...@@ -1812,6 +1812,7 @@ bool bio_attempt_back_merge(struct request_queue *q, struct request *req,
return false; return false;
trace_block_bio_backmerge(q, req, bio); trace_block_bio_backmerge(q, req, bio);
rq_qos_merge(q, req, bio);
if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff) if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff)
blk_rq_set_mixed_merge(req); blk_rq_set_mixed_merge(req);
...@@ -1834,6 +1835,7 @@ bool bio_attempt_front_merge(struct request_queue *q, struct request *req, ...@@ -1834,6 +1835,7 @@ bool bio_attempt_front_merge(struct request_queue *q, struct request *req,
return false; return false;
trace_block_bio_frontmerge(q, req, bio); trace_block_bio_frontmerge(q, req, bio);
rq_qos_merge(q, req, bio);
if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff) if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff)
blk_rq_set_mixed_merge(req); blk_rq_set_mixed_merge(req);
...@@ -1860,6 +1862,8 @@ bool bio_attempt_discard_merge(struct request_queue *q, struct request *req, ...@@ -1860,6 +1862,8 @@ bool bio_attempt_discard_merge(struct request_queue *q, struct request *req,
blk_rq_get_max_sectors(req, blk_rq_pos(req))) blk_rq_get_max_sectors(req, blk_rq_pos(req)))
goto no_merge; goto no_merge;
rq_qos_merge(q, req, bio);
req->biotail->bi_next = bio; req->biotail->bi_next = bio;
req->biotail = bio; req->biotail = bio;
req->__data_len += bio->bi_iter.bi_size; req->__data_len += bio->bi_iter.bi_size;
......
...@@ -88,6 +88,15 @@ void rq_qos_track(struct request_queue *q, struct request *rq, struct bio *bio) ...@@ -88,6 +88,15 @@ void rq_qos_track(struct request_queue *q, struct request *rq, struct bio *bio)
} }
} }
void __rq_qos_merge(struct rq_qos *rqos, struct request *rq, struct bio *bio)
{
do {
if (rqos->ops->merge)
rqos->ops->merge(rqos, rq, bio);
rqos = rqos->next;
} while (rqos);
}
void rq_qos_done_bio(struct request_queue *q, struct bio *bio) void rq_qos_done_bio(struct request_queue *q, struct bio *bio)
{ {
struct rq_qos *rqos; struct rq_qos *rqos;
......
...@@ -27,6 +27,7 @@ struct rq_qos { ...@@ -27,6 +27,7 @@ struct rq_qos {
struct rq_qos_ops { struct rq_qos_ops {
void (*throttle)(struct rq_qos *, struct bio *, spinlock_t *); void (*throttle)(struct rq_qos *, struct bio *, spinlock_t *);
void (*track)(struct rq_qos *, struct request *, struct bio *); 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 (*issue)(struct rq_qos *, struct request *);
void (*requeue)(struct rq_qos *, struct request *); void (*requeue)(struct rq_qos *, struct request *);
void (*done)(struct rq_qos *, struct request *); void (*done)(struct rq_qos *, struct request *);
...@@ -102,5 +103,14 @@ void rq_qos_requeue(struct request_queue *, struct request *); ...@@ -102,5 +103,14 @@ void rq_qos_requeue(struct request_queue *, struct request *);
void rq_qos_done_bio(struct request_queue *q, struct bio *bio); 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_throttle(struct request_queue *, struct bio *, spinlock_t *);
void rq_qos_track(struct request_queue *q, struct request *, struct bio *); void rq_qos_track(struct request_queue *q, struct request *, struct bio *);
void __rq_qos_merge(struct rq_qos *rqos, struct request *rq, struct bio *bio);
void rq_qos_exit(struct request_queue *); void rq_qos_exit(struct request_queue *);
static inline void rq_qos_merge(struct request_queue *q, struct request *rq,
struct bio *bio)
{
if (q->rq_qos)
__rq_qos_merge(q->rq_qos, rq, bio);
}
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册