aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2019-08-28 18:05:55 -0400
committerJens Axboe <axboe@kernel.dk>2019-08-28 23:17:07 -0400
commit9677a3e01f838622d2efc9a3ccb97090a2c3156a (patch)
tree8fee617bcc94779a92ab88c46d7862f0885a1282 /block
parentd3e65ffff61c329fb2d0bf15736c440c2d0cfc97 (diff)
block/rq_qos: implement rq_qos_ops->queue_depth_changed()
wbt already gets queue depth changed notification through wbt_set_queue_depth(). Generalize it into rq_qos_ops->queue_depth_changed() so that other rq_qos policies can easily hook into the events too. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/blk-rq-qos.c9
-rw-r--r--block/blk-rq-qos.h8
-rw-r--r--block/blk-settings.c2
-rw-r--r--block/blk-wbt.c18
-rw-r--r--block/blk-wbt.h4
5 files changed, 26 insertions, 15 deletions
diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c
index f4eea78f5cc1..61b635bc2a31 100644
--- a/block/blk-rq-qos.c
+++ b/block/blk-rq-qos.c
@@ -101,6 +101,15 @@ void __rq_qos_done_bio(struct rq_qos *rqos, struct bio *bio)
101 } while (rqos); 101 } while (rqos);
102} 102}
103 103
104void __rq_qos_queue_depth_changed(struct rq_qos *rqos)
105{
106 do {
107 if (rqos->ops->queue_depth_changed)
108 rqos->ops->queue_depth_changed(rqos);
109 rqos = rqos->next;
110 } while (rqos);
111}
112
104/* 113/*
105 * Return true, if we can't increase the depth further by scaling 114 * Return true, if we can't increase the depth further by scaling
106 */ 115 */
diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h
index 8e426a8505b6..e15b6907b76d 100644
--- a/block/blk-rq-qos.h
+++ b/block/blk-rq-qos.h
@@ -41,6 +41,7 @@ struct rq_qos_ops {
41 void (*done)(struct rq_qos *, struct request *); 41 void (*done)(struct rq_qos *, struct request *);
42 void (*done_bio)(struct rq_qos *, struct bio *); 42 void (*done_bio)(struct rq_qos *, struct bio *);
43 void (*cleanup)(struct rq_qos *, struct bio *); 43 void (*cleanup)(struct rq_qos *, struct bio *);
44 void (*queue_depth_changed)(struct rq_qos *);
44 void (*exit)(struct rq_qos *); 45 void (*exit)(struct rq_qos *);
45 const struct blk_mq_debugfs_attr *debugfs_attrs; 46 const struct blk_mq_debugfs_attr *debugfs_attrs;
46}; 47};
@@ -138,6 +139,7 @@ void __rq_qos_throttle(struct rq_qos *rqos, struct bio *bio);
138void __rq_qos_track(struct rq_qos *rqos, struct request *rq, struct bio *bio); 139void __rq_qos_track(struct rq_qos *rqos, struct request *rq, struct bio *bio);
139void __rq_qos_merge(struct rq_qos *rqos, struct request *rq, struct bio *bio); 140void __rq_qos_merge(struct rq_qos *rqos, struct request *rq, struct bio *bio);
140void __rq_qos_done_bio(struct rq_qos *rqos, struct bio *bio); 141void __rq_qos_done_bio(struct rq_qos *rqos, struct bio *bio);
142void __rq_qos_queue_depth_changed(struct rq_qos *rqos);
141 143
142static inline void rq_qos_cleanup(struct request_queue *q, struct bio *bio) 144static inline void rq_qos_cleanup(struct request_queue *q, struct bio *bio)
143{ 145{
@@ -194,6 +196,12 @@ static inline void rq_qos_merge(struct request_queue *q, struct request *rq,
194 __rq_qos_merge(q->rq_qos, rq, bio); 196 __rq_qos_merge(q->rq_qos, rq, bio);
195} 197}
196 198
199static inline void rq_qos_queue_depth_changed(struct request_queue *q)
200{
201 if (q->rq_qos)
202 __rq_qos_queue_depth_changed(q->rq_qos);
203}
204
197void rq_qos_exit(struct request_queue *); 205void rq_qos_exit(struct request_queue *);
198 206
199#endif 207#endif
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 2c1831207a8f..a058997b9cce 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -805,7 +805,7 @@ EXPORT_SYMBOL(blk_queue_update_dma_alignment);
805void blk_set_queue_depth(struct request_queue *q, unsigned int depth) 805void blk_set_queue_depth(struct request_queue *q, unsigned int depth)
806{ 806{
807 q->queue_depth = depth; 807 q->queue_depth = depth;
808 wbt_set_queue_depth(q, depth); 808 rq_qos_queue_depth_changed(q);
809} 809}
810EXPORT_SYMBOL(blk_set_queue_depth); 810EXPORT_SYMBOL(blk_set_queue_depth);
811 811
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index c4d3089e47f7..8af553a0ba00 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -629,15 +629,6 @@ static void wbt_requeue(struct rq_qos *rqos, struct request *rq)
629 } 629 }
630} 630}
631 631
632void wbt_set_queue_depth(struct request_queue *q, unsigned int depth)
633{
634 struct rq_qos *rqos = wbt_rq_qos(q);
635 if (rqos) {
636 RQWB(rqos)->rq_depth.queue_depth = depth;
637 __wbt_update_limits(RQWB(rqos));
638 }
639}
640
641void wbt_set_write_cache(struct request_queue *q, bool write_cache_on) 632void wbt_set_write_cache(struct request_queue *q, bool write_cache_on)
642{ 633{
643 struct rq_qos *rqos = wbt_rq_qos(q); 634 struct rq_qos *rqos = wbt_rq_qos(q);
@@ -689,6 +680,12 @@ static int wbt_data_dir(const struct request *rq)
689 return -1; 680 return -1;
690} 681}
691 682
683static void wbt_queue_depth_changed(struct rq_qos *rqos)
684{
685 RQWB(rqos)->rq_depth.queue_depth = blk_queue_depth(rqos->q);
686 __wbt_update_limits(RQWB(rqos));
687}
688
692static void wbt_exit(struct rq_qos *rqos) 689static void wbt_exit(struct rq_qos *rqos)
693{ 690{
694 struct rq_wb *rwb = RQWB(rqos); 691 struct rq_wb *rwb = RQWB(rqos);
@@ -811,6 +808,7 @@ static struct rq_qos_ops wbt_rqos_ops = {
811 .requeue = wbt_requeue, 808 .requeue = wbt_requeue,
812 .done = wbt_done, 809 .done = wbt_done,
813 .cleanup = wbt_cleanup, 810 .cleanup = wbt_cleanup,
811 .queue_depth_changed = wbt_queue_depth_changed,
814 .exit = wbt_exit, 812 .exit = wbt_exit,
815#ifdef CONFIG_BLK_DEBUG_FS 813#ifdef CONFIG_BLK_DEBUG_FS
816 .debugfs_attrs = wbt_debugfs_attrs, 814 .debugfs_attrs = wbt_debugfs_attrs,
@@ -853,7 +851,7 @@ int wbt_init(struct request_queue *q)
853 851
854 rwb->min_lat_nsec = wbt_default_latency_nsec(q); 852 rwb->min_lat_nsec = wbt_default_latency_nsec(q);
855 853
856 wbt_set_queue_depth(q, blk_queue_depth(q)); 854 wbt_queue_depth_changed(&rwb->rqos);
857 wbt_set_write_cache(q, test_bit(QUEUE_FLAG_WC, &q->queue_flags)); 855 wbt_set_write_cache(q, test_bit(QUEUE_FLAG_WC, &q->queue_flags));
858 856
859 return 0; 857 return 0;
diff --git a/block/blk-wbt.h b/block/blk-wbt.h
index f47218d5b3b2..8e4e37660971 100644
--- a/block/blk-wbt.h
+++ b/block/blk-wbt.h
@@ -95,7 +95,6 @@ void wbt_enable_default(struct request_queue *);
95u64 wbt_get_min_lat(struct request_queue *q); 95u64 wbt_get_min_lat(struct request_queue *q);
96void wbt_set_min_lat(struct request_queue *q, u64 val); 96void wbt_set_min_lat(struct request_queue *q, u64 val);
97 97
98void wbt_set_queue_depth(struct request_queue *, unsigned int);
99void wbt_set_write_cache(struct request_queue *, bool); 98void wbt_set_write_cache(struct request_queue *, bool);
100 99
101u64 wbt_default_latency_nsec(struct request_queue *); 100u64 wbt_default_latency_nsec(struct request_queue *);
@@ -118,9 +117,6 @@ static inline void wbt_disable_default(struct request_queue *q)
118static inline void wbt_enable_default(struct request_queue *q) 117static inline void wbt_enable_default(struct request_queue *q)
119{ 118{
120} 119}
121static inline void wbt_set_queue_depth(struct request_queue *q, unsigned int depth)
122{
123}
124static inline void wbt_set_write_cache(struct request_queue *q, bool wc) 120static inline void wbt_set_write_cache(struct request_queue *q, bool wc)
125{ 121{
126} 122}