block: always attach cgroup info into bio
authorShaohua Li <shli@fb.com>
Wed, 12 Jul 2017 18:49:54 +0000 (11:49 -0700)
committerJens Axboe <axboe@kernel.dk>
Sat, 29 Jul 2017 15:00:03 +0000 (09:00 -0600)
blkcg_bio_issue_check() already gets blkcg for a BIO.
bio_associate_blkcg() uses a percpu refcounter, so it's a very cheap
operation. There is no point we don't attach the cgroup info into bio at
blkcg_bio_issue_check. This also makes blktrace outputs correct cgroup
info.

Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-throttle.c
include/linux/blk-cgroup.h

index a7285bf2831c7bdbb89b753fccb198f8640e8780..a6ebd2bdb4df9498743449fc3c6a220ae4c5522e 100644 (file)
@@ -2104,14 +2104,9 @@ static inline void throtl_update_latency_buckets(struct throtl_data *td)
 static void blk_throtl_assoc_bio(struct throtl_grp *tg, struct bio *bio)
 {
 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
-       int ret;
-
-       ret = bio_associate_current(bio);
-       if (ret == 0 || ret == -EBUSY)
+       if (bio->bi_css)
                bio->bi_cg_private = tg;
        blk_stat_set_issue(&bio->bi_issue_stat, bio_sectors(bio));
-#else
-       bio_associate_current(bio);
 #endif
 }
 
index 7104bea8dab1c9895ccc916c5d90912fb41db77e..9d92153dd856f49eb927271e493a4416a2ea15a7 100644 (file)
@@ -691,6 +691,9 @@ static inline bool blkcg_bio_issue_check(struct request_queue *q,
        rcu_read_lock();
        blkcg = bio_blkcg(bio);
 
+       /* associate blkcg if bio hasn't attached one */
+       bio_associate_blkcg(bio, &blkcg->css);
+
        blkg = blkg_lookup(blkcg, q);
        if (unlikely(!blkg)) {
                spin_lock_irq(q->queue_lock);