4 #include <linux/kernel.h>
5 #include <linux/blkdev.h>
6 #include <linux/blk_types.h>
7 #include <linux/atomic.h>
8 #include <linux/wait.h>
16 wait_queue_head_t wait
;
21 struct rq_qos_ops
*ops
;
22 struct request_queue
*q
;
28 void (*throttle
)(struct rq_qos
*, struct bio
*, spinlock_t
*);
29 void (*track
)(struct rq_qos
*, struct request
*, struct bio
*);
30 void (*issue
)(struct rq_qos
*, struct request
*);
31 void (*requeue
)(struct rq_qos
*, struct request
*);
32 void (*done
)(struct rq_qos
*, struct request
*);
33 void (*done_bio
)(struct rq_qos
*, struct bio
*);
34 void (*cleanup
)(struct rq_qos
*, struct bio
*);
35 void (*exit
)(struct rq_qos
*);
39 unsigned int max_depth
;
44 unsigned int queue_depth
;
45 unsigned int default_depth
;
48 static inline struct rq_qos
*rq_qos_id(struct request_queue
*q
,
52 for (rqos
= q
->rq_qos
; rqos
; rqos
= rqos
->next
) {
59 static inline struct rq_qos
*wbt_rq_qos(struct request_queue
*q
)
61 return rq_qos_id(q
, RQ_QOS_WBT
);
64 static inline struct rq_qos
*blkcg_rq_qos(struct request_queue
*q
)
66 return rq_qos_id(q
, RQ_QOS_CGROUP
);
69 static inline void rq_wait_init(struct rq_wait
*rq_wait
)
71 atomic_set(&rq_wait
->inflight
, 0);
72 init_waitqueue_head(&rq_wait
->wait
);
75 static inline void rq_qos_add(struct request_queue
*q
, struct rq_qos
*rqos
)
77 rqos
->next
= q
->rq_qos
;
81 static inline void rq_qos_del(struct request_queue
*q
, struct rq_qos
*rqos
)
83 struct rq_qos
*cur
, *prev
= NULL
;
84 for (cur
= q
->rq_qos
; cur
; cur
= cur
->next
) {
87 prev
->next
= rqos
->next
;
96 bool rq_wait_inc_below(struct rq_wait
*rq_wait
, unsigned int limit
);
97 void rq_depth_scale_up(struct rq_depth
*rqd
);
98 void rq_depth_scale_down(struct rq_depth
*rqd
, bool hard_throttle
);
99 bool rq_depth_calc_max_depth(struct rq_depth
*rqd
);
101 void rq_qos_cleanup(struct request_queue
*, struct bio
*);
102 void rq_qos_done(struct request_queue
*, struct request
*);
103 void rq_qos_issue(struct request_queue
*, struct request
*);
104 void rq_qos_requeue(struct request_queue
*, struct request
*);
105 void rq_qos_done_bio(struct request_queue
*q
, struct bio
*bio
);
106 void rq_qos_throttle(struct request_queue
*, struct bio
*, spinlock_t
*);
107 void rq_qos_track(struct request_queue
*q
, struct request
*, struct bio
*);
108 void rq_qos_exit(struct request_queue
*);