mm/fs: convert inode_attach_wb() to take a folio

Patch series "Writeback folio conversions".

Remove more calls to compound_head() by passing folios around instead of
pages.


This patch (of 2):

The only caller of inode_attach_wb() which doesn't pass NULL already has a
folio, so convert the whole call-chain to take folios.

Link: https://lkml.kernel.org/r/20230116192507.2146150-1-willy@infradead.org
Link: https://lkml.kernel.org/r/20230116192507.2146150-2-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Matthew Wilcox (Oracle) 2023-01-16 19:25:06 +00:00 committed by Andrew Morton
parent 14ddee4126
commit 9cfb816b1c
3 changed files with 10 additions and 10 deletions

View file

@ -237,7 +237,7 @@ void wb_wait_for_completion(struct wb_completion *done)
static atomic_t isw_nr_in_flight = ATOMIC_INIT(0); static atomic_t isw_nr_in_flight = ATOMIC_INIT(0);
static struct workqueue_struct *isw_wq; static struct workqueue_struct *isw_wq;
void __inode_attach_wb(struct inode *inode, struct page *page) void __inode_attach_wb(struct inode *inode, struct folio *folio)
{ {
struct backing_dev_info *bdi = inode_to_bdi(inode); struct backing_dev_info *bdi = inode_to_bdi(inode);
struct bdi_writeback *wb = NULL; struct bdi_writeback *wb = NULL;
@ -245,8 +245,8 @@ void __inode_attach_wb(struct inode *inode, struct page *page)
if (inode_cgwb_enabled(inode)) { if (inode_cgwb_enabled(inode)) {
struct cgroup_subsys_state *memcg_css; struct cgroup_subsys_state *memcg_css;
if (page) { if (folio) {
memcg_css = mem_cgroup_css_from_page(page); memcg_css = mem_cgroup_css_from_page(&folio->page);
wb = wb_get_create(bdi, memcg_css, GFP_ATOMIC); wb = wb_get_create(bdi, memcg_css, GFP_ATOMIC);
} else { } else {
/* must pin memcg_css, see wb_get_create() */ /* must pin memcg_css, see wb_get_create() */

View file

@ -207,7 +207,7 @@ static inline void wait_on_inode(struct inode *inode)
#include <linux/cgroup.h> #include <linux/cgroup.h>
#include <linux/bio.h> #include <linux/bio.h>
void __inode_attach_wb(struct inode *inode, struct page *page); void __inode_attach_wb(struct inode *inode, struct folio *folio);
void wbc_attach_and_unlock_inode(struct writeback_control *wbc, void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
struct inode *inode) struct inode *inode)
__releases(&inode->i_lock); __releases(&inode->i_lock);
@ -222,16 +222,16 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb);
/** /**
* inode_attach_wb - associate an inode with its wb * inode_attach_wb - associate an inode with its wb
* @inode: inode of interest * @inode: inode of interest
* @page: page being dirtied (may be NULL) * @folio: folio being dirtied (may be NULL)
* *
* If @inode doesn't have its wb, associate it with the wb matching the * If @inode doesn't have its wb, associate it with the wb matching the
* memcg of @page or, if @page is NULL, %current. May be called w/ or w/o * memcg of @folio or, if @folio is NULL, %current. May be called w/ or w/o
* @inode->i_lock. * @inode->i_lock.
*/ */
static inline void inode_attach_wb(struct inode *inode, struct page *page) static inline void inode_attach_wb(struct inode *inode, struct folio *folio)
{ {
if (!inode->i_wb) if (!inode->i_wb)
__inode_attach_wb(inode, page); __inode_attach_wb(inode, folio);
} }
/** /**
@ -290,7 +290,7 @@ static inline void wbc_init_bio(struct writeback_control *wbc, struct bio *bio)
#else /* CONFIG_CGROUP_WRITEBACK */ #else /* CONFIG_CGROUP_WRITEBACK */
static inline void inode_attach_wb(struct inode *inode, struct page *page) static inline void inode_attach_wb(struct inode *inode, struct folio *folio)
{ {
} }

View file

@ -2652,7 +2652,7 @@ static void folio_account_dirtied(struct folio *folio,
struct bdi_writeback *wb; struct bdi_writeback *wb;
long nr = folio_nr_pages(folio); long nr = folio_nr_pages(folio);
inode_attach_wb(inode, &folio->page); inode_attach_wb(inode, folio);
wb = inode_to_wb(inode); wb = inode_to_wb(inode);
__lruvec_stat_mod_folio(folio, NR_FILE_DIRTY, nr); __lruvec_stat_mod_folio(folio, NR_FILE_DIRTY, nr);