diff --git a/block/blk-core.c b/block/blk-core.c index ea33d6abdcfc9e8543df0c9c5c5f735b3c4c2f9e..dddb63d67b50c6906e364c47d811fd35dc4fc211 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1812,6 +1812,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(q, req, bio); if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff) blk_rq_set_mixed_merge(req); @@ -1834,6 +1835,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(q, req, bio); if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff) blk_rq_set_mixed_merge(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))) 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 43bcd4e7a7f9ae5da1fa005b5bca0110e7be9aa9..45df2889c59e675693a5b96e9959a2a220978402 100644 --- a/block/blk-rq-qos.c +++ b/block/blk-rq-qos.c @@ -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) { struct rq_qos *rqos; diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index 98caba3e962eeb63bd9bbdc78ce0398d6fa414ca..7cceed738fe6a22b6fdd9ce38dfe4a6e7d4aebbd 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,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_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 rq_qos *rqos, struct request *rq, struct bio *bio); 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