blk-cgroup: bypass blkcg_deactivate_policy after destroying
authorMing Lei <ming.lei@redhat.com>
Fri, 17 Nov 2023 02:35:24 +0000 (10:35 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 17 Nov 2023 17:48:58 +0000 (10:48 -0700)
blkcg_deactivate_policy() can be called after blkg_destroy_all()
returns, and it isn't necessary since blkg_destroy_all has covered
policy deactivation.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20231117023527.3188627-4-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-cgroup.c

index 4a42ea2972ad85693480c5e9c0e9599923c73ccf..4b48c2c44098131328447f80172269657e64c2d0 100644 (file)
@@ -577,6 +577,7 @@ static void blkg_destroy_all(struct gendisk *disk)
        struct request_queue *q = disk->queue;
        struct blkcg_gq *blkg, *n;
        int count = BLKG_DESTROY_BATCH_SIZE;
+       int i;
 
 restart:
        spin_lock_irq(&q->queue_lock);
@@ -602,6 +603,18 @@ restart:
                }
        }
 
+       /*
+        * Mark policy deactivated since policy offline has been done, and
+        * the free is scheduled, so future blkcg_deactivate_policy() can
+        * be bypassed
+        */
+       for (i = 0; i < BLKCG_MAX_POLS; i++) {
+               struct blkcg_policy *pol = blkcg_policy[i];
+
+               if (pol)
+                       __clear_bit(pol->plid, q->blkcg_pols);
+       }
+
        q->root_blkg = NULL;
        spin_unlock_irq(&q->queue_lock);
 }