blkcg: handle dying request_queue when associating a blkg
[sfrench/cifs-2.6.git] / block / blk-cgroup.c
index 2ca7611fe2740ada237debc4a5bc102455d08ff5..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;
@@ -1736,8 +1742,7 @@ void blkcg_maybe_throttle_current(void)
        blkg = blkg_lookup(blkcg, q);
        if (!blkg)
                goto out;
-       blkg = blkg_try_get(blkg);
-       if (!blkg)
+       if (!blkg_tryget(blkg))
                goto out;
        rcu_read_unlock();