aboutsummaryrefslogtreecommitdiffstats
path: root/block/elevator.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-03-05 16:15:19 -0500
committerJens Axboe <axboe@kernel.dk>2012-03-06 15:27:23 -0500
commit03aa264ac15637b6f98374270bcdf31400965505 (patch)
tree6fa9ca54d3f775fba19123790f6655158034a1d8 /block/elevator.c
parent4eef3049986e8397d5003916aed8cad6567a5e02 (diff)
blkcg: let blkcg core manage per-queue blkg list and counter
With the previous patch to move blkg list heads and counters to request_queue and blkg, logic to manage them in both policies are almost identical and can be moved to blkcg core. This patch moves blkg link logic into blkg_lookup_create(), implements common blkg unlink code in blkg_destroy(), and updates blkg_destory_all() so that it's policy specific and can skip root group. The updated blkg_destroy_all() is now used to both clear queue for bypassing and elv switching, and release all blkgs on q exit. This patch introduces a race window where policy [de]registration may race against queue blkg clearing. This can only be a problem on cfq unload and shouldn't be a real problem in practice (and we have many other places where this race already exists). Future patches will remove these unlikely races. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/elevator.c')
-rw-r--r--block/elevator.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/block/elevator.c b/block/elevator.c
index 8c7561fd2c79..d4d39dab841a 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -876,7 +876,7 @@ static int elevator_switch(struct request_queue *q, struct elevator_type *new_e)
876{ 876{
877 struct elevator_queue *old = q->elevator; 877 struct elevator_queue *old = q->elevator;
878 bool registered = old->registered; 878 bool registered = old->registered;
879 int err; 879 int i, err;
880 880
881 /* 881 /*
882 * Turn on BYPASS and drain all requests w/ elevator private data. 882 * Turn on BYPASS and drain all requests w/ elevator private data.
@@ -895,7 +895,8 @@ static int elevator_switch(struct request_queue *q, struct elevator_type *new_e)
895 ioc_clear_queue(q); 895 ioc_clear_queue(q);
896 spin_unlock_irq(q->queue_lock); 896 spin_unlock_irq(q->queue_lock);
897 897
898 blkg_destroy_all(q); 898 for (i = 0; i < BLKIO_NR_POLICIES; i++)
899 blkg_destroy_all(q, i, false);
899 900
900 /* allocate, init and register new elevator */ 901 /* allocate, init and register new elevator */
901 err = -ENOMEM; 902 err = -ENOMEM;