Message ID | 20241002150036.1339475-5-willy@infradead.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | nilfs2: Finish folio conversion | expand |
On Thu, Oct 3, 2024 at 12:00 AM Matthew Wilcox (Oracle) wrote: > > By implementing ->writepages instead of ->writepage, we remove a > layer of indirect function calls from the writeback path and the > last use of struct page in nilfs2. > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> > --- > fs/nilfs2/mdt.c | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) > > diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c > index ceb7dc0b5bad..4f4a935fcdc5 100644 > --- a/fs/nilfs2/mdt.c > +++ b/fs/nilfs2/mdt.c > @@ -396,10 +396,9 @@ int nilfs_mdt_fetch_dirty(struct inode *inode) > return test_bit(NILFS_I_DIRTY, &ii->i_state); > } > > -static int > -nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc) > +static int nilfs_mdt_write_folio(struct folio *folio, > + struct writeback_control *wbc) > { > - struct folio *folio = page_folio(page); > struct inode *inode = folio->mapping->host; > struct super_block *sb; > int err = 0; > @@ -432,11 +431,23 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc) > return err; > } > > +static int nilfs_mdt_writeback(struct address_space *mapping, > + struct writeback_control *wbc) > +{ > + struct folio *folio = NULL; > + int error; > + > + while ((folio = writeback_iter(mapping, wbc, folio, &error))) > + nilfs_mdt_write_folio(folio, wbc); In order to catch and return the error returned by nilfs_mdt_write_folio, I think it's necessary to assign the return value to the variable "error" in the loop as follows: + while ((folio = writeback_iter(mapping, wbc, folio, &error))) + error = nilfs_mdt_write_folio(folio, wbc); > + > + return error; > +} > > static const struct address_space_operations def_mdt_aops = { > .dirty_folio = block_dirty_folio, > .invalidate_folio = block_invalidate_folio, > - .writepage = nilfs_mdt_write_page, > + .writepages = nilfs_mdt_writeback, > + .migrate_folio = buffer_migrate_folio, > }; And, this also caused kernel panics with the fsstress command. As with patch 1/4, it was necessary to use buffer_migrate_folio_norefs for migrate_folio: + .migrate_folio = buffer_migrate_folio_norefs, Thanks, Ryusuke Konishi > > static const struct inode_operations def_mdt_iops; > -- > 2.43.0 >
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c index ceb7dc0b5bad..4f4a935fcdc5 100644 --- a/fs/nilfs2/mdt.c +++ b/fs/nilfs2/mdt.c @@ -396,10 +396,9 @@ int nilfs_mdt_fetch_dirty(struct inode *inode) return test_bit(NILFS_I_DIRTY, &ii->i_state); } -static int -nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc) +static int nilfs_mdt_write_folio(struct folio *folio, + struct writeback_control *wbc) { - struct folio *folio = page_folio(page); struct inode *inode = folio->mapping->host; struct super_block *sb; int err = 0; @@ -432,11 +431,23 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc) return err; } +static int nilfs_mdt_writeback(struct address_space *mapping, + struct writeback_control *wbc) +{ + struct folio *folio = NULL; + int error; + + while ((folio = writeback_iter(mapping, wbc, folio, &error))) + nilfs_mdt_write_folio(folio, wbc); + + return error; +} static const struct address_space_operations def_mdt_aops = { .dirty_folio = block_dirty_folio, .invalidate_folio = block_invalidate_folio, - .writepage = nilfs_mdt_write_page, + .writepages = nilfs_mdt_writeback, + .migrate_folio = buffer_migrate_folio, }; static const struct inode_operations def_mdt_iops;
By implementing ->writepages instead of ->writepage, we remove a layer of indirect function calls from the writeback path and the last use of struct page in nilfs2. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- fs/nilfs2/mdt.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)