diff options
author | Tejun Heo <tj@kernel.org> | 2013-05-14 16:52:38 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-05-14 16:52:38 -0400 |
commit | 6bc9c2b464fb89eab705da87aa4284171d942369 (patch) | |
tree | 9b302b4d3f036f28ee2c0198148a3bf7d8bceadf /block | |
parent | 9e660acffcd1b5adc4ec1ffba0cbb584f86b8907 (diff) |
blk-throttle: make tg_dispatch_one_bio() ready for hierarchy
tg_dispatch_one_bio() currently assumes that the parent_sq is the top
level one and the bio being dispatched is ready to be issued; however,
this assumption will be wrong with proper hierarchy support. This
patch makes the following changes to make tg_dispatch_on_bio() ready
for hiearchy.
* throtl_data->nr_queued[] is incremented in blk_throtl_bio() instead
of throtl_add_bio_tg() so that throtl_add_bio_tg() can be used to
transfer a bio from a child tg to its parent.
* tg_dispatch_one_bio() is updated to distinguish whether its parent
is another throtl_grp or the throtl_data. If former, the bio is
transferred to the parent throtl_grp using throtl_add_bio_tg(). If
latter, the bio is ready to be issued and put on the top-level
service_queue's bio_lists[] and throtl_data->nr_queued is
decremented.
As all throtl_grps currently have the top level service_queue as their
->parent_sq, this patch in itself doesn't make any behavior
difference.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-throttle.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 52321a42cd78..04202617fda5 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c | |||
@@ -824,7 +824,6 @@ static void throtl_add_bio_tg(struct bio *bio, struct throtl_grp *tg) | |||
824 | /* Take a bio reference on tg */ | 824 | /* Take a bio reference on tg */ |
825 | blkg_get(tg_to_blkg(tg)); | 825 | blkg_get(tg_to_blkg(tg)); |
826 | sq->nr_queued[rw]++; | 826 | sq->nr_queued[rw]++; |
827 | tg->td->nr_queued[rw]++; | ||
828 | throtl_enqueue_tg(tg); | 827 | throtl_enqueue_tg(tg); |
829 | } | 828 | } |
830 | 829 | ||
@@ -855,20 +854,34 @@ static void tg_update_disptime(struct throtl_grp *tg) | |||
855 | static void tg_dispatch_one_bio(struct throtl_grp *tg, bool rw) | 854 | static void tg_dispatch_one_bio(struct throtl_grp *tg, bool rw) |
856 | { | 855 | { |
857 | struct throtl_service_queue *sq = &tg->service_queue; | 856 | struct throtl_service_queue *sq = &tg->service_queue; |
857 | struct throtl_service_queue *parent_sq = sq->parent_sq; | ||
858 | struct throtl_grp *parent_tg = sq_to_tg(parent_sq); | ||
858 | struct bio *bio; | 859 | struct bio *bio; |
859 | 860 | ||
860 | bio = bio_list_pop(&sq->bio_lists[rw]); | 861 | bio = bio_list_pop(&sq->bio_lists[rw]); |
861 | sq->nr_queued[rw]--; | 862 | sq->nr_queued[rw]--; |
862 | /* Drop bio reference on blkg */ | ||
863 | blkg_put(tg_to_blkg(tg)); | ||
864 | |||
865 | BUG_ON(tg->td->nr_queued[rw] <= 0); | ||
866 | tg->td->nr_queued[rw]--; | ||
867 | 863 | ||
868 | throtl_charge_bio(tg, bio); | 864 | throtl_charge_bio(tg, bio); |
869 | bio_list_add(&sq->parent_sq->bio_lists[rw], bio); | 865 | |
866 | /* | ||
867 | * If our parent is another tg, we just need to transfer @bio to | ||
868 | * the parent using throtl_add_bio_tg(). If our parent is | ||
869 | * @td->service_queue, @bio is ready to be issued. Put it on its | ||
870 | * bio_lists[] and decrease total number queued. The caller is | ||
871 | * responsible for issuing these bios. | ||
872 | */ | ||
873 | if (parent_tg) { | ||
874 | throtl_add_bio_tg(bio, parent_tg); | ||
875 | } else { | ||
876 | bio_list_add(&parent_sq->bio_lists[rw], bio); | ||
877 | BUG_ON(tg->td->nr_queued[rw] <= 0); | ||
878 | tg->td->nr_queued[rw]--; | ||
879 | } | ||
870 | 880 | ||
871 | throtl_trim_slice(tg, rw); | 881 | throtl_trim_slice(tg, rw); |
882 | |||
883 | /* @bio is transferred to parent, drop its blkg reference */ | ||
884 | blkg_put(tg_to_blkg(tg)); | ||
872 | } | 885 | } |
873 | 886 | ||
874 | static int throtl_dispatch_tg(struct throtl_grp *tg) | 887 | static int throtl_dispatch_tg(struct throtl_grp *tg) |
@@ -1283,6 +1296,7 @@ bool blk_throtl_bio(struct request_queue *q, struct bio *bio) | |||
1283 | sq->nr_queued[READ], sq->nr_queued[WRITE]); | 1296 | sq->nr_queued[READ], sq->nr_queued[WRITE]); |
1284 | 1297 | ||
1285 | bio_associate_current(bio); | 1298 | bio_associate_current(bio); |
1299 | tg->td->nr_queued[rw]++; | ||
1286 | throtl_add_bio_tg(bio, tg); | 1300 | throtl_add_bio_tg(bio, tg); |
1287 | throttled = true; | 1301 | throttled = true; |
1288 | 1302 | ||