diff options
-rw-r--r-- | block/bio.c | 56 | ||||
-rw-r--r-- | block/bounce.c | 2 | ||||
-rw-r--r-- | drivers/block/loop.c | 5 | ||||
-rw-r--r-- | drivers/md/raid0.c | 2 | ||||
-rw-r--r-- | include/linux/bio.h | 9 | ||||
-rw-r--r-- | include/linux/blk-cgroup.h | 8 | ||||
-rw-r--r-- | include/linux/blk_types.h | 1 | ||||
-rw-r--r-- | kernel/trace/blktrace.c | 4 |
8 files changed, 25 insertions, 62 deletions
diff --git a/block/bio.c b/block/bio.c index 387480de6992..71cfe3720ea7 100644 --- a/block/bio.c +++ b/block/bio.c | |||
@@ -609,7 +609,7 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src) | |||
609 | bio->bi_iter = bio_src->bi_iter; | 609 | bio->bi_iter = bio_src->bi_iter; |
610 | bio->bi_io_vec = bio_src->bi_io_vec; | 610 | bio->bi_io_vec = bio_src->bi_io_vec; |
611 | 611 | ||
612 | bio_clone_blkcg_association(bio, bio_src); | 612 | bio_clone_blkg_association(bio, bio_src); |
613 | 613 | ||
614 | blkcg_bio_issue_init(bio); | 614 | blkcg_bio_issue_init(bio); |
615 | } | 615 | } |
@@ -1957,34 +1957,6 @@ EXPORT_SYMBOL(bioset_init_from_src); | |||
1957 | #ifdef CONFIG_BLK_CGROUP | 1957 | #ifdef CONFIG_BLK_CGROUP |
1958 | 1958 | ||
1959 | /** | 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 | |||
1987 | /** | ||
1988 | * bio_associate_blkg - associate a bio with the a blkg | 1960 | * bio_associate_blkg - associate a bio with the a blkg |
1989 | * @bio: target bio | 1961 | * @bio: target bio |
1990 | * @blkg: the blkg to associate | 1962 | * @blkg: the blkg to associate |
@@ -2033,7 +2005,6 @@ int bio_associate_blkg_from_css(struct bio *bio, | |||
2033 | struct cgroup_subsys_state *css) | 2005 | struct cgroup_subsys_state *css) |
2034 | { | 2006 | { |
2035 | css_get(css); | 2007 | css_get(css); |
2036 | bio->bi_css = css; | ||
2037 | return __bio_associate_blkg_from_css(bio, css); | 2008 | return __bio_associate_blkg_from_css(bio, css); |
2038 | } | 2009 | } |
2039 | EXPORT_SYMBOL_GPL(bio_associate_blkg_from_css); | 2010 | EXPORT_SYMBOL_GPL(bio_associate_blkg_from_css); |
@@ -2054,12 +2025,11 @@ int bio_associate_blkg_from_page(struct bio *bio, struct page *page) | |||
2054 | { | 2025 | { |
2055 | struct cgroup_subsys_state *css; | 2026 | struct cgroup_subsys_state *css; |
2056 | 2027 | ||
2057 | if (unlikely(bio->bi_css)) | 2028 | if (unlikely(bio->bi_blkg)) |
2058 | return -EBUSY; | 2029 | return -EBUSY; |
2059 | if (!page->mem_cgroup) | 2030 | if (!page->mem_cgroup) |
2060 | return 0; | 2031 | return 0; |
2061 | css = cgroup_get_e_css(page->mem_cgroup->css.cgroup, &io_cgrp_subsys); | 2032 | css = cgroup_get_e_css(page->mem_cgroup->css.cgroup, &io_cgrp_subsys); |
2062 | bio->bi_css = css; | ||
2063 | 2033 | ||
2064 | return __bio_associate_blkg_from_css(bio, css); | 2034 | return __bio_associate_blkg_from_css(bio, css); |
2065 | } | 2035 | } |
@@ -2085,8 +2055,7 @@ int bio_associate_create_blkg(struct request_queue *q, struct bio *bio) | |||
2085 | 2055 | ||
2086 | rcu_read_lock(); | 2056 | rcu_read_lock(); |
2087 | 2057 | ||
2088 | bio_associate_blkcg(bio, NULL); | 2058 | blkcg = css_to_blkcg(blkcg_get_css()); |
2089 | blkcg = bio_blkcg(bio); | ||
2090 | 2059 | ||
2091 | if (!blkcg->css.parent) { | 2060 | if (!blkcg->css.parent) { |
2092 | ret = bio_associate_blkg(bio, q->root_blkg); | 2061 | ret = bio_associate_blkg(bio, q->root_blkg); |
@@ -2110,30 +2079,27 @@ void bio_disassociate_task(struct bio *bio) | |||
2110 | put_io_context(bio->bi_ioc); | 2079 | put_io_context(bio->bi_ioc); |
2111 | bio->bi_ioc = NULL; | 2080 | bio->bi_ioc = NULL; |
2112 | } | 2081 | } |
2113 | if (bio->bi_css) { | ||
2114 | css_put(bio->bi_css); | ||
2115 | bio->bi_css = NULL; | ||
2116 | } | ||
2117 | if (bio->bi_blkg) { | 2082 | if (bio->bi_blkg) { |
2083 | /* a ref is always taken on css */ | ||
2084 | css_put(&bio_blkcg(bio)->css); | ||
2118 | blkg_put(bio->bi_blkg); | 2085 | blkg_put(bio->bi_blkg); |
2119 | bio->bi_blkg = NULL; | 2086 | bio->bi_blkg = NULL; |
2120 | } | 2087 | } |
2121 | } | 2088 | } |
2122 | 2089 | ||
2123 | /** | 2090 | /** |
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 |
2125 | * @dst: destination bio | 2092 | * @dst: destination bio |
2126 | * @src: source bio | 2093 | * @src: source bio |
2127 | */ | 2094 | */ |
2128 | void bio_clone_blkcg_association(struct bio *dst, struct bio *src) | 2095 | void bio_clone_blkg_association(struct bio *dst, struct bio *src) |
2129 | { | 2096 | { |
2130 | if (src->bi_css) | 2097 | if (src->bi_blkg) { |
2131 | WARN_ON(bio_associate_blkcg(dst, src->bi_css)); | 2098 | css_get(&bio_blkcg(src)->css); |
2132 | |||
2133 | if (src->bi_blkg) | ||
2134 | bio_associate_blkg(dst, src->bi_blkg); | 2099 | bio_associate_blkg(dst, src->bi_blkg); |
2100 | } | ||
2135 | } | 2101 | } |
2136 | EXPORT_SYMBOL_GPL(bio_clone_blkcg_association); | 2102 | EXPORT_SYMBOL_GPL(bio_clone_blkg_association); |
2137 | #endif /* CONFIG_BLK_CGROUP */ | 2103 | #endif /* CONFIG_BLK_CGROUP */ |
2138 | 2104 | ||
2139 | static void __init biovec_init_slabs(void) | 2105 | static void __init biovec_init_slabs(void) |
diff --git a/block/bounce.c b/block/bounce.c index 7a08703b1204..b30071ac4ec6 100644 --- a/block/bounce.c +++ b/block/bounce.c | |||
@@ -257,7 +257,7 @@ static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask, | |||
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | bio_clone_blkcg_association(bio, bio_src); | 260 | bio_clone_blkg_association(bio, bio_src); |
261 | 261 | ||
262 | blkcg_bio_issue_init(bio); | 262 | blkcg_bio_issue_init(bio); |
263 | 263 | ||
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index ea9debf59b22..abad6d15f956 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -77,6 +77,7 @@ | |||
77 | #include <linux/falloc.h> | 77 | #include <linux/falloc.h> |
78 | #include <linux/uio.h> | 78 | #include <linux/uio.h> |
79 | #include <linux/ioprio.h> | 79 | #include <linux/ioprio.h> |
80 | #include <linux/blk-cgroup.h> | ||
80 | 81 | ||
81 | #include "loop.h" | 82 | #include "loop.h" |
82 | 83 | ||
@@ -1760,8 +1761,8 @@ static blk_status_t loop_queue_rq(struct blk_mq_hw_ctx *hctx, | |||
1760 | 1761 | ||
1761 | /* always use the first bio's css */ | 1762 | /* always use the first bio's css */ |
1762 | #ifdef CONFIG_BLK_CGROUP | 1763 | #ifdef CONFIG_BLK_CGROUP |
1763 | if (cmd->use_aio && rq->bio && rq->bio->bi_css) { | 1764 | if (cmd->use_aio && rq->bio && rq->bio->bi_blkg) { |
1764 | cmd->css = rq->bio->bi_css; | 1765 | cmd->css = &bio_blkcg(rq->bio)->css; |
1765 | css_get(cmd->css); | 1766 | css_get(cmd->css); |
1766 | } else | 1767 | } else |
1767 | #endif | 1768 | #endif |
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index ac1cffd2a09b..f3fb5bb8c82a 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c | |||
@@ -542,7 +542,7 @@ static void raid0_handle_discard(struct mddev *mddev, struct bio *bio) | |||
542 | !discard_bio) | 542 | !discard_bio) |
543 | continue; | 543 | continue; |
544 | bio_chain(discard_bio, bio); | 544 | bio_chain(discard_bio, bio); |
545 | bio_clone_blkcg_association(discard_bio, bio); | 545 | bio_clone_blkg_association(discard_bio, bio); |
546 | if (mddev->gendisk) | 546 | if (mddev->gendisk) |
547 | trace_block_bio_remap(bdev_get_queue(rdev->bdev), | 547 | trace_block_bio_remap(bdev_get_queue(rdev->bdev), |
548 | discard_bio, disk_devt(mddev->gendisk), | 548 | discard_bio, disk_devt(mddev->gendisk), |
diff --git a/include/linux/bio.h b/include/linux/bio.h index c73a870ebc0e..e973876625a8 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
@@ -540,24 +540,21 @@ static inline int bio_associate_blkg_from_page(struct bio *bio, | |||
540 | #endif | 540 | #endif |
541 | 541 | ||
542 | #ifdef CONFIG_BLK_CGROUP | 542 | #ifdef CONFIG_BLK_CGROUP |
543 | int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css); | ||
544 | int bio_associate_blkg(struct bio *bio, struct blkcg_gq *blkg); | 543 | int bio_associate_blkg(struct bio *bio, struct blkcg_gq *blkg); |
545 | int bio_associate_blkg_from_css(struct bio *bio, | 544 | int bio_associate_blkg_from_css(struct bio *bio, |
546 | struct cgroup_subsys_state *css); | 545 | struct cgroup_subsys_state *css); |
547 | int bio_associate_create_blkg(struct request_queue *q, struct bio *bio); | 546 | int bio_associate_create_blkg(struct request_queue *q, struct bio *bio); |
548 | void bio_disassociate_task(struct bio *bio); | 547 | void bio_disassociate_task(struct bio *bio); |
549 | void bio_clone_blkcg_association(struct bio *dst, struct bio *src); | 548 | void bio_clone_blkg_association(struct bio *dst, struct bio *src); |
550 | #else /* CONFIG_BLK_CGROUP */ | 549 | #else /* CONFIG_BLK_CGROUP */ |
551 | static inline int bio_associate_blkcg(struct bio *bio, | ||
552 | struct cgroup_subsys_state *blkcg_css) { return 0; } | ||
553 | static inline int bio_associate_blkg_from_css(struct bio *bio, | 550 | static inline int bio_associate_blkg_from_css(struct bio *bio, |
554 | struct cgroup_subsys_state *css) | 551 | struct cgroup_subsys_state *css) |
555 | { return 0; } | 552 | { return 0; } |
556 | static inline int bio_associate_create_blkg(struct request_queue *q, | 553 | static inline int bio_associate_create_blkg(struct request_queue *q, |
557 | struct bio *bio) { return 0; } | 554 | struct bio *bio) { return 0; } |
558 | static inline void bio_disassociate_task(struct bio *bio) { } | 555 | static inline void bio_disassociate_task(struct bio *bio) { } |
559 | static inline void bio_clone_blkcg_association(struct bio *dst, | 556 | static inline void bio_clone_blkg_association(struct bio *dst, |
560 | struct bio *src) { } | 557 | struct bio *src) { } |
561 | #endif /* CONFIG_BLK_CGROUP */ | 558 | #endif /* CONFIG_BLK_CGROUP */ |
562 | 559 | ||
563 | #ifdef CONFIG_HIGHMEM | 560 | #ifdef CONFIG_HIGHMEM |
diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index a6b6e741a75e..c41cfcc2b4d8 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h | |||
@@ -308,8 +308,8 @@ static inline struct blkcg *css_to_blkcg(struct cgroup_subsys_state *css) | |||
308 | */ | 308 | */ |
309 | static inline struct blkcg *__bio_blkcg(struct bio *bio) | 309 | static inline struct blkcg *__bio_blkcg(struct bio *bio) |
310 | { | 310 | { |
311 | if (bio && bio->bi_css) | 311 | if (bio && bio->bi_blkg) |
312 | return css_to_blkcg(bio->bi_css); | 312 | return bio->bi_blkg->blkcg; |
313 | return css_to_blkcg(blkcg_css()); | 313 | return css_to_blkcg(blkcg_css()); |
314 | } | 314 | } |
315 | 315 | ||
@@ -323,8 +323,8 @@ static inline struct blkcg *__bio_blkcg(struct bio *bio) | |||
323 | */ | 323 | */ |
324 | static inline struct blkcg *bio_blkcg(struct bio *bio) | 324 | static inline struct blkcg *bio_blkcg(struct bio *bio) |
325 | { | 325 | { |
326 | if (bio && bio->bi_css) | 326 | if (bio && bio->bi_blkg) |
327 | return css_to_blkcg(bio->bi_css); | 327 | return bio->bi_blkg->blkcg; |
328 | return NULL; | 328 | return NULL; |
329 | } | 329 | } |
330 | 330 | ||
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index f6dfb30737d8..9578c7ab1eb6 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h | |||
@@ -178,7 +178,6 @@ struct bio { | |||
178 | * release. Read comment on top of bio_associate_current(). | 178 | * release. Read comment on top of bio_associate_current(). |
179 | */ | 179 | */ |
180 | struct io_context *bi_ioc; | 180 | struct io_context *bi_ioc; |
181 | struct cgroup_subsys_state *bi_css; | ||
182 | struct blkcg_gq *bi_blkg; | 181 | struct blkcg_gq *bi_blkg; |
183 | struct bio_issue bi_issue; | 182 | struct bio_issue bi_issue; |
184 | #endif | 183 | #endif |
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 2868d85f1fb1..fac0ddf8a8e2 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
@@ -764,9 +764,9 @@ blk_trace_bio_get_cgid(struct request_queue *q, struct bio *bio) | |||
764 | if (!bt || !(blk_tracer_flags.val & TRACE_BLK_OPT_CGROUP)) | 764 | if (!bt || !(blk_tracer_flags.val & TRACE_BLK_OPT_CGROUP)) |
765 | return NULL; | 765 | return NULL; |
766 | 766 | ||
767 | if (!bio->bi_css) | 767 | if (!bio->bi_blkg) |
768 | return NULL; | 768 | return NULL; |
769 | return cgroup_get_kernfs_id(bio->bi_css->cgroup); | 769 | return cgroup_get_kernfs_id(bio_blkcg(bio)->css.cgroup); |
770 | } | 770 | } |
771 | #else | 771 | #else |
772 | static union kernfs_node_id * | 772 | static union kernfs_node_id * |