mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
blk-cgroup: don't nest queue_lock under rcu in bio_associate_blkg()
If a bio is already associated with a blkg, the blkcg is already pinned until the bio is done, so there is no need for RCU protection. Otherwise, protect blkcg_css() with RCU independently. Prepare to protect blkcg with blkcg_mutex instead of queue_lock. Signed-off-by: Yu Kuai <yukuai@fygo.io> Link: https://patch.msgid.link/8496fa234b21d4b31b7f068766906d0bffcac8e6.1780621988.git.yukuai@fygo.io Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
9327a865e3
commit
457d3c4f0f
|
|
@ -2134,16 +2134,20 @@ void bio_associate_blkg(struct bio *bio)
|
||||||
if (blk_op_is_passthrough(bio->bi_opf))
|
if (blk_op_is_passthrough(bio->bi_opf))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rcu_read_lock();
|
if (bio->bi_blkg) {
|
||||||
|
|
||||||
if (bio->bi_blkg)
|
|
||||||
css = bio_blkcg_css(bio);
|
css = bio_blkcg_css(bio);
|
||||||
else
|
bio_associate_blkg_from_css(bio, css);
|
||||||
|
} else {
|
||||||
|
rcu_read_lock();
|
||||||
css = blkcg_css();
|
css = blkcg_css();
|
||||||
|
if (!css_tryget_online(css))
|
||||||
|
css = NULL;
|
||||||
|
rcu_read_unlock();
|
||||||
|
|
||||||
bio_associate_blkg_from_css(bio, css);
|
bio_associate_blkg_from_css(bio, css);
|
||||||
|
if (css)
|
||||||
rcu_read_unlock();
|
css_put(css);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(bio_associate_blkg);
|
EXPORT_SYMBOL_GPL(bio_associate_blkg);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user