Merge tag 'for-5.12/block-2021-02-17' of git://git.kernel.dk/linux-block
[sfrench/cifs-2.6.git] / block / blk-cgroup.c
index 4221a1539391c8eb1dfaf63e30e22aa2418ba00f..a317c03d40f6e1ff6a1f4aa5b7f0f214665e63b7 100644 (file)
@@ -32,8 +32,6 @@
 #include <linux/psi.h>
 #include "blk.h"
 
-#define MAX_KEY_LEN 100
-
 /*
  * blkcg_pol_mutex protects blkcg_policy[] and policy [de]activation.
  * blkcg_pol_register_mutex nests outside of it and synchronizes entire
@@ -1765,12 +1763,15 @@ void blkcg_schedule_throttle(struct request_queue *q, bool use_memdelay)
        if (unlikely(current->flags & PF_KTHREAD))
                return;
 
-       if (!blk_get_queue(q))
-               return;
+       if (current->throttle_queue != q) {
+               if (!blk_get_queue(q))
+                       return;
+
+               if (current->throttle_queue)
+                       blk_put_queue(current->throttle_queue);
+               current->throttle_queue = q;
+       }
 
-       if (current->throttle_queue)
-               blk_put_queue(current->throttle_queue);
-       current->throttle_queue = q;
        if (use_memdelay)
                current->use_memdelay = use_memdelay;
        set_notify_resume(current);
@@ -1808,7 +1809,8 @@ static inline struct blkcg_gq *blkg_tryget_closest(struct bio *bio,
        struct blkcg_gq *blkg, *ret_blkg = NULL;
 
        rcu_read_lock();
-       blkg = blkg_lookup_create(css_to_blkcg(css), bio->bi_disk->queue);
+       blkg = blkg_lookup_create(css_to_blkcg(css),
+                                 bio->bi_bdev->bd_disk->queue);
        while (blkg) {
                if (blkg_tryget(blkg)) {
                        ret_blkg = blkg;
@@ -1844,8 +1846,8 @@ void bio_associate_blkg_from_css(struct bio *bio,
        if (css && css->parent) {
                bio->bi_blkg = blkg_tryget_closest(bio, css);
        } else {
-               blkg_get(bio->bi_disk->queue->root_blkg);
-               bio->bi_blkg = bio->bi_disk->queue->root_blkg;
+               blkg_get(bio->bi_bdev->bd_disk->queue->root_blkg);
+               bio->bi_blkg = bio->bi_bdev->bd_disk->queue->root_blkg;
        }
 }
 EXPORT_SYMBOL_GPL(bio_associate_blkg_from_css);