nilfs2: Folio conversions for file paths
Ryusuke Konishi
maintainercover nilfs2: Folio conversions for file paths
Hi Andrew, please queue this series for the next merge window.
This series advances page->folio conversions for a wide range of nilfs2, including its file operations, block routines, and the log writer's writeback routines. It doesn't cover large folios support, but it saves a lot of hidden compound_head() calls while preserving the existing support range behavior.
The original series in post [1] also covered directory-related page->folio conversions, but that was put on hold because a regression was found in testing, so this is an excerpt from the first half of the original post.
[1] https://lkml.kernel.org/r/[email protected]
I tested this series in both 32-bit and 64-bit environments, switching between normal and small block sizes. I also reviewed all changes in all patches to ensure they do not break existing behavior.
There were no problems, so I'm sending this part first because I would like you to keep it in the -mm tree at an early stage.
Thanks,
Ryusuke Konishi
Matthew Wilcox (Oracle) (20):
nilfs2: Add nilfs_end_folio_io()
nilfs2: Convert nilfs_abort_logs to use folios
nilfs2: Convert nilfs_segctor_complete_write to use folios
nilfs2: Convert nilfs_forget_buffer to use a folio
nilfs2: Convert to nilfs_folio_buffers_clean()
nilfs2: Convert nilfs_writepage() to use a folio
nilfs2: Convert nilfs_mdt_write_page() to use a folio
nilfs2: Convert to nilfs_clear_folio_dirty()
nilfs2: Convert to __nilfs_clear_folio_dirty()
nilfs2: Convert nilfs_segctor_prepare_write to use folios
nilfs2: Convert nilfs_page_mkwrite() to use a folio
nilfs2: Convert nilfs_mdt_create_block to use a folio
nilfs2: Convert nilfs_mdt_submit_block to use a folio
nilfs2: Convert nilfs_gccache_submit_read_data to use a folio
nilfs2: Convert nilfs_btnode_create_block to use a folio
nilfs2: Convert nilfs_btnode_submit_block to use a folio
nilfs2: Convert nilfs_btnode_delete to use a folio
nilfs2: Convert nilfs_btnode_prepare_change_key to use a folio
nilfs2: Convert nilfs_btnode_commit_change_key to use a folio
nilfs2: Convert nilfs_btnode_abort_change_key to use a folio
fs/nilfs2/btnode.c | 62 ++++++++--------- fs/nilfs2/file.c | 28 ++++---- fs/nilfs2/gcinode.c | 4 +- fs/nilfs2/inode.c | 11 ++-- fs/nilfs2/mdt.c | 23 +++---- fs/nilfs2/page.c | 68 +++++++++---------- fs/nilfs2/page.h | 6 +- fs/nilfs2/segment.c | 157 ++++++++++++++++++++++---------------------- 8 files changed, 183 insertions(+), 176 deletions(-)
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 1/20 nilfs2: Add nilfs_end_folio_io()
From: "Matthew Wilcox (Oracle)" <[email protected]>
This is the folio counterpart of the existing nilfs_end_page_io() which is retained as a wrapper of nilfs_end_folio_io(). Replaces nine hidden calls to compound_head() with one.
--- fs/nilfs2/segment.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
fs/nilfs2/segment.c +22 -14
@@ -1739,17 +1739,18 @@ static int nilfs_segctor_write(struct nilfs_sc_info *sci,return ret; } -static void nilfs_end_page_io (struct page *page,int err) +static void nilfs_end_folio_io (struct folio *folio,int err) { -if (!page) +if (!folio)return ; -if (buffer_nilfs_node (page_buffers (page)) && !PageWriteback (page)) { +if (buffer_nilfs_node (folio_buffers (folio)) && + !folio_test_writeback (folio)) {/* * For b-tree node pages, this function may be called twice * or more because they might be split in a segment. */ -if (PageDirty (page)) { +if (folio_test_dirty (folio)) {/* * For pages holding split b-tree node buffers, dirty * flag on the buffers may be cleared discretely.
@@ -1757,24 +1758,31 @@ static void nilfs_end_page_io(struct page *page, int err)* remaining buffers, and it must be cancelled if * all the buffers get cleaned later. */ -lock_page (page); -if (nilfs_page_buffers_clean (page)) -__nilfs_clear_page_dirty (page); -unlock_page (page); +folio_lock (folio); +if (nilfs_page_buffers_clean (&folio->page)) +__nilfs_clear_page_dirty (&folio->page); +folio_unlock (folio); }return ; }if (!err) { -if (!nilfs_page_buffers_clean (page)) -__set_page_dirty_nobuffers (page); -ClearPageError (page); +if (!nilfs_page_buffers_clean (&folio->page)) +filemap_dirty_folio (folio->mapping, folio); +folio_clear_error (folio); }else { -__set_page_dirty_nobuffers (page); -SetPageError (page); +filemap_dirty_folio (folio->mapping, folio); +folio_set_error (folio); } -end_page_writeback (page); +folio_end_writeback (folio); +} + +static void nilfs_end_page_io (struct page *page,int err) +{ +if (!page) +return ; +nilfs_end_folio_io (page_folio (page), err); }static void nilfs_abort_logs (struct list_head *logs,int err)
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 2/20 nilfs2: Convert nilfs_abort_logs to use folios
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Use the new folio APIs, saving five hidden calls to compound_head().
--- fs/nilfs2/segment.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
fs/nilfs2/segment.c +14 -14
@@ -1788,7 +1788,7 @@ static void nilfs_end_page_io(struct page *page, int err)static void nilfs_abort_logs (struct list_head *logs,int err) {struct nilfs_segment_buffer *segbuf; -struct page *bd_page =NULL , *fs_page =NULL ; +struct folio *bd_folio =NULL , *fs_folio =NULL ;struct buffer_head *bh;if (list_empty (logs))
@@ -1798,10 +1798,10 @@ static void nilfs_abort_logs(struct list_head *logs, int err)list_for_each_entry (bh, &segbuf->sb_segsum_buffers, b_assoc_buffers) {clear_buffer_uptodate (bh); -if (bh->b_page != bd_page) { -if (bd_page) -end_page_writeback (bd_page); - bd_page = bh->b_page; +if (bh->b_folio != bd_folio) { +if (bd_folio) +folio_end_writeback (bd_folio); + bd_folio = bh->b_folio; } }
@@ -1810,22 +1810,22 @@ static void nilfs_abort_logs(struct list_head *logs, int err)clear_buffer_async_write (bh);if (bh == segbuf->sb_super_root) {clear_buffer_uptodate (bh); -if (bh->b_page != bd_page) { -end_page_writeback (bd_page); - bd_page = bh->b_page; +if (bh->b_folio != bd_folio) { +folio_end_writeback (bd_folio); + bd_folio = bh->b_folio; }break ; } -if (bh->b_page != fs_page) { -nilfs_end_page_io (fs_page, err); - fs_page = bh->b_page; +if (bh->b_folio != fs_folio) { +nilfs_end_folio_io (fs_folio, err); + fs_folio = bh->b_folio; } } } -if (bd_page) -end_page_writeback (bd_page); +if (bd_folio) +folio_end_writeback (bd_folio); -nilfs_end_page_io (fs_page, err); +nilfs_end_folio_io (fs_folio, err); } static void nilfs_segctor_abort_construction(struct nilfs_sc_info *sci,
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 3/20 nilfs2: Convert nilfs_segctor_complete_write to use folios
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Use the new folio APIs, saving five calls to compound_head(). This includes the last callers of nilfs_end_page_io(), so remove that too.
--- fs/nilfs2/segment.c | 49 +++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 28 deletions(-)
fs/nilfs2/segment.c +21 -28
@@ -1778,13 +1778,6 @@ static void nilfs_end_folio_io(struct folio *folio, int err)folio_end_writeback (folio); } -static void nilfs_end_page_io (struct page *page,int err) -{ -if (!page) -return ; -nilfs_end_folio_io (page_folio (page), err); -} -static void nilfs_abort_logs (struct list_head *logs,int err) {struct nilfs_segment_buffer *segbuf;
@@ -1867,7 +1860,7 @@ static void nilfs_set_next_segment(struct the_nilfs *nilfs,static void nilfs_segctor_complete_write (struct nilfs_sc_info *sci) {struct nilfs_segment_buffer *segbuf; -struct page *bd_page =NULL , *fs_page =NULL ; +struct folio *bd_folio =NULL , *fs_folio =NULL ;struct the_nilfs *nilfs = sci->sc_super->s_fs_info;int update_sr = false;
@@ -1878,21 +1871,21 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci) b_assoc_buffers) {set_buffer_uptodate (bh );clear_buffer_dirty (bh); -if (bh->b_page != bd_page) { -if (bd_page) -end_page_writeback (bd_page); - bd_page = bh->b_page; +if (bh->b_folio != bd_folio) { +if (bd_folio) +folio_end_writeback (bd_folio); + bd_folio = bh->b_folio; } }/* -* We assume that the buffers which belong to the same page +* We assume that the buffers which belong to the same folio * continue over the buffer list. -* Under this assumption, the last BHs of pages is -* identifiable by the discontinuity of bh->b_page -* (page != fs_page). +* Under this assumption, the last BHs of folios is +* identifiable by the discontinuity of bh->b_folio +* (folio != fs_folio). * * For B-tree node blocks, however, this assumption is not -* guaranteed. The cleanup code of B-tree node pages needs +* guaranteed. The cleanup code of B-tree node folios needs * special care. */ list_for_each_entry(bh, &segbuf->sb_payload_buffers,
@@ -1905,16 +1898,16 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)set_mask_bits (&bh->b_state, clear_bits, set_bits);if (bh == segbuf->sb_super_root) { -if (bh->b_page != bd_page) { -end_page_writeback (bd_page); - bd_page = bh->b_page; +if (bh->b_folio != bd_folio) { +folio_end_writeback (bd_folio); + bd_folio = bh->b_folio; } update_sr = true;break ; } -if (bh->b_page != fs_page) { -nilfs_end_page_io (fs_page,0 ); - fs_page = bh->b_page; +if (bh->b_folio != fs_folio) { +nilfs_end_folio_io (fs_folio,0 ); + fs_folio = bh->b_folio; } }
@@ -1928,13 +1921,13 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci) } }/* -* Since pages may continue over multiple segment buffers, -* end of the last page must be checked outside of the loop. +* Since folios may continue over multiple segment buffers, +* end of the last folio must be checked outside of the loop. */ -if (bd_page) -end_page_writeback (bd_page); +if (bd_folio) +folio_end_writeback (bd_folio); -nilfs_end_page_io (fs_page,0 ); +nilfs_end_folio_io (fs_folio,0 );nilfs_drop_collected_inodes (&sci->sc_dirty_files);
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 4/20 nilfs2: Convert nilfs_forget_buffer to use a folio
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Save two hidden calls to compound_head().
--- fs/nilfs2/page.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/nilfs2/page.c +5 -5
@@ -73,7 +73,7 @@ struct buffer_head *nilfs_grab_buffer(struct inode *inode,*/ void nilfs_forget_buffer (struct buffer_head *bh) { -struct page *page = bh->b_page; +struct folio *folio = bh->b_folio; const unsigned long clear_bits = (BIT(BH_Uptodate) | BIT(BH_Dirty) | BIT(BH_Mapped) | BIT(BH_Async_Write) | BIT(BH_NILFS_Volatile) |
@@ -81,12 +81,12 @@ void nilfs_forget_buffer(struct buffer_head *bh)lock_buffer (bh);set_mask_bits (&bh->b_state, clear_bits,0 ); -if (nilfs_page_buffers_clean (page)) -__nilfs_clear_page_dirty (page); +if (nilfs_page_buffers_clean (&folio->page)) +__nilfs_clear_page_dirty (&folio->page); bh->b_blocknr =-1 ; -ClearPageUptodate (page); -ClearPageMappedToDisk (page); +folio_clear_uptodate (folio); +folio_clear_mappedtodisk (folio);unlock_buffer (bh);brelse (bh); }
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 5/20 nilfs2: Convert to nilfs_folio_buffers_clean()
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
All callers of nilfs_page_buffers_clean() now have a folio, so convert it to take a folio. While I'm at it, make it return a bool.
--- fs/nilfs2/page.c | 18 +++++++++--------- fs/nilfs2/page.h | 2 +- fs/nilfs2/segment.c | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-)
fs/nilfs2/page.c +9 -9
@@ -81,7 +81,7 @@ void nilfs_forget_buffer(struct buffer_head *bh)lock_buffer (bh);set_mask_bits (&bh->b_state, clear_bits,0 ); -if (nilfs_page_buffers_clean (&folio->page)) +if (nilfs_folio_buffers_clean (folio))__nilfs_clear_page_dirty (&folio->page); bh->b_blocknr =-1 ;
@@ -131,23 +131,23 @@ void nilfs_copy_buffer(struct buffer_head *dbh, struct buffer_head *sbh) }/** -* nilfs_page_buffers_clean - check if a page has dirty buffers or not. -* @page: page to be checked +* nilfs_folio_buffers_clean - Check if a folio has dirty buffers or not. +* @folio: Folio to be checked. * -* nilfs_page_buffers_clean() returns zero if the page has dirty buffers. -* Otherwise, it returns non-zero value. +* nilfs_folio_buffers_clean() returns false if the folio has dirty buffers. +* Otherwise, it returns true. */ -int nilfs_page_buffers_clean (struct page *page) +bool nilfs_folio_buffers_clean (struct folio *folio) {struct buffer_head *bh, *head; - bh = head =page_buffers (page); + bh = head =folio_buffers (folio);do {if (buffer_dirty (bh)) -return 0 ; +return false; bh = bh->b_this_page; }while (bh != head); -return 1 ; +return true; }void nilfs_page_bug (struct page *page)
fs/nilfs2/page.h +1 -1
@@ -36,7 +36,7 @@ struct buffer_head *nilfs_grab_buffer(struct inode *, struct address_space *, unsigned long, unsigned long);void nilfs_forget_buffer (struct buffer_head *);void nilfs_copy_buffer (struct buffer_head *,struct buffer_head *); -int nilfs_page_buffers_clean (struct page *); +bool nilfs_folio_buffers_clean (struct folio *);void nilfs_page_bug (struct page *);int nilfs_copy_dirty_pages (struct address_space *,struct address_space *);
fs/nilfs2/segment.c +2 -2
@@ -1759,7 +1759,7 @@ static void nilfs_end_folio_io(struct folio *folio, int err)* all the buffers get cleaned later. */ folio_lock (folio); -if (nilfs_page_buffers_clean (&folio->page)) +if (nilfs_folio_buffers_clean (folio))__nilfs_clear_page_dirty (&folio->page);folio_unlock (folio); }
@@ -1767,7 +1767,7 @@ static void nilfs_end_folio_io(struct folio *folio, int err) }if (!err) { -if (!nilfs_page_buffers_clean (&folio->page)) +if (!nilfs_folio_buffers_clean (folio))filemap_dirty_folio (folio->mapping, folio);folio_clear_error (folio); }else {
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 6/20 nilfs2: Convert nilfs_writepage() to use a folio
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Convert the incoming page to a folio. Replaces three calls to compound_head() with one.
--- fs/nilfs2/inode.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/nilfs2/inode.c +5 -4
@@ -175,7 +175,8 @@ static int nilfs_writepages(struct address_space *mapping,static int nilfs_writepage (struct page *page,struct writeback_control *wbc) { -struct inode *inode = page->mapping->host; +struct folio *folio =page_folio (page); +struct inode *inode = folio->mapping->host;int err;if (sb_rdonly (inode->i_sb)) {
@@ -186,12 +187,12 @@ static int nilfs_writepage(struct page *page, struct writeback_control *wbc)* So, here we simply discard this dirty page. */ nilfs_clear_dirty_page (page, false); -unlock_page (page); +folio_unlock (folio);return -EROFS ; } -redirty_page_for_writepage (wbc, page); -unlock_page (page); +folio_redirty_for_writepage (wbc, folio); +folio_unlock (folio);if (wbc->sync_mode ==WB_SYNC_ALL ) { err =nilfs_construct_segment (inode->i_sb);
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 7/20 nilfs2: Convert nilfs_mdt_write_page() to use a folio
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Convert the incoming page to a folio. Replaces three calls to compound_head() with one.
--- fs/nilfs2/mdt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
fs/nilfs2/mdt.c +7 -6
@@ -399,7 +399,8 @@ int nilfs_mdt_fetch_dirty(struct inode *inode)static int nilfs_mdt_write_page (struct page *page,struct writeback_control *wbc) { -struct inode *inode = page->mapping->host; +struct folio *folio =page_folio (page); +struct inode *inode = folio->mapping->host;struct super_block *sb;int err =0 ;
@@ -407,16 +408,16 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc)/* * It means that filesystem was remounted in read-only * mode because of error or metadata corruption. But we -* have dirty pages that try to be flushed in background. -* So, here we simply discard this dirty page. +* have dirty folios that try to be flushed in background. +* So, here we simply discard this dirty folio. */ nilfs_clear_dirty_page (page, false); -unlock_page (page); +folio_unlock (folio);return -EROFS ; } -redirty_page_for_writepage (wbc, page); -unlock_page (page); +folio_redirty_for_writepage (wbc, folio); +folio_unlock (folio);if (!inode)return 0 ;
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 8/20 nilfs2: Convert to nilfs_clear_folio_dirty()
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
All callers of nilfs_clear_dirty_page() now have a folio, so rename the function and pass in the folio. Saves three hidden calls to compound_head().
--- fs/nilfs2/inode.c | 2 +- fs/nilfs2/mdt.c | 2 +- fs/nilfs2/page.c | 27 ++++++++++++++------------- fs/nilfs2/page.h | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-)
fs/nilfs2/inode.c +1 -1
@@ -186,7 +186,7 @@ static int nilfs_writepage(struct page *page, struct writeback_control *wbc)* have dirty pages that try to be flushed in background. * So, here we simply discard this dirty page. */ -nilfs_clear_dirty_page (page, false); +nilfs_clear_folio_dirty (folio, false);folio_unlock (folio);return -EROFS ; }
fs/nilfs2/mdt.c +1 -1
@@ -411,7 +411,7 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc)* have dirty folios that try to be flushed in background. * So, here we simply discard this dirty folio. */ -nilfs_clear_dirty_page (page, false); +nilfs_clear_folio_dirty (folio, false);folio_unlock (folio);return -EROFS ; }
fs/nilfs2/page.c +14 -13
@@ -379,7 +379,7 @@ void nilfs_clear_dirty_pages(struct address_space *mapping, bool silent)* was acquired. Skip processing in that case. */ if (likely (folio->mapping == mapping)) -nilfs_clear_dirty_page (&folio->page, silent); +nilfs_clear_folio_dirty (folio, silent);folio_unlock (folio); }
@@ -389,32 +389,33 @@ void nilfs_clear_dirty_pages(struct address_space *mapping, bool silent) }/** -* nilfs_clear_dirty_page - discard dirty page -* @page: dirty page that will be discarded +* nilfs_clear_folio_dirty - discard dirty folio +* @folio: dirty folio that will be discarded * @silent: suppress [true] or print [false] warning messages */ -void nilfs_clear_dirty_page (struct page *page,bool silent) +void nilfs_clear_folio_dirty (struct folio *folio,bool silent) { -struct inode *inode = page->mapping->host; +struct inode *inode = folio->mapping->host;struct super_block *sb = inode->i_sb; +struct buffer_head *bh, *head; -BUG_ON (!PageLocked (page)); +BUG_ON (!folio_test_locked (folio));if (!silent)nilfs_warn (sb,"discard dirty page: offset=%lld, ino=%lu" , -page_offset (page), inode->i_ino); +folio_pos (folio), inode->i_ino); -ClearPageUptodate (page); -ClearPageMappedToDisk (page); +folio_clear_uptodate (folio); +folio_clear_mappedtodisk (folio); -if (page_has_buffers (page)) { -struct buffer_head *bh, *head; + head =folio_buffers (folio); +if (head) {const unsigned long clear_bits = (BIT (BH_Uptodate) |BIT (BH_Dirty) |BIT (BH_Mapped) |BIT (BH_Async_Write) |BIT (BH_NILFS_Volatile) |BIT (BH_NILFS_Checked) |BIT (BH_NILFS_Redirected)); - bh = head =page_buffers (page); + bh = head; do { lock_buffer(bh); if (!silent)
@@ -427,7 +428,7 @@ void nilfs_clear_dirty_page(struct page *page, bool silent) }while (bh = bh->b_this_page, bh != head); } -__nilfs_clear_page_dirty (page); +__nilfs_clear_page_dirty (&folio->page); } unsigned int nilfs_page_count_clean_buffers(struct page *page,
fs/nilfs2/page.h +1 -1
@@ -41,7 +41,7 @@ void nilfs_page_bug(struct page *);int nilfs_copy_dirty_pages (struct address_space *,struct address_space *);void nilfs_copy_back_pages (struct address_space *,struct address_space *); -void nilfs_clear_dirty_page (struct page *,bool ); +void nilfs_clear_folio_dirty (struct folio *,bool );void nilfs_clear_dirty_pages (struct address_space *,bool );unsigned int nilfs_page_count_clean_buffers (struct page *,unsigned int ,unsigned int );
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 9/20 nilfs2: Convert to __nilfs_clear_folio_dirty()
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
All callers now have a folio, so convert to pass a folio. No caller uses the return value, so make it return void. Removes a couple of hidden calls to compound_head().
--- fs/nilfs2/page.c | 19 ++++++++++--------- fs/nilfs2/page.h | 2 +- fs/nilfs2/segment.c | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-)
fs/nilfs2/page.c +10 -9
@@ -82,7 +82,7 @@ void nilfs_forget_buffer(struct buffer_head *bh)lock_buffer (bh);set_mask_bits (&bh->b_state, clear_bits,0 );if (nilfs_folio_buffers_clean (folio)) -__nilfs_clear_page_dirty (&folio->page); +__nilfs_clear_folio_dirty (folio); bh->b_blocknr =-1 ;folio_clear_uptodate (folio);
@@ -428,7 +428,7 @@ void nilfs_clear_folio_dirty(struct folio *folio, bool silent) }while (bh = bh->b_this_page, bh != head); } -__nilfs_clear_page_dirty (&folio->page); +__nilfs_clear_folio_dirty (folio); } unsigned int nilfs_page_count_clean_buffers(struct page *page,
@@ -458,22 +458,23 @@ unsigned int nilfs_page_count_clean_buffers(struct page *page,* 2) Some B-tree operations like insertion or deletion may dispose buffers * in dirty state, and this needs to cancel the dirty state of their pages. */ -int __nilfs_clear_page_dirty (struct page *page) +void __nilfs_clear_folio_dirty (struct folio *folio) { -struct address_space *mapping = page->mapping; +struct address_space *mapping = folio->mapping;if (mapping) {xa_lock_irq (&mapping->i_pages); -if (test_bit (PG_dirty, &page->flags)) { -__xa_clear_mark (&mapping->i_pages,page_index (page), +if (folio_test_dirty (folio)) { +__xa_clear_mark (&mapping->i_pages, folio->index,PAGECACHE_TAG_DIRTY );xa_unlock_irq (&mapping->i_pages); -return clear_page_dirty_for_io (page); +folio_clear_dirty_for_io (folio); +return ; }xa_unlock_irq (&mapping->i_pages); -return 0 ; +return ; } -return TestClearPageDirty (page); +folio_clear_dirty (folio); }/**
fs/nilfs2/page.h +1 -1
@@ -30,7 +30,7 @@ BUFFER_FNS(NILFS_Checked, nilfs_checked) /* buffer is verified */ BUFFER_FNS(NILFS_Redirected, nilfs_redirected) /* redirected to a copy */ -int __nilfs_clear_page_dirty (struct page *); +void __nilfs_clear_folio_dirty (struct folio *);struct buffer_head *nilfs_grab_buffer (struct inode *,struct address_space *,unsigned long ,unsigned long );
fs/nilfs2/segment.c +1 -1
@@ -1760,7 +1760,7 @@ static void nilfs_end_folio_io(struct folio *folio, int err)*/ folio_lock (folio);if (nilfs_folio_buffers_clean (folio)) -__nilfs_clear_page_dirty (&folio->page); +__nilfs_clear_folio_dirty (folio);folio_unlock (folio); }return ;
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 10/20 nilfs2: Convert nilfs_segctor_prepare_write to use folios
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Use the new folio APIs, saving 17 hidden calls to compound_head().
--- fs/nilfs2/segment.c | 58 ++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 29 deletions(-)
fs/nilfs2/segment.c +29 -29
@@ -1665,39 +1665,39 @@ static int nilfs_segctor_assign(struct nilfs_sc_info *sci, int mode)return 0 ; } -static void nilfs_begin_page_io (struct page *page) +static void nilfs_begin_folio_io (struct folio *folio) { -if (!page ||PageWriteback (page)) +if (!folio ||folio_test_writeback (folio))/* * For split b-tree node pages, this function may be called * twice. We ignore the 2nd or later calls by this check. */ return ; -lock_page (page); -clear_page_dirty_for_io (page); -set_page_writeback (page); -unlock_page (page); +folio_lock (folio); +folio_clear_dirty_for_io (folio); +folio_start_writeback (folio); +folio_unlock (folio); }static void nilfs_segctor_prepare_write (struct nilfs_sc_info *sci) {struct nilfs_segment_buffer *segbuf; -struct page *bd_page =NULL , *fs_page =NULL ; +struct folio *bd_folio =NULL , *fs_folio =NULL ;list_for_each_entry (segbuf, &sci->sc_segbufs, sb_list) {struct buffer_head *bh;list_for_each_entry (bh, &segbuf->sb_segsum_buffers, b_assoc_buffers) { -if (bh->b_page != bd_page) { -if (bd_page) { -lock_page (bd_page); -clear_page_dirty_for_io (bd_page); -set_page_writeback (bd_page); -unlock_page (bd_page); +if (bh->b_folio != bd_folio) { +if (bd_folio) { +folio_lock (bd_folio); +folio_clear_dirty_for_io (bd_folio); +folio_start_writeback (bd_folio); +folio_unlock (bd_folio); } - bd_page = bh->b_page; + bd_folio = bh->b_folio; } }
@@ -1705,28 +1705,28 @@ static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci) b_assoc_buffers) {set_buffer_async_write (bh );if (bh == segbuf->sb_super_root) { -if (bh->b_page != bd_page) { -lock_page (bd_page); -clear_page_dirty_for_io (bd_page); -set_page_writeback (bd_page); -unlock_page (bd_page); - bd_page = bh->b_page; +if (bh->b_folio != bd_folio) { +folio_lock (bd_folio); +folio_clear_dirty_for_io (bd_folio); +folio_start_writeback (bd_folio); +folio_unlock (bd_folio); + bd_folio = bh->b_folio; }break ; } -if (bh->b_page != fs_page) { -nilfs_begin_page_io (fs_page); - fs_page = bh->b_page; +if (bh->b_folio != fs_folio) { +nilfs_begin_folio_io (fs_folio); + fs_folio = bh->b_folio; } } } -if (bd_page) { -lock_page (bd_page); -clear_page_dirty_for_io (bd_page); -set_page_writeback (bd_page); -unlock_page (bd_page); +if (bd_folio) { +folio_lock (bd_folio); +folio_clear_dirty_for_io (bd_folio); +folio_start_writeback (bd_folio); +folio_unlock (bd_folio); } -nilfs_begin_page_io (fs_page); +nilfs_begin_folio_io (fs_folio); } static int nilfs_segctor_write(struct nilfs_sc_info *sci,
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 11/20 nilfs2: Convert nilfs_page_mkwrite() to use a folio
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Using the new folio APIs saves seven hidden calls to compound_head().
--- fs/nilfs2/file.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
fs/nilfs2/file.c +15 -13
@@ -45,34 +45,36 @@ int nilfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)static vm_fault_t nilfs_page_mkwrite (struct vm_fault *vmf) {struct vm_area_struct *vma = vmf->vma; -struct page *page = vmf->page; +struct folio *folio =page_folio (vmf->page);struct inode *inode =file_inode (vma->vm_file);struct nilfs_transaction_info ti; +struct buffer_head *bh, *head;int ret =0 ;if (unlikely (nilfs_near_disk_full (inode->i_sb->s_fs_info)))return VM_FAULT_SIGBUS ;/* -ENOSPC */ sb_start_pagefault (inode->i_sb); -lock_page (page); -if (page->mapping != inode->i_mapping || -page_offset (page) >=i_size_read (inode) || !PageUptodate (page)) { -unlock_page (page); +folio_lock (folio); +if (folio->mapping != inode->i_mapping || +folio_pos (folio) >=i_size_read (inode) || + !folio_test_uptodate (folio)) { +folio_unlock (folio); ret = -EFAULT ;/* make the VM retry the fault */ goto out; }/* -* check to see if the page is mapped already (no holes) +* check to see if the folio is mapped already (no holes) */ -if (PageMappedToDisk (page)) +if (folio_test_mappedtodisk (folio)) goto mapped; -if (page_has_buffers (page)) { -struct buffer_head *bh, *head; + head =folio_buffers (folio); +if (head) {int fully_mapped =1 ; - bh = head =page_buffers (page); + bh = head; do { if (!buffer_mapped(bh)) { fully_mapped = 0;
@@ -81,11 +83,11 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) }while (bh = bh->b_this_page, bh != head);if (fully_mapped) { -SetPageMappedToDisk (page); +folio_set_mappedtodisk (folio); goto mapped; } } -unlock_page (page); +folio_unlock (folio);/* * fill hole blocks
@@ -105,7 +107,7 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf)nilfs_transaction_commit (inode->i_sb); mapped: -wait_for_stable_page (page); +folio_wait_stable (folio); out:sb_end_pagefault (inode->i_sb);return vmf_fs_error (ret);
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 12/20 nilfs2: Convert nilfs_mdt_create_block to use a folio
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Saves two calls to compound_head().
--- fs/nilfs2/mdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nilfs2/mdt.c +2 -2
@@ -97,8 +97,8 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block, } failed_bh: -unlock_page (bh->b_page); -put_page (bh->b_page); +folio_unlock (bh->b_folio); +folio_put (bh->b_folio);brelse (bh); failed_unlock:
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 13/20 nilfs2: Convert nilfs_mdt_submit_block to use a folio
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Saves two calls to compound_head().
--- fs/nilfs2/mdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nilfs2/mdt.c +2 -2
@@ -158,8 +158,8 @@ nilfs_mdt_submit_block(struct inode *inode, unsigned long blkoff, blk_opf_t opf, *out_bh = bh; failed_bh: -unlock_page (bh->b_page); -put_page (bh->b_page); +folio_unlock (bh->b_folio); +folio_put (bh->b_folio);brelse (bh); failed:return ret;
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 14/20 nilfs2: Convert nilfs_gccache_submit_read_data to use a folio
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Saves two calls to compound_head().
--- fs/nilfs2/gcinode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nilfs2/gcinode.c +2 -2
@@ -98,8 +98,8 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff, *out_bh = bh; failed: -unlock_page (bh->b_page); -put_page (bh->b_page); +folio_unlock (bh->b_folio); +folio_put (bh->b_folio);if (unlikely (err))brelse (bh);return err;
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 15/20 nilfs2: Convert nilfs_btnode_create_block to use a folio
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Saves two calls to compound_head().
--- fs/nilfs2/btnode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nilfs2/btnode.c +2 -2
@@ -64,8 +64,8 @@ nilfs_btnode_create_block(struct address_space *btnc, __u64 blocknr)set_buffer_mapped (bh);set_buffer_uptodate (bh); -unlock_page (bh->b_page); -put_page (bh->b_page); +folio_unlock (bh->b_folio); +folio_put (bh->b_folio);return bh; }
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 16/20 nilfs2: Convert nilfs_btnode_submit_block to use a folio
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Saves two calls to compound_head().
--- fs/nilfs2/btnode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/nilfs2/btnode.c +4 -4
@@ -75,7 +75,7 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, {struct buffer_head *bh;struct inode *inode = btnc->host; -struct page *page; +struct folio *folio;int err; bh =nilfs_grab_buffer (inode, btnc, blocknr,BIT (BH_NILFS_Node));
@@ -83,7 +83,7 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr,return -ENOMEM ; err = -EEXIST ;/* internal code */ - page = bh->b_page; + folio = bh->b_folio;if (buffer_uptodate (bh) ||buffer_dirty (bh)) goto found;
@@ -130,8 +130,8 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, *pbh = bh; out_locked: -unlock_page (page); -put_page (page); +folio_unlock (folio); +folio_put (folio);return err; }
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 17/20 nilfs2: Convert nilfs_btnode_delete to use a folio
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Saves six calls to compound_head().
--- fs/nilfs2/btnode.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
fs/nilfs2/btnode.c +9 -9
@@ -145,19 +145,19 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr,void nilfs_btnode_delete (struct buffer_head *bh) {struct address_space *mapping; -struct page *page = bh->b_page; -pgoff_t index =page_index (page); +struct folio *folio = bh->b_folio; +pgoff_t index = folio->index;int still_dirty; -get_page (page); -lock_page (page); -wait_on_page_writeback (page); +folio_get (folio); +folio_lock (folio); +folio_wait_writeback (folio);nilfs_forget_buffer (bh); - still_dirty =PageDirty (page); - mapping = page->mapping; -unlock_page (page); -put_page (page); + still_dirty =folio_test_dirty (folio); + mapping = folio->mapping; +folio_unlock (folio); +folio_put (folio);if (!still_dirty && mapping)invalidate_inode_pages2_range (mapping, index, index);
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 18/20 nilfs2: Convert nilfs_btnode_prepare_change_key to use a folio
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Saves three calls to compound_head().
--- fs/nilfs2/btnode.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
fs/nilfs2/btnode.c +9 -9
@@ -185,23 +185,23 @@ int nilfs_btnode_prepare_change_key(struct address_space *btnc, ctxt->newbh =NULL ;if (inode->i_blkbits ==PAGE_SHIFT ) { -struct page *opage = obh->b_page; -lock_page (opage); +struct folio *ofolio = obh->b_folio; +folio_lock (ofolio); retry:/* BUG_ON(oldkey != obh->b_folio->index); */ -if (unlikely (oldkey != opage->index)) -NILFS_PAGE_BUG (opage, +if (unlikely (oldkey != ofolio->index)) +NILFS_PAGE_BUG (&ofolio->page,"invalid oldkey %lld (newkey=%lld)" , (unsigned long long )oldkey, (unsigned long long )newkey);xa_lock_irq (&btnc->i_pages); - err =__xa_insert (&btnc->i_pages, newkey, opage,GFP_NOFS ); + err =__xa_insert (&btnc->i_pages, newkey, ofolio,GFP_NOFS );xa_unlock_irq (&btnc->i_pages);/* -* Note: page->index will not change to newkey until +* Note: folio->index will not change to newkey until * nilfs_btnode_commit_change_key() will be called. -* To protect the page in intermediate state, the page lock +* To protect the folio in intermediate state, the folio lock * is held. */ if (!err)
@@ -213,7 +213,7 @@ int nilfs_btnode_prepare_change_key(struct address_space *btnc,if (!err) goto retry;/* fallback to copy mode */ -unlock_page (opage); +folio_unlock (ofolio); } nbh =nilfs_btnode_create_block (btnc, newkey);
@@ -225,7 +225,7 @@ int nilfs_btnode_prepare_change_key(struct address_space *btnc,return 0 ; failed_unlock: -unlock_page (obh->b_page); +folio_unlock (obh->b_folio);return err; }
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 19/20 nilfs2: Convert nilfs_btnode_commit_change_key to use a folio
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Saves one call to compound_head().
--- fs/nilfs2/btnode.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/nilfs2/btnode.c +6 -6
@@ -238,15 +238,15 @@ void nilfs_btnode_commit_change_key(struct address_space *btnc, {struct buffer_head *obh = ctxt->bh, *nbh = ctxt->newbh;__u64 oldkey = ctxt->oldkey, newkey = ctxt->newkey; -struct page *opage; +struct folio *ofolio;if (oldkey == newkey)return ;if (nbh ==NULL ) {/* blocksize == pagesize */ - opage = obh->b_page; -if (unlikely (oldkey != opage->index)) -NILFS_PAGE_BUG (opage, + ofolio = obh->b_folio; +if (unlikely (oldkey != ofolio->index)) +NILFS_PAGE_BUG (&ofolio->page,"invalid oldkey %lld (newkey=%lld)" , (unsigned long long )oldkey, (unsigned long long )newkey);
@@ -257,8 +257,8 @@ void nilfs_btnode_commit_change_key(struct address_space *btnc,__xa_set_mark (&btnc->i_pages, newkey,PAGECACHE_TAG_DIRTY );xa_unlock_irq (&btnc->i_pages); - opage->index = obh->b_blocknr = newkey; -unlock_page (opage); + ofolio->index = obh->b_blocknr = newkey; +folio_unlock (ofolio); }else {nilfs_copy_buffer (nbh, obh);mark_buffer_dirty (nbh);
Signature · 1 line
2.34.1
Ryusuke Konishi
maintainerPATCH 20/20 nilfs2: Convert nilfs_btnode_abort_change_key to use a folio
In reply to Ryusuke KonishiFrom: "Matthew Wilcox (Oracle)" <[email protected]>
Saves one call to compound_head().
--- fs/nilfs2/btnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nilfs2/btnode.c +1 -1
@@ -284,7 +284,7 @@ void nilfs_btnode_abort_change_key(struct address_space *btnc,if (nbh ==NULL ) {/* blocksize == pagesize */ xa_erase_irq (&btnc->i_pages, newkey); -unlock_page (ctxt->bh->b_page); +folio_unlock (ctxt->bh->b_folio); }else {/* * When canceling a buffer that a prepare operation has
Signature · 1 line
2.34.1