Skip to content

Commit

Permalink
block: bypass blkg_tryget_closest for the root_blkg
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Jun 29, 2020
1 parent 8c54628 commit a5b9752
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions block/blk-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit a5b9752

Please sign in to comment.