@@ -609,7 +609,7 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
609609 bio -> bi_iter = bio_src -> bi_iter ;
610610 bio -> bi_io_vec = bio_src -> bi_io_vec ;
611611
612- bio_clone_blkcg_association (bio , bio_src );
612+ bio_clone_blkg_association (bio , bio_src );
613613
614614 blkcg_bio_issue_init (bio );
615615}
@@ -1956,34 +1956,6 @@ EXPORT_SYMBOL(bioset_init_from_src);
19561956
19571957#ifdef CONFIG_BLK_CGROUP
19581958
1959- /**
1960- * bio_associate_blkcg - associate a bio with the specified blkcg
1961- * @bio: target bio
1962- * @blkcg_css: css of the blkcg to associate
1963- *
1964- * Associate @bio with the blkcg specified by @blkcg_css. Block layer will
1965- * treat @bio as if it were issued by a task which belongs to the blkcg.
1966- *
1967- * This function takes an extra reference of @blkcg_css which will be put
1968- * when @bio is released. The caller must own @bio and is responsible for
1969- * synchronizing calls to this function. If @blkcg_css is NULL, a call to
1970- * blkcg_get_css finds the current css from the kthread or task.
1971- */
1972- int bio_associate_blkcg (struct bio * bio , struct cgroup_subsys_state * blkcg_css )
1973- {
1974- if (unlikely (bio -> bi_css ))
1975- return - EBUSY ;
1976-
1977- if (blkcg_css )
1978- css_get (blkcg_css );
1979- else
1980- blkcg_css = blkcg_get_css ();
1981-
1982- bio -> bi_css = blkcg_css ;
1983- return 0 ;
1984- }
1985- EXPORT_SYMBOL_GPL (bio_associate_blkcg );
1986-
19871959/**
19881960 * bio_associate_blkg - associate a bio with the a blkg
19891961 * @bio: target bio
@@ -2033,7 +2005,6 @@ int bio_associate_blkg_from_css(struct bio *bio,
20332005 struct cgroup_subsys_state * css )
20342006{
20352007 css_get (css );
2036- bio -> bi_css = css ;
20372008 return __bio_associate_blkg_from_css (bio , css );
20382009}
20392010EXPORT_SYMBOL_GPL (bio_associate_blkg_from_css );
@@ -2054,12 +2025,11 @@ int bio_associate_blkg_from_page(struct bio *bio, struct page *page)
20542025{
20552026 struct cgroup_subsys_state * css ;
20562027
2057- if (unlikely (bio -> bi_css ))
2028+ if (unlikely (bio -> bi_blkg ))
20582029 return - EBUSY ;
20592030 if (!page -> mem_cgroup )
20602031 return 0 ;
20612032 css = cgroup_get_e_css (page -> mem_cgroup -> css .cgroup , & io_cgrp_subsys );
2062- bio -> bi_css = css ;
20632033
20642034 return __bio_associate_blkg_from_css (bio , css );
20652035}
@@ -2085,8 +2055,7 @@ int bio_associate_create_blkg(struct request_queue *q, struct bio *bio)
20852055
20862056 rcu_read_lock ();
20872057
2088- bio_associate_blkcg (bio , NULL );
2089- blkcg = bio_blkcg (bio );
2058+ blkcg = css_to_blkcg (blkcg_get_css ());
20902059
20912060 if (!blkcg -> css .parent ) {
20922061 ret = bio_associate_blkg (bio , q -> root_blkg );
@@ -2110,30 +2079,27 @@ void bio_disassociate_task(struct bio *bio)
21102079 put_io_context (bio -> bi_ioc );
21112080 bio -> bi_ioc = NULL ;
21122081 }
2113- if (bio -> bi_css ) {
2114- css_put (bio -> bi_css );
2115- bio -> bi_css = NULL ;
2116- }
21172082 if (bio -> bi_blkg ) {
2083+ /* a ref is always taken on css */
2084+ css_put (& bio_blkcg (bio )-> css );
21182085 blkg_put (bio -> bi_blkg );
21192086 bio -> bi_blkg = NULL ;
21202087 }
21212088}
21222089
21232090/**
2124- * bio_clone_blkcg_association - clone blkcg association from src to dst bio
2091+ * bio_clone_blkg_association - clone blkg association from src to dst bio
21252092 * @dst: destination bio
21262093 * @src: source bio
21272094 */
2128- void bio_clone_blkcg_association (struct bio * dst , struct bio * src )
2095+ void bio_clone_blkg_association (struct bio * dst , struct bio * src )
21292096{
2130- if (src -> bi_css )
2131- WARN_ON (bio_associate_blkcg (dst , src -> bi_css ));
2132-
2133- if (src -> bi_blkg )
2097+ if (src -> bi_blkg ) {
2098+ css_get (& bio_blkcg (src )-> css );
21342099 bio_associate_blkg (dst , src -> bi_blkg );
2100+ }
21352101}
2136- EXPORT_SYMBOL_GPL (bio_clone_blkcg_association );
2102+ EXPORT_SYMBOL_GPL (bio_clone_blkg_association );
21372103#endif /* CONFIG_BLK_CGROUP */
21382104
21392105static void __init biovec_init_slabs (void )
0 commit comments