Skip to content
This repository has been archived by the owner on Apr 10, 2019. It is now read-only.

Commit

Permalink
blkcg: shoot down blkgs if all policies are deactivated
Browse files Browse the repository at this point in the history
There's no reason to keep blkgs around if no policy is activated for
the queue.  This patch moves queue locking out of blkg_destroy_all()
and call it from blkg_deactivate_policy() on deactivation of the last
policy on the queue.

This change was suggested by Vivek.

Signed-off-by: Tejun Heo <[email protected]>
Cc: Vivek Goyal <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
htejun authored and axboe committed Apr 20, 2012
1 parent 3c96cb3 commit 6d18b00
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions block/blk-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static void blkg_destroy_all(struct request_queue *q)
{
struct blkio_group *blkg, *n;

spin_lock_irq(q->queue_lock);
lockdep_assert_held(q->queue_lock);

list_for_each_entry_safe(blkg, n, &q->blkg_list, q_node) {
struct blkio_cgroup *blkcg = blkg->blkcg;
Expand All @@ -267,8 +267,6 @@ static void blkg_destroy_all(struct request_queue *q)
blkg_destroy(blkg);
spin_unlock(&blkcg->lock);
}

spin_unlock_irq(q->queue_lock);
}

static void blkg_rcu_free(struct rcu_head *rcu_head)
Expand Down Expand Up @@ -646,7 +644,10 @@ void blkcg_drain_queue(struct request_queue *q)
*/
void blkcg_exit_queue(struct request_queue *q)
{
spin_lock_irq(q->queue_lock);
blkg_destroy_all(q);
spin_unlock_irq(q->queue_lock);

blk_throtl_exit(q);
}

Expand Down Expand Up @@ -802,6 +803,10 @@ void blkcg_deactivate_policy(struct request_queue *q,

__clear_bit(pol->plid, q->blkcg_pols);

/* if no policy is left, no need for blkgs - shoot them down */
if (bitmap_empty(q->blkcg_pols, BLKCG_MAX_POLS))
blkg_destroy_all(q);

list_for_each_entry(blkg, &q->blkg_list, q_node) {
/* grab blkcg lock too while removing @pd from @blkg */
spin_lock(&blkg->blkcg->lock);
Expand Down

0 comments on commit 6d18b00

Please sign in to comment.