From: Christoph Hellwig <hch@lst.de>
Date: Sat, 27 Jun 2020 09:31:50 +0200
Subject: [PATCH] block: move bio_associate_blkg_from_page to mm/page_io.c
References: bsc#1175995,jsc#SLE-15608
Git-commit: a18b9b1590ca64f877588700de32c9ad236f405c
Patch-mainline: v5.9-rc1
bio_associate_blkg_from_page is a special purpose helper for swap bios
that doesn't need access to bio internals. Move it to the swap code
instead of having it in bio.c.
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>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
block/bio.c | 26 --------------------------
include/linux/bio.h | 7 -------
mm/page_io.c | 17 +++++++++++++++++
3 files changed, 17 insertions(+), 33 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index e898267b8e30..c2bd8c031f11 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -2197,32 +2197,6 @@ void bio_associate_blkg_from_css(struct bio *bio,
}
EXPORT_SYMBOL_GPL(bio_associate_blkg_from_css);
-#ifdef CONFIG_MEMCG
-/**
- * bio_associate_blkg_from_page - associate a bio with the page's blkg
- * @bio: target bio
- * @page: the page to lookup the blkcg from
- *
- * Associate @bio with the blkg from @page's owning memcg and the respective
- * request_queue. If cgroup_e_css returns %NULL, fall back to the queue's
- * root_blkg.
- */
-void bio_associate_blkg_from_page(struct bio *bio, struct page *page)
-{
- struct cgroup_subsys_state *css;
-
- if (!page->mem_cgroup)
- return;
-
- rcu_read_lock();
-
- css = cgroup_e_css(page->mem_cgroup->css.cgroup, &io_cgrp_subsys);
- bio_associate_blkg_from_css(bio, css);
-
- rcu_read_unlock();
-}
-#endif /* CONFIG_MEMCG */
-
/**
* bio_associate_blkg - associate a bio with a blkg
* @bio: target bio
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 102024e18da6..c660baa6dbbb 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -502,13 +502,6 @@ do { \
#define bio_dev(bio) \
disk_devt((bio)->bi_disk)
-#if defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP)
-void bio_associate_blkg_from_page(struct bio *bio, struct page *page);
-#else
-static inline void bio_associate_blkg_from_page(struct bio *bio,
- struct page *page) { }
-#endif
-
#ifdef CONFIG_BLK_CGROUP
void bio_associate_blkg(struct bio *bio);
void bio_associate_blkg_from_css(struct bio *bio,
diff --git a/mm/page_io.c b/mm/page_io.c
index 3a198deb8bb1..85cc375241ba 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -275,6 +275,23 @@ static inline void count_swpout_vm_event(struct page *page)
count_vm_events(PSWPOUT, hpage_nr_pages(page));
}
+#if defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP)
+static void bio_associate_blkg_from_page(struct bio *bio, struct page *page)
+{
+ struct cgroup_subsys_state *css;
+
+ if (!page->mem_cgroup)
+ return;
+
+ rcu_read_lock();
+ css = cgroup_e_css(page->mem_cgroup->css.cgroup, &io_cgrp_subsys);
+ bio_associate_blkg_from_css(bio, css);
+ rcu_read_unlock();
+}
+#else
+#define bio_associate_blkg_from_page(bio, page) do { } while (0)
+#endif /* CONFIG_MEMCG && CONFIG_BLK_CGROUP */
+
int __swap_writepage(struct page *page, struct writeback_control *wbc,
bio_end_io_t end_write_func)
{
--
2.16.4