mirror of https://gitee.com/openkylin/linux.git
block: merge __bio_associate_blkg into bio_associate_blkg_from_css
Merge __bio_associate_blkg into the only caller, which allows to slightly reduce the RCU crticial section and better explain the code flow. Acked-by: Tejun Heo <tj@kernel.org> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
d92c370a16
commit
2badf06cf9
45
block/bio.c
45
block/bio.c
|
@ -1628,52 +1628,33 @@ int bioset_init_from_src(struct bio_set *bs, struct bio_set *src)
|
||||||
EXPORT_SYMBOL(bioset_init_from_src);
|
EXPORT_SYMBOL(bioset_init_from_src);
|
||||||
|
|
||||||
#ifdef CONFIG_BLK_CGROUP
|
#ifdef CONFIG_BLK_CGROUP
|
||||||
|
|
||||||
/**
|
|
||||||
* __bio_associate_blkg - associate a bio with the a blkg
|
|
||||||
* @bio: target bio
|
|
||||||
* @blkg: the blkg to associate
|
|
||||||
*
|
|
||||||
* This tries to associate @bio with the specified @blkg. Association failure
|
|
||||||
* is handled by walking up the blkg tree. Therefore, the blkg associated can
|
|
||||||
* be anything between @blkg and the root_blkg. This situation only happens
|
|
||||||
* when a cgroup is dying and then the remaining bios will spill to the closest
|
|
||||||
* alive blkg.
|
|
||||||
*
|
|
||||||
* A reference will be taken on the @blkg and will be released when @bio is
|
|
||||||
* freed.
|
|
||||||
*/
|
|
||||||
static void __bio_associate_blkg(struct bio *bio, struct blkcg_gq *blkg)
|
|
||||||
{
|
|
||||||
if (bio->bi_blkg)
|
|
||||||
blkg_put(bio->bi_blkg);
|
|
||||||
bio->bi_blkg = blkg_tryget_closest(blkg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bio_associate_blkg_from_css - associate a bio with a specified css
|
* bio_associate_blkg_from_css - associate a bio with a specified css
|
||||||
* @bio: target bio
|
* @bio: target bio
|
||||||
* @css: target css
|
* @css: target css
|
||||||
*
|
*
|
||||||
* Associate @bio with the blkg found by combining the css's blkg and the
|
* Associate @bio with the blkg found by combining the css's blkg and the
|
||||||
* request_queue of the @bio. This falls back to the queue's root_blkg if
|
* request_queue of the @bio. An association failure is handled by walking up
|
||||||
* the association fails with the css.
|
* the blkg tree. Therefore, the blkg associated can be anything between @blkg
|
||||||
|
* and q->root_blkg. This situation only happens when a cgroup is dying and
|
||||||
|
* then the remaining bios will spill to the closest alive blkg.
|
||||||
|
*
|
||||||
|
* A reference will be taken on the blkg and will be released when @bio is
|
||||||
|
* freed.
|
||||||
*/
|
*/
|
||||||
void bio_associate_blkg_from_css(struct bio *bio,
|
void bio_associate_blkg_from_css(struct bio *bio,
|
||||||
struct cgroup_subsys_state *css)
|
struct cgroup_subsys_state *css)
|
||||||
{
|
{
|
||||||
struct request_queue *q = bio->bi_disk->queue;
|
struct request_queue *q = bio->bi_disk->queue;
|
||||||
struct blkcg_gq *blkg;
|
struct blkcg_gq *blkg = q->root_blkg;
|
||||||
|
|
||||||
|
if (bio->bi_blkg)
|
||||||
|
blkg_put(bio->bi_blkg);
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
|
if (css && css->parent)
|
||||||
if (!css || !css->parent)
|
|
||||||
blkg = q->root_blkg;
|
|
||||||
else
|
|
||||||
blkg = blkg_lookup_create(css_to_blkcg(css), q);
|
blkg = blkg_lookup_create(css_to_blkcg(css), q);
|
||||||
|
bio->bi_blkg = blkg_tryget_closest(blkg);
|
||||||
__bio_associate_blkg(bio, blkg);
|
|
||||||
|
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(bio_associate_blkg_from_css);
|
EXPORT_SYMBOL_GPL(bio_associate_blkg_from_css);
|
||||||
|
|
Loading…
Reference in New Issue