Skip to content

Commit a5b9752

Browse files
Christoph Hellwigaxboe
authored andcommitted
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>
1 parent 8c54628 commit a5b9752

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎block/blk-cgroup.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,16 +1758,21 @@ void bio_associate_blkg_from_css(struct bio *bio,
17581758
struct cgroup_subsys_state *css)
17591759
{
17601760
struct request_queue *q = bio->bi_disk->queue;
1761-
struct blkcg_gq *blkg = q->root_blkg;
17621761

17631762
if (bio->bi_blkg)
17641763
blkg_put(bio->bi_blkg);
17651764

1766-
rcu_read_lock();
1767-
if (css && css->parent)
1765+
if (css && css->parent) {
1766+
struct blkcg_gq *blkg;
1767+
1768+
rcu_read_lock();
17681769
blkg = blkg_lookup_create(css_to_blkcg(css), q);
1769-
bio->bi_blkg = blkg_tryget_closest(blkg);
1770-
rcu_read_unlock();
1770+
bio->bi_blkg = blkg_tryget_closest(blkg);
1771+
rcu_read_unlock();
1772+
} else {
1773+
blkg_get(q->root_blkg);
1774+
bio->bi_blkg = q->root_blkg;
1775+
}
17711776
}
17721777
EXPORT_SYMBOL_GPL(bio_associate_blkg_from_css);
17731778

0 commit comments

Comments
 (0)