diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 3093c1c03902..d095302d7dcc 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -575,6 +575,7 @@ static void blkg_destroy_all(struct gendisk *disk) int i; restart: + mutex_lock(&q->blkcg_mutex); spin_lock_irq(&q->queue_lock); list_for_each_entry(blkg, &q->blkg_list, q_node) { struct blkcg *blkcg = blkg->blkcg; @@ -593,6 +594,7 @@ static void blkg_destroy_all(struct gendisk *disk) if (!(--count)) { count = BLKG_DESTROY_BATCH_SIZE; spin_unlock_irq(&q->queue_lock); + mutex_unlock(&q->blkcg_mutex); cond_resched(); goto restart; } @@ -612,6 +614,7 @@ static void blkg_destroy_all(struct gendisk *disk) q->root_blkg = NULL; spin_unlock_irq(&q->queue_lock); + mutex_unlock(&q->blkcg_mutex); wake_up_var(&q->root_blkg); }