diff options
author | Tejun Heo <tj@kernel.org> | 2013-05-14 16:52:34 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-05-14 16:52:34 -0400 |
commit | 49a2f1e3f231f6b2ccfc8192f4c395de7fa910a1 (patch) | |
tree | aa1f0a5ff403d778b5b97997cdaec361eb79a0b9 /block/blk-throttle.c | |
parent | 0049af73bb4b74d1407db59caefc5fe057ee434a (diff) |
blk-throttle: add throtl_grp->service_queue
Currently, there's single service_queue per queue -
throtl_data->service_queue. All active throtl_grp's are queued on the
queue and dispatched according to their limits. To support hierarchy,
this will be expanded such that active throtl_grp's form a tree
anchored at throtl_data->service_queue and chained through each
intermediate throtl_grp's service_queue.
This patch adds throtl_grp->service_queue to prepare for hierarchy
support. The initialization function - throtl_service_queue_init() -
is added and replaces the macro initializer. The newly added
tg->service_queue isn't used yet. Following patches will do.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Diffstat (limited to 'block/blk-throttle.c')
-rw-r--r-- | block/blk-throttle.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/block/blk-throttle.c b/block/blk-throttle.c index ebaaaa9f57d6..7340440ccfb5 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c | |||
@@ -33,9 +33,6 @@ struct throtl_service_queue { | |||
33 | unsigned long first_pending_disptime; /* disptime of the first tg */ | 33 | unsigned long first_pending_disptime; /* disptime of the first tg */ |
34 | }; | 34 | }; |
35 | 35 | ||
36 | #define THROTL_SERVICE_QUEUE_INITIALIZER \ | ||
37 | (struct throtl_service_queue){ .pending_tree = RB_ROOT } | ||
38 | |||
39 | enum tg_state_flags { | 36 | enum tg_state_flags { |
40 | THROTL_TG_PENDING = 1 << 0, /* on parent's pending tree */ | 37 | THROTL_TG_PENDING = 1 << 0, /* on parent's pending tree */ |
41 | }; | 38 | }; |
@@ -60,6 +57,9 @@ struct throtl_grp { | |||
60 | /* throtl_data this group belongs to */ | 57 | /* throtl_data this group belongs to */ |
61 | struct throtl_data *td; | 58 | struct throtl_data *td; |
62 | 59 | ||
60 | /* this group's service queue */ | ||
61 | struct throtl_service_queue service_queue; | ||
62 | |||
63 | /* | 63 | /* |
64 | * Dispatch time in jiffies. This is the estimated time when group | 64 | * Dispatch time in jiffies. This is the estimated time when group |
65 | * will unthrottle and is ready to dispatch more bio. It is used as | 65 | * will unthrottle and is ready to dispatch more bio. It is used as |
@@ -190,11 +190,18 @@ alloc_stats: | |||
190 | goto alloc_stats; | 190 | goto alloc_stats; |
191 | } | 191 | } |
192 | 192 | ||
193 | /* init a service_queue, assumes the caller zeroed it */ | ||
194 | static void throtl_service_queue_init(struct throtl_service_queue *sq) | ||
195 | { | ||
196 | sq->pending_tree = RB_ROOT; | ||
197 | } | ||
198 | |||
193 | static void throtl_pd_init(struct blkcg_gq *blkg) | 199 | static void throtl_pd_init(struct blkcg_gq *blkg) |
194 | { | 200 | { |
195 | struct throtl_grp *tg = blkg_to_tg(blkg); | 201 | struct throtl_grp *tg = blkg_to_tg(blkg); |
196 | unsigned long flags; | 202 | unsigned long flags; |
197 | 203 | ||
204 | throtl_service_queue_init(&tg->service_queue); | ||
198 | RB_CLEAR_NODE(&tg->rb_node); | 205 | RB_CLEAR_NODE(&tg->rb_node); |
199 | tg->td = blkg->q->td; | 206 | tg->td = blkg->q->td; |
200 | bio_list_init(&tg->bio_lists[0]); | 207 | bio_list_init(&tg->bio_lists[0]); |
@@ -1168,8 +1175,8 @@ int blk_throtl_init(struct request_queue *q) | |||
1168 | if (!td) | 1175 | if (!td) |
1169 | return -ENOMEM; | 1176 | return -ENOMEM; |
1170 | 1177 | ||
1171 | td->service_queue = THROTL_SERVICE_QUEUE_INITIALIZER; | ||
1172 | INIT_DELAYED_WORK(&td->dispatch_work, blk_throtl_dispatch_work_fn); | 1178 | INIT_DELAYED_WORK(&td->dispatch_work, blk_throtl_dispatch_work_fn); |
1179 | throtl_service_queue_init(&td->service_queue); | ||
1173 | 1180 | ||
1174 | q->td = td; | 1181 | q->td = td; |
1175 | td->queue = q; | 1182 | td->queue = q; |