diff options
author | Christoph Hellwig <hch@lst.de> | 2020-06-27 09:31:53 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-06-29 17:09:08 +0200 |
commit | a5b97526bf2860fe8306959f19ee428d1f5cc732 (patch) | |
tree | 8f3c46c26cb255774957970073be840bdc23af9f /block/blk-cgroup.c | |
parent | block: merge blkg_lookup_create and __blkg_lookup_create (diff) | |
download | linux-a5b97526bf2860fe8306959f19ee428d1f5cc732.tar.xz linux-a5b97526bf2860fe8306959f19ee428d1f5cc732.zip |
block: bypass blkg_tryget_closest for the root_blkg
The root_blkg is only torn down at the very end of removing a queue.
So in the I/O submission path is always has a life reference and we
can just grab another one using blkg_get instead of doing a tryget
and parent walk that won't lead anywhere.
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-cgroup.c')
-rw-r--r-- | block/blk-cgroup.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 6aedb73ffbf4..0912820d4f81 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1758,16 +1758,21 @@ void bio_associate_blkg_from_css(struct bio *bio, struct cgroup_subsys_state *css) { struct request_queue *q = bio->bi_disk->queue; - struct blkcg_gq *blkg = q->root_blkg; if (bio->bi_blkg) blkg_put(bio->bi_blkg); - rcu_read_lock(); - if (css && css->parent) + if (css && css->parent) { + struct blkcg_gq *blkg; + + rcu_read_lock(); blkg = blkg_lookup_create(css_to_blkcg(css), q); - bio->bi_blkg = blkg_tryget_closest(blkg); - rcu_read_unlock(); + bio->bi_blkg = blkg_tryget_closest(blkg); + rcu_read_unlock(); + } else { + blkg_get(q->root_blkg); + bio->bi_blkg = q->root_blkg; + } } EXPORT_SYMBOL_GPL(bio_associate_blkg_from_css); |