blkcg: handle dying request_queue when associating a blkg
[sfrench/cifs-2.6.git] / block / blk-cgroup.c
index 6bd0619a7d6ecd3cf95716fe399fdc45f4bf308f..c30661ddc873e04c5864d002cd3474a74180f1c1 100644 (file)
@@ -202,6 +202,12 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,
        WARN_ON_ONCE(!rcu_read_lock_held());
        lockdep_assert_held(&q->queue_lock);
 
+       /* request_queue is dying, do not create/recreate a blkg */
+       if (blk_queue_dying(q)) {
+               ret = -ENODEV;
+               goto err_free_blkg;
+       }
+
        /* blkg holds a reference to blkcg */
        if (!css_tryget_online(&blkcg->css)) {
                ret = -ENODEV;