summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorDennis Zhou <dennis@kernel.org>2018-12-05 12:10:35 -0500
committerJens Axboe <axboe@kernel.dk>2018-12-08 00:26:37 -0500
commitdb6638d7d177a8bc74c9e539e2e0d7d061c767b1 (patch)
tree4d797db1677ed41d4c59857f680ef05ff1902b07 /block
parentfd42df305f804ddc0d5ac028e944784283b2f92d (diff)
blkcg: remove bio->bi_css and instead use bio->bi_blkg
Prior patches ensured that any bio that interacts with a request_queue is properly associated with a blkg. This makes bio->bi_css unnecessary as blkg maintains a reference to blkcg already. This removes the bio field bi_css and transfers corresponding uses to access via bi_blkg. Signed-off-by: Dennis Zhou <dennis@kernel.org> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/bio.c59
-rw-r--r--block/bounce.c2
2 files changed, 14 insertions, 47 deletions
diff --git a/block/bio.c b/block/bio.c
index b42477b6a225..2b6bc7b805ec 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -610,7 +610,7 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
610 bio->bi_iter = bio_src->bi_iter; 610 bio->bi_iter = bio_src->bi_iter;
611 bio->bi_io_vec = bio_src->bi_io_vec; 611 bio->bi_io_vec = bio_src->bi_io_vec;
612 612
613 bio_clone_blkcg_association(bio, bio_src); 613 bio_clone_blkg_association(bio, bio_src);
614 blkcg_bio_issue_init(bio); 614 blkcg_bio_issue_init(bio);
615} 615}
616EXPORT_SYMBOL(__bio_clone_fast); 616EXPORT_SYMBOL(__bio_clone_fast);
@@ -1958,34 +1958,6 @@ EXPORT_SYMBOL(bioset_init_from_src);
1958#ifdef CONFIG_BLK_CGROUP 1958#ifdef CONFIG_BLK_CGROUP
1959 1959
1960/** 1960/**
1961 * bio_associate_blkcg - associate a bio with the specified blkcg
1962 * @bio: target bio
1963 * @blkcg_css: css of the blkcg to associate
1964 *
1965 * Associate @bio with the blkcg specified by @blkcg_css. Block layer will
1966 * treat @bio as if it were issued by a task which belongs to the blkcg.
1967 *
1968 * This function takes an extra reference of @blkcg_css which will be put
1969 * when @bio is released. The caller must own @bio and is responsible for
1970 * synchronizing calls to this function. If @blkcg_css is %NULL, a call to
1971 * blkcg_get_css() finds the current css from the kthread or task.
1972 */
1973int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css)
1974{
1975 if (unlikely(bio->bi_css))
1976 return -EBUSY;
1977
1978 if (blkcg_css)
1979 css_get(blkcg_css);
1980 else
1981 blkcg_css = blkcg_get_css();
1982
1983 bio->bi_css = blkcg_css;
1984 return 0;
1985}
1986EXPORT_SYMBOL_GPL(bio_associate_blkcg);
1987
1988/**
1989 * bio_disassociate_blkg - puts back the blkg reference if associated 1961 * bio_disassociate_blkg - puts back the blkg reference if associated
1990 * @bio: target bio 1962 * @bio: target bio
1991 * 1963 *
@@ -1994,6 +1966,8 @@ EXPORT_SYMBOL_GPL(bio_associate_blkcg);
1994void bio_disassociate_blkg(struct bio *bio) 1966void bio_disassociate_blkg(struct bio *bio)
1995{ 1967{
1996 if (bio->bi_blkg) { 1968 if (bio->bi_blkg) {
1969 /* a ref is always taken on css */
1970 css_put(&bio_blkcg(bio)->css);
1997 blkg_put(bio->bi_blkg); 1971 blkg_put(bio->bi_blkg);
1998 bio->bi_blkg = NULL; 1972 bio->bi_blkg = NULL;
1999 } 1973 }
@@ -2047,7 +2021,6 @@ void bio_associate_blkg_from_css(struct bio *bio,
2047 struct cgroup_subsys_state *css) 2021 struct cgroup_subsys_state *css)
2048{ 2022{
2049 css_get(css); 2023 css_get(css);
2050 bio->bi_css = css;
2051 __bio_associate_blkg_from_css(bio, css); 2024 __bio_associate_blkg_from_css(bio, css);
2052} 2025}
2053EXPORT_SYMBOL_GPL(bio_associate_blkg_from_css); 2026EXPORT_SYMBOL_GPL(bio_associate_blkg_from_css);
@@ -2066,13 +2039,10 @@ void bio_associate_blkg_from_page(struct bio *bio, struct page *page)
2066{ 2039{
2067 struct cgroup_subsys_state *css; 2040 struct cgroup_subsys_state *css;
2068 2041
2069 if (unlikely(bio->bi_css))
2070 return;
2071 if (!page->mem_cgroup) 2042 if (!page->mem_cgroup)
2072 return; 2043 return;
2073 2044
2074 css = cgroup_get_e_css(page->mem_cgroup->css.cgroup, &io_cgrp_subsys); 2045 css = cgroup_get_e_css(page->mem_cgroup->css.cgroup, &io_cgrp_subsys);
2075 bio->bi_css = css;
2076 __bio_associate_blkg_from_css(bio, css); 2046 __bio_associate_blkg_from_css(bio, css);
2077} 2047}
2078#endif /* CONFIG_MEMCG */ 2048#endif /* CONFIG_MEMCG */
@@ -2094,8 +2064,10 @@ void bio_associate_blkg(struct bio *bio)
2094 2064
2095 rcu_read_lock(); 2065 rcu_read_lock();
2096 2066
2097 bio_associate_blkcg(bio, NULL); 2067 if (bio->bi_blkg)
2098 blkcg = bio_blkcg(bio); 2068 blkcg = bio->bi_blkg->blkcg;
2069 else
2070 blkcg = css_to_blkcg(blkcg_get_css());
2099 2071
2100 if (!blkcg->css.parent) { 2072 if (!blkcg->css.parent) {
2101 __bio_associate_blkg(bio, q->root_blkg); 2073 __bio_associate_blkg(bio, q->root_blkg);
@@ -2115,27 +2087,22 @@ EXPORT_SYMBOL_GPL(bio_associate_blkg);
2115 */ 2087 */
2116void bio_disassociate_task(struct bio *bio) 2088void bio_disassociate_task(struct bio *bio)
2117{ 2089{
2118 if (bio->bi_css) {
2119 css_put(bio->bi_css);
2120 bio->bi_css = NULL;
2121 }
2122 bio_disassociate_blkg(bio); 2090 bio_disassociate_blkg(bio);
2123} 2091}
2124 2092
2125/** 2093/**
2126 * bio_clone_blkcg_association - clone blkcg association from src to dst bio 2094 * bio_clone_blkg_association - clone blkg association from src to dst bio
2127 * @dst: destination bio 2095 * @dst: destination bio
2128 * @src: source bio 2096 * @src: source bio
2129 */ 2097 */
2130void bio_clone_blkcg_association(struct bio *dst, struct bio *src) 2098void bio_clone_blkg_association(struct bio *dst, struct bio *src)
2131{ 2099{
2132 if (src->bi_css) 2100 if (src->bi_blkg) {
2133 WARN_ON(bio_associate_blkcg(dst, src->bi_css)); 2101 css_get(&bio_blkcg(src)->css);
2134
2135 if (src->bi_blkg)
2136 __bio_associate_blkg(dst, src->bi_blkg); 2102 __bio_associate_blkg(dst, src->bi_blkg);
2103 }
2137} 2104}
2138EXPORT_SYMBOL_GPL(bio_clone_blkcg_association); 2105EXPORT_SYMBOL_GPL(bio_clone_blkg_association);
2139#endif /* CONFIG_BLK_CGROUP */ 2106#endif /* CONFIG_BLK_CGROUP */
2140 2107
2141static void __init biovec_init_slabs(void) 2108static void __init biovec_init_slabs(void)
diff --git a/block/bounce.c b/block/bounce.c
index cfb96d5170d0..ffb9e9ecfa7e 100644
--- a/block/bounce.c
+++ b/block/bounce.c
@@ -277,7 +277,7 @@ static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask,
277 } 277 }
278 } 278 }
279 279
280 bio_clone_blkcg_association(bio, bio_src); 280 bio_clone_blkg_association(bio, bio_src);
281 blkcg_bio_issue_init(bio); 281 blkcg_bio_issue_init(bio);
282 282
283 return bio; 283 return bio;