diff options
author | Tejun Heo <tj@kernel.org> | 2018-07-03 11:14:54 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-07-09 09:07:54 -0600 |
commit | 0d3bd88d54f513723602b361dccfc71639f50779 (patch) | |
tree | 349c7095f6e4faad0eadd64b516e80e1a0d3ef8d /block | |
parent | 0d1e0c7cd5909d6c6aa0957179318e13fcca971a (diff) | |
download | linux-stable-0d3bd88d54f513723602b361dccfc71639f50779.tar.gz linux-stable-0d3bd88d54f513723602b361dccfc71639f50779.tar.bz2 linux-stable-0d3bd88d54f513723602b361dccfc71639f50779.zip |
swap,blkcg: issue swap io with the appropriate context
For backcharging we need to know who the page belongs to when swapping
it out. We don't worry about things that do ->rw_page (zram etc) at the
moment, we're only worried about pages that actually go to a block
device.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r-- | block/bio.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/block/bio.c b/block/bio.c index 044571538574..5f84f5c3887b 100644 --- a/block/bio.c +++ b/block/bio.c @@ -2015,6 +2015,30 @@ EXPORT_SYMBOL(bioset_init_from_src); #ifdef CONFIG_BLK_CGROUP +#ifdef CONFIG_MEMCG +/** + * bio_associate_blkcg_from_page - associate a bio with the page's blkcg + * @bio: target bio + * @page: the page to lookup the blkcg from + * + * Associate @bio with the blkcg from @page's owning memcg. This works like + * every other associate function wrt references. + */ +int bio_associate_blkcg_from_page(struct bio *bio, struct page *page) +{ + struct cgroup_subsys_state *blkcg_css; + + if (unlikely(bio->bi_css)) + return -EBUSY; + if (!page->mem_cgroup) + return 0; + blkcg_css = cgroup_get_e_css(page->mem_cgroup->css.cgroup, + &io_cgrp_subsys); + bio->bi_css = blkcg_css; + return 0; +} +#endif /* CONFIG_MEMCG */ + /** * bio_associate_blkcg - associate a bio with the specified blkcg * @bio: target bio |