f2fs: convert f2fs_write_begin() to use folio
Chao Yu
maintainerPATCH 1/8 f2fs: convert f2fs_write_begin() to use folio
Convert to use folio, so that we can get rid of 'page->index' to prepare for removal of 'index' field in structure page [1].
[1] https://lore.kernel.org/all/[email protected]/
--- fs/f2fs/data.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-)
fs/f2fs/data.c +21 -19
@@ -3381,8 +3381,8 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi, struct page *page, loff_t pos, unsigned len, block_t *blk_addr, bool *node_changed) { - struct inode *inode = page->mapping->host; -pgoff_t index = page->index; + struct inode *inode = folio->mapping->host; +pgoff_t index = folio->index;struct dnode_of_data dn;struct page *ipage;bool locked = false;
@@ -3419,7 +3419,7 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi,if (f2fs_has_inline_data (inode)) {if (pos + len <=MAX_INLINE_DATA (inode)) { -f2fs_do_read_inline_data (page_folio (page), ipage); +f2fs_do_read_inline_data (folio, ipage);set_inode_flag (inode,FI_DATA_EXIST );if (inode->i_nlink)set_page_private_inline (ipage);
@@ -3518,12 +3518,12 @@ static int __reserve_data_block(struct inode *inode, pgoff_t index, }static int prepare_atomic_write_begin (struct f2fs_sb_info *sbi, -struct page *page,loff_t pos,unsigned int len, +struct folio *folio,loff_t pos,unsigned int len,block_t *blk_addr,bool *node_changed,bool *use_cow) { -struct inode *inode = page->mapping->host; +struct inode *inode = folio->mapping->host;struct inode *cow_inode =F2FS_I (inode)->cow_inode; -pgoff_t index = page->index; +pgoff_t index = folio->index;int err =0 ;block_t ori_blk_addr =NULL_ADDR ;
@@ -3566,6 +3566,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,struct inode *inode = mapping->host;struct f2fs_sb_info *sbi =F2FS_I_SB (inode);struct page *page =NULL ; +struct folio *folio;pgoff_t index = ((unsigned long long ) pos) >>PAGE_SHIFT ;bool need_balance = false;bool use_cow = false;
@@ -3625,22 +3626,23 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,/* TODO: cluster can be compressed due to race with .writepage */ *pagep = page; + folio =page_folio (page);if (f2fs_is_atomic_file (inode)) - err =prepare_atomic_write_begin (sbi, page, pos, len, + err =prepare_atomic_write_begin (sbi, folio, pos, len &blkaddr, &need_balance, &use_cow);else - err =prepare_write_begin (sbi, page, pos, len, + err =prepare_write_begin (sbi, folio, pos, len, &blkaddr, &need_balance);if (err) goto fail;if (need_balance && !IS_NOQUOTA (inode) &&has_not_enough_free_secs (sbi,0 ,0 )) { -unlock_page (page); +folio_unlock (folio);f2fs_balance_fs (sbi, true); -lock_page (page); -if (page->mapping != mapping) { +folio_lock (folio); +if (folio->mapping != mapping) {/* The page got truncated from under us */ f2fs_put_page (page,1 ); goto repeat;
@@ -3649,18 +3651,18 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,f2fs_wait_on_page_writeback (page,DATA , false, true); -if (len ==PAGE_SIZE ||PageUptodate (page)) +if (len ==PAGE_SIZE ||folio_test_uptodate (folio))return 0 ;if (!(pos & (PAGE_SIZE -1 )) && (pos + len) >=i_size_read (inode) && !f2fs_verity_in_progress (inode)) { -zero_user_segment (page, len,PAGE_SIZE ); +folio_zero_segment (folio, len,folio_size (folio));return 0 ; }if (blkaddr ==NEW_ADDR ) { -zero_user_segment (page,0 ,PAGE_SIZE ); -SetPageUptodate (page); +folio_zero_segment (folio,0 ,folio_size (folio)); +folio_mark_uptodate (folio); }else {if (!f2fs_is_valid_blkaddr (sbi, blkaddr,DATA_GENERIC_ENHANCE_READ )) {
@@ -3669,16 +3671,16 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, } err =f2fs_submit_page_read (use_cow ?F2FS_I (inode)->cow_inode : inode, -page_folio (page), blkaddr,0 , true); + folio, blkaddr,0 , true);if (err) goto fail; -lock_page (page); -if (unlikely (page->mapping != mapping)) { +folio_lock (folio); +if (unlikely (folio->mapping != mapping)) {f2fs_put_page (page,1 ); goto repeat; } -if (unlikely (!PageUptodate (page))) { +if (unlikely (!folio_test_uptodate (folio))) { err = -EIO ; goto fail; }
Signature · 1 line
2.40.1
Chao Yu
maintainerPATCH 2/8 f2fs: convert f2fs_write_end() to use folio
Convert to use folio, so that we can get rid of 'page->index' to prepare for removal of 'index' field in structure page [1].
[1] https://lore.kernel.org/all/[email protected]/
--- fs/f2fs/data.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
fs/f2fs/data.c +10 -9
@@ -3378,7 +3378,7 @@ void f2fs_write_failed(struct inode *inode, loff_t to) }static int prepare_write_begin (struct f2fs_sb_info *sbi, -struct page *page,loff_t pos,unsigned len, +struct folio *folio,loff_t pos,unsigned int len,block_t *blk_addr,bool *node_changed) {struct inode *inode = folio->mapping->host;
@@ -3425,7 +3425,7 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi,set_page_private_inline (ipage); goto out; } - err =f2fs_convert_inline_page (&dn, page); + err =f2fs_convert_inline_page (&dn,folio_page (folio,0 ));if (err || dn.data_blkaddr !=NULL_ADDR ) goto out; }
@@ -3629,7 +3629,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, folio =page_folio (page);if (f2fs_is_atomic_file (inode)) - err =prepare_atomic_write_begin (sbi, folio, pos, len + err =prepare_atomic_write_begin (sbi, folio, pos, len, &blkaddr, &need_balance, &use_cow);else err = prepare_write_begin(sbi, folio, pos, len,
@@ -3698,7 +3698,8 @@ static int f2fs_write_end(struct file *file, loff_t pos, unsigned len, unsigned copied, struct page *page, void *fsdata) { - struct inode *inode = page->mapping->host; + struct folio *folio = page_folio(page); +struct inode *inode = folio->mapping->host;trace_f2fs_write_end (inode, pos, len, copied);
@@ -3707,17 +3708,17 @@ static int f2fs_write_end(struct file *file,* should be PAGE_SIZE. Otherwise, we treat it with zero copied and * let generic_perform_write() try to copy data again through copied=0. */ -if (!PageUptodate (page)) { +if (!folio_test_uptodate (folio)) {if (unlikely (copied != len)) copied =0 ;else -SetPageUptodate (page); +folio_mark_uptodate (folio); }#ifdef CONFIG_F2FS_FS_COMPRESSION /* overwrite compressed file */ if (f2fs_compressed_file (inode) && fsdata) { -f2fs_compress_write_end (inode, fsdata, page->index, copied); +f2fs_compress_write_end (inode, fsdata, folio->index, copied);f2fs_update_time (F2FS_I_SB (inode),REQ_TIME ); if (pos + copied > i_size_read(inode) &&
@@ -3730,10 +3731,10 @@ static int f2fs_write_end(struct file *file,if (!copied) goto unlock_out; -set_page_dirty (page); +folio_mark_dirty (folio);if (f2fs_is_atomic_file (inode)) -set_page_private_atomic (page); +set_page_private_atomic (folio_page (folio,0 ));if (pos + copied >i_size_read (inode) && !f2fs_verity_in_progress (inode)) {
Signature · 1 line
2.40.1
Re: [PATCH 2/8] f2fs: convert f2fs_write_end() to use folio
Hi,
Quoted 34 lines · Chao Yu
Convert to use folio, so that we can get rid of '
page->index' to prepare for removal of 'index' field in structure page [1].[1] https://lore.kernel.org/all/[email protected]/
Cc Matthew Wilcox <[email protected]>Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/data.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)fs/f2fs/data.c +2
-2@@ -3378,7 +3378,7 @@ void f2fs_write_failed(struct inode *inode, loff_t to) }static int prepare_write_begin (struct f2fs_sb_info *sbi, -struct page *page,loff_t pos,unsigned len, +struct folio *folio,loff_t pos,unsigned int len,block_t *blk_addr,bool *node_changed) {struct inode *inode = folio->mapping->host;@@ -3425,7 +3425,7 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi,set_page_private_inline (ipage); goto out; } - err =f2fs_convert_inline_page (&dn, page); + err =f2fs_convert_inline_page (&dn,folio_page (folio,0 ));if (err || dn.data_blkaddr !=NULL_ADDR ) goto out; }
fs/f2fs/data.c static int f2fs_write_begin(struct file *file, struct address_space *mapping, · line 3632
Quoted 5 lines
fs/f2fs/data.c +1
-1@@ -3629,7 +3629,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, folio =page_folio (page);if (f2fs_is_atomic_file (inode)) - err = prepare_atomic_write_begin(sbi, folio, pos, len + err = prepare_atomic_write_begin(sbi, folio, pos, len,
This has been changed in the first patch, it is redundant here.
Quoted 47 lines
fs/f2fs/data.c +7
-6&blkaddr, &need_balance, &use_cow); else err = prepare_write_begin(sbi, folio, pos, len,@@ -3698,7 +3698,8 @@ static int f2fs_write_end(struct file *file, loff_t pos, unsigned len, unsigned copied, struct page *page, void *fsdata) { - struct inode *inode = page->mapping->host; + struct folio *folio = page_folio(page); +struct inode *inode = folio->mapping->host;trace_f2fs_write_end (inode, pos, len, copied);@@ -3707,17 +3708,17 @@ static int f2fs_write_end(struct file *file,* should be PAGE_SIZE. Otherwise, we treat it with zero copied and * let generic_perform_write() try to copy data again through copied=0. */ -if (!PageUptodate (page)) { +if (!folio_test_uptodate (folio)) {if (unlikely (copied != len)) copied =0 ;else -SetPageUptodate (page); +folio_mark_uptodate (folio); }#ifdef CONFIG_F2FS_FS_COMPRESSION /* overwrite compressed file */ if (f2fs_compressed_file (inode) && fsdata) { -f2fs_compress_write_end (inode, fsdata, page->index, copied); +f2fs_compress_write_end (inode, fsdata, folio->index, copied);f2fs_update_time (F2FS_I_SB (inode),REQ_TIME ); if (pos + copied > i_size_read(inode) &&@@ -3730,10 +3731,10 @@ static int f2fs_write_end(struct file *file,if (!copied) goto unlock_out; -set_page_dirty (page); +folio_mark_dirty (folio);if (f2fs_is_atomic_file (inode)) -set_page_private_atomic (page); +set_page_private_atomic (folio_page (folio,0 ));if (pos + copied >i_size_read (inode) && !f2fs_verity_in_progress (inode)) {
Chao Yu
maintainerRe: [PATCH 2/8] f2fs: convert f2fs_write_end() to use folio
Quoted 32 lines · Li Zetao
Hi,
Quoted 29 lines · Chao Yu
Convert to use folio, so that we can get rid of '
page->index' to prepare for removal of 'index' field in structure page [1].[1] https://lore.kernel.org/all/[email protected]/
Cc Matthew Wilcox <[email protected]>Signed-off-by Chao Yu <[email protected]>---
fs/f2fs/data.c| 19 ++++++++++---------1 file changed, 10 insertions(+), 9 deletions(-)fs/f2fs/data.c +2
-2@@ -3378,7 +3378,7 @@ void f2fs_write_failed(struct inode *inode, loff_t to) } static int prepare_write_begin(struct f2fs_sb_info *sbi, - struct page *page, loff_t pos, unsigned len, + struct folio *folio, loff_t pos, unsigned int len, block_t *blk_addr, bool *node_changed) { struct inode *inode = folio->mapping->host;@@ -3425,7 +3425,7 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi, set_page_private_inline(ipage); goto out; } - err = f2fs_convert_inline_page(&dn, page); + err = f2fs_convert_inline_page(&dn, folio_page(folio, 0));
Quoted 8 lines
fs/f2fs/data.c static int f2fs_write_begin(struct file *file, struct address_space *mapping, · line 3631
Quoted 8 lines
fs/f2fs/data.c +1
-1if (err || dn.data_blkaddr != NULL_ADDR) goto out; }@@ -3629,7 +3629,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, folio = page_folio(page); if (f2fs_is_atomic_file(inode)) - err = prepare_atomic_write_begin(sbi, folio, pos, len + err = prepare_atomic_write_begin(sbi, folio, pos, len,
Thanks for your reminder, I removed comma after @len in patch 1/8 by mistake, let me fix it.
Thanks,
Quoted 41 lines
This has been changed in the first patch, it is redundant here.
Quoted 40 lines
fs/f2fs/data.c +0
-0&blkaddr, &need_balance, &use_cow);else
err = prepare_write_begin(sbi, folio, pos, len,fs/f2fs/data.c +3
-2@@ -3698,7 +3698,8 @@ static int f2fs_write_end(struct file *file, loff_t pos, unsigned len, unsigned copied, struct page *page, void *fsdata) { - struct inode *inode = page->mapping->host; + struct folio *folio = page_folio(page); + struct inode *inode = folio->mapping->host; trace_f2fs_write_end(inode, pos, len, copied);@@ -3707,17 +3708,17 @@ static int f2fs_write_end(struct file *file,* should be PAGE_SIZE. Otherwise, we treat it with zero copied and * let generic_perform_write() try to copy data again through copied=0. */ - if (!PageUptodate(page)) { + if (!folio_test_uptodate(folio)) { if (unlikely(copied != len)) copied = 0;else
- SetPageUptodate(page);
+folio_mark_uptodate(folio);
}
#ifdefCONFIG_F2FS_FS_COMPRESSION
/* overwrite compressed file */
if (f2fs_compressed_file(inode)&& fsdata) {
-f2fs_compress_write_end(inode, fsdata, page->index, copied); +f2fs_compress_write_end(inode, fsdata, folio->index, copied);f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
if (pos + copied >i_size_read(inode)&&fs/f2fs/data.c +2
-2@@ -3730,10 +3731,10 @@ static int f2fs_write_end(struct file *file, if (!copied) goto unlock_out; - set_page_dirty(page); + folio_mark_dirty(folio); if (f2fs_is_atomic_file(inode)) - set_page_private_atomic(page); + set_page_private_atomic(folio_page(folio, 0));if (pos + copied >
i_size_read(inode)&&
!f2fs_verity_in_progress(inode)) {
Chao Yu
maintainerPATCH 3/8 f2fs: convert f2fs_set_compressed_page() to use folio
In reply to Chao YuConvert to use folio, so that we can get rid of 'page->index' to prepare for removal of 'index' field in structure page [1].
[1] https://lore.kernel.org/all/[email protected]/
--- fs/f2fs/compress.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/f2fs/compress.c +5 -3
@@ -90,11 +90,13 @@ bool f2fs_is_compressed_page(struct page *page)static void f2fs_set_compressed_page (struct page *page,struct inode *inode,pgoff_t index,void *data) { -attach_page_private (page, (void *)data); +struct folio *folio =page_folio (page); + +folio_attach_private (folio, (void *)data);/* i_crypto_info and iv index */ - page->index = index; - page->mapping = inode->i_mapping; + folio->index = index; + folio->mapping = inode->i_mapping; }static void f2fs_drop_rpages (struct compress_ctx *cc,int len,bool unlock)
Signature · 1 line
2.40.1
Chao Yu
maintainerPATCH 4/8 f2fs: convert f2fs_do_write_data_page() to use folio
In reply to Chao YuConvert to use folio, so that we can get rid of 'page->index' to prepare for removal of 'index' field in structure page [1].
[1] https://lore.kernel.org/all/[email protected]/
--- fs/f2fs/data.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
fs/f2fs/data.c +13 -13
@@ -2648,8 +2648,8 @@ static inline bool need_inplace_update(struct f2fs_io_info *fio)int f2fs_do_write_data_page (struct f2fs_io_info *fio) { -struct page *page = fio->page; -struct inode *inode = page->mapping->host; +struct folio *folio =page_folio (fio->page); +struct inode *inode = folio->mapping->host;struct dnode_of_data dn;struct node_info ni;bool ipu_force = false;
@@ -2658,14 +2658,14 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio)/* Use COW inode to make dnode_of_data for atomic write */ atomic_commit =f2fs_is_atomic_file (inode) && -page_private_atomic (fio->page); +page_private_atomic (folio_page (folio,0 ));if (atomic_commit)set_new_dnode (&dn,F2FS_I (inode)->cow_inode,NULL ,NULL ,0 );else set_new_dnode (&dn, inode,NULL ,NULL ,0 );if (need_inplace_update (fio) && -f2fs_lookup_read_extent_cache_block (inode, page->index, +f2fs_lookup_read_extent_cache_block (inode, folio->index, &fio->old_blkaddr)) {if (!f2fs_is_valid_blkaddr (fio->sbi, fio->old_blkaddr,DATA_GENERIC_ENHANCE ))
@@ -2680,7 +2680,7 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio)if (fio->need_lock ==LOCK_REQ && !f2fs_trylock_op (fio->sbi))return -EAGAIN ; - err =f2fs_get_dnode_of_data (&dn, page->index,LOOKUP_NODE ); + err =f2fs_get_dnode_of_data (&dn, folio->index,LOOKUP_NODE );if (err) goto out;
@@ -2688,8 +2688,8 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio)/* This page is already truncated */ if (fio->old_blkaddr ==NULL_ADDR ) { -ClearPageUptodate (page); -clear_page_private_gcing (page); +folio_clear_uptodate (folio); +clear_page_private_gcing (folio_page (folio,0 )); goto out_writepage; } got_it:
@@ -2715,7 +2715,7 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio)if (err) goto out_writepage; -set_page_writeback (page); +folio_start_writeback (folio);f2fs_put_dnode (&dn);if (fio->need_lock ==LOCK_REQ )f2fs_unlock_op (fio->sbi);
@@ -2723,11 +2723,11 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio)if (err) {if (fscrypt_inode_uses_fs_layer_crypto (inode))fscrypt_finalize_bounce_page (&fio->encrypted_page); -end_page_writeback (page); +folio_end_writeback (folio); }else {set_inode_flag (inode,FI_UPDATE_WRITE ); } -trace_f2fs_do_write_data_page (page_folio (page),IPU ); +trace_f2fs_do_write_data_page (folio,IPU );return err; }
@@ -2749,17 +2749,17 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio)if (err) goto out_writepage; -set_page_writeback (page); +folio_start_writeback (folio);if (fio->compr_blocks && fio->old_blkaddr ==COMPRESS_ADDR )f2fs_i_compr_blocks_update (inode, fio->compr_blocks -1 , false);/* LFS mode write path */ f2fs_outplace_write_data (&dn, fio); -trace_f2fs_do_write_data_page (page_folio (page),OPU ); +trace_f2fs_do_write_data_page (folio,OPU );set_inode_flag (inode,FI_APPEND_WRITE );if (atomic_commit) -clear_page_private_atomic (page); +clear_page_private_atomic (folio_page (folio,0 )); out_writepage:f2fs_put_dnode (&dn); out:
Signature · 1 line
2.40.1
Chao Yu
maintainerPATCH 5/8 f2fs: convert f2fs_write_data_page() to use folio
In reply to Chao YuConvert to use folio, so that we can get rid of 'page->index' to prepare for removal of 'index' field in structure page [1].
[1] https://lore.kernel.org/all/[email protected]/
--- fs/f2fs/data.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/f2fs/data.c +5 -4
@@ -2945,22 +2945,23 @@ int f2fs_write_single_data_page(struct folio *folio, int *submitted,static int f2fs_write_data_page (struct page *page,struct writeback_control *wbc) { +struct folio *folio =page_folio (page);#ifdef CONFIG_F2FS_FS_COMPRESSION -struct inode *inode = page->mapping->host; +struct inode *inode = folio->mapping->host;if (unlikely (f2fs_cp_error (F2FS_I_SB (inode)))) goto out;if (f2fs_compressed_file (inode)) { -if (f2fs_is_compressed_cluster (inode, page->index)) { -redirty_page_for_writepage (wbc, page); +if (f2fs_is_compressed_cluster (inode, folio->index)) { +folio_redirty_for_writepage (wbc, folio);return AOP_WRITEPAGE_ACTIVATE ; } } out:#endif -return f2fs_write_single_data_page (page_folio (page),NULL ,NULL ,NULL , +return f2fs_write_single_data_page (folio,NULL ,NULL ,NULL , wbc,FS_DATA_IO ,0 , true); }
Signature · 1 line
2.40.1
Chao Yu
maintainerPATCH 6/8 f2fs: convert __write_node_page() to use folio
In reply to Chao YuConvert to use folio, so that we can get rid of 'page->index' to prepare for removal of 'index' field in structure page [1].
[1] https://lore.kernel.org/all/[email protected]/
--- fs/f2fs/node.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
fs/f2fs/node.c +10 -9
@@ -1608,6 +1608,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, enum iostat_type io_type, unsigned int *seq_id) { struct f2fs_sb_info *sbi = F2FS_P_SB(page); +struct folio *folio =page_folio (page);nid_t nid;struct node_info ni; struct f2fs_io_info fio = {
@@ -1624,15 +1625,15 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, };unsigned int seq; -trace_f2fs_writepage (page_folio (page),NODE ); +trace_f2fs_writepage (folio,NODE );if (unlikely (f2fs_cp_error (sbi))) {/* keep node pages in remount-ro mode */ if (F2FS_OPTION (sbi).errors ==MOUNT_ERRORS_READONLY ) goto redirty_out; -ClearPageUptodate (page); +folio_clear_uptodate (folio);dec_page_count (sbi,F2FS_DIRTY_NODES ); -unlock_page (page); +folio_unlock (folio);return 0 ; }
@@ -1646,7 +1647,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,/* get old block addr of this node page */ nid =nid_of_node (page); -f2fs_bug_on (sbi, page->index != nid); +f2fs_bug_on (sbi, folio->index != nid);if (f2fs_get_node_info (sbi, nid, &ni, !do_balance)) goto redirty_out;
@@ -1660,10 +1661,10 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,/* This page is already truncated */ if (unlikely (ni.blk_addr ==NULL_ADDR )) { -ClearPageUptodate (page); +folio_clear_uptodate (folio);dec_page_count (sbi,F2FS_DIRTY_NODES );f2fs_up_read (&sbi->node_write); -unlock_page (page); +folio_unlock (folio);return 0 ; }
@@ -1684,7 +1685,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, *seq_id = seq; } -set_page_writeback (page); +folio_start_writeback (folio); fio.old_blkaddr = ni.blk_addr;f2fs_do_write_node_page (nid, &fio);
@@ -1697,7 +1698,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, submitted =NULL ; } -unlock_page (page); +folio_unlock (folio);if (unlikely (f2fs_cp_error (sbi))) {f2fs_submit_merged_write (sbi,NODE );
@@ -1711,7 +1712,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,return 0 ; redirty_out: -redirty_page_for_writepage (wbc, page); +folio_redirty_for_writepage (wbc, folio);return AOP_WRITEPAGE_ACTIVATE ; }
Signature · 1 line
2.40.1
Chao Yu
maintainerPATCH 7/8 f2fs: convert read_node_page() to use folio
In reply to Chao YuConvert to use folio, so that we can get rid of 'page->index' to prepare for removal of 'index' field in structure page [1].
[1] https://lore.kernel.org/all/[email protected]/
--- fs/f2fs/node.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/f2fs/node.c +5 -4
@@ -1369,6 +1369,7 @@ struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs)*/ static int read_node_page (struct page *page,blk_opf_t op_flags) { +struct folio *folio =page_folio (page);struct f2fs_sb_info *sbi =F2FS_P_SB (page);struct node_info ni;struct f2fs_io_info fio = {
@@ -1381,21 +1382,21 @@ static int read_node_page(struct page *page, blk_opf_t op_flags) };int err; -if (PageUptodate (page)) { +if (folio_test_uptodate (folio)) {if (!f2fs_inode_chksum_verify (sbi, page)) { -ClearPageUptodate (page); +folio_clear_uptodate (folio);return -EFSBADCRC ; }return LOCKED_PAGE ; } - err =f2fs_get_node_info (sbi, page->index, &ni, false); + err =f2fs_get_node_info (sbi, folio->index, &ni, false);if (err)return err;/* NEW_ADDR can be seen, after cp_error drops some dirty node pages */ if (unlikely (ni.blk_addr ==NULL_ADDR || ni.blk_addr ==NEW_ADDR )) { -ClearPageUptodate (page); +folio_clear_uptodate (folio);return -ENOENT ; }
Signature · 1 line
2.40.1
Chao Yu
maintainerPATCH 8/8 f2fs: get rid of page->index
In reply to Chao YuConvert to use folio, so that we can get rid of 'page->index' to prepare for removal of 'index' field in structure page [1].
[1] https://lore.kernel.org/all/[email protected]/
--- fs/f2fs/compress.c | 2 +- fs/f2fs/data.c | 12 ++++++------ fs/f2fs/dir.c | 3 ++- fs/f2fs/inode.c | 3 ++- fs/f2fs/node.c | 4 ++-- fs/f2fs/segment.c | 3 ++- 6 files changed, 15 insertions(+), 12 deletions(-)
fs/f2fs/compress.c +1 -1
@@ -881,7 +881,7 @@ static bool cluster_has_invalid_data(struct compress_ctx *cc)f2fs_bug_on (F2FS_I_SB (cc->inode), !page);/* beyond EOF */ -if (page->index >= nr_pages) +if (page_folio (page)->index >= nr_pages)return true; }return false;
fs/f2fs/data.c +6 -6
@@ -354,7 +354,7 @@ static void f2fs_write_end_io(struct bio *bio) }f2fs_bug_on (sbi, page->mapping ==NODE_MAPPING (sbi) && - page->index !=nid_of_node (page)); +page_folio (page)->index !=nid_of_node (page));dec_page_count (sbi, type);if (f2fs_in_warm_node_list (sbi, page))
@@ -703,7 +703,7 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio) bio =__bio_alloc (fio,1 );f2fs_set_bio_crypt_ctx (bio, fio->page->mapping->host, - fio->page->index, fio,GFP_NOIO ); +page_folio (fio->page)->index, fio,GFP_NOIO );if (bio_add_page (bio, page,PAGE_SIZE ,0 ) <PAGE_SIZE ) {bio_put (bio);
@@ -802,7 +802,7 @@ static int add_ipu_page(struct f2fs_io_info *fio, struct bio **bio, fio->new_blkaddr));if (f2fs_crypt_mergeable_bio (*bio, fio->page->mapping->host, - fio->page->index, fio) && +page_folio (fio->page)->index, fio) &&bio_add_page (*bio, page,PAGE_SIZE ,0 ) ==PAGE_SIZE ) { ret =0 ;
@@ -902,7 +902,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)if (!bio) { bio =__bio_alloc (fio,BIO_MAX_VECS );f2fs_set_bio_crypt_ctx (bio, fio->page->mapping->host, - fio->page->index, fio,GFP_NOIO ); +page_folio (fio->page)->index, fio,GFP_NOIO );add_bio_entry (fio->sbi, bio, page, fio->temp); }else {
@@ -995,13 +995,13 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio) (!io_is_mergeable(sbi, io->bio, io, fio, io->last_block_in_bio, fio->new_blkaddr) || !f2fs_crypt_mergeable_bio(io->bio, fio->page->mapping->host, - bio_page->index, fio))) + page_folio(bio_page)->index, fio)))__submit_merged_bio (io); alloc_new:if (io->bio ==NULL ) { io->bio =__bio_alloc (fio,BIO_MAX_VECS );f2fs_set_bio_crypt_ctx (io->bio, fio->page->mapping->host, - bio_page->index, fio,GFP_NOIO ); +page_folio (bio_page)->index, fio,GFP_NOIO ); io->fio = *fio; }
fs/f2fs/dir.c +2 -1
@@ -842,6 +842,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,struct f2fs_dentry_block *dentry_blk;unsigned int bit_pos;int slots =GET_DENTRY_SLOTS (le16_to_cpu (dentry->name_len)); +pgoff_t index =page_folio (page)->index;int i;f2fs_update_time (F2FS_I_SB (dir),REQ_TIME );
@@ -867,7 +868,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,set_page_dirty (page);if (bit_pos ==NR_DENTRY_IN_BLOCK && - !f2fs_truncate_hole (dir, page->index, page->index +1 )) { + !f2fs_truncate_hole (dir, index, index +1 )) {f2fs_clear_page_cache_dirty_tag (page_folio (page));clear_page_dirty_for_io (page);ClearPageUptodate (page);
fs/f2fs/inode.c +2 -1
@@ -174,7 +174,8 @@ bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, struct page *page)if (provided != calculated)f2fs_warn (sbi,"checksum invalid, nid = %lu, ino_of_node = %x, %x vs. %x" , - page->index,ino_of_node (page), provided, calculated); +page_folio (page)->index,ino_of_node (page), + provided, calculated);return provided == calculated; }
fs/f2fs/node.c +2 -2
@@ -919,7 +919,7 @@ static int truncate_node(struct dnode_of_data *dn)clear_node_page_dirty (dn->node_page);set_sbi_flag (sbi,SBI_IS_DIRTY ); - index = dn->node_page->index; + index =page_folio (dn->node_page)->index;f2fs_put_page (dn->node_page,1 ); invalidate_mapping_pages(NODE_MAPPING(sbi),
@@ -1869,7 +1869,7 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, }if (!ret && atomic && !marked) {f2fs_debug (sbi,"Retry to write fsync mark: ino=%u, idx=%lx" , - ino, last_page->index); + ino,page_folio (last_page)->index);lock_page (last_page);f2fs_wait_on_page_writeback (last_page,NODE , true, true);set_page_dirty (last_page);
fs/f2fs/segment.c +2 -1
@@ -3564,7 +3564,8 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)if (file_is_cold (inode) ||f2fs_need_compress_data (inode))return CURSEG_COLD_DATA ; - type =__get_age_segment_type (inode, fio->page->index); + type =__get_age_segment_type (inode, +page_folio (fio->page)->index);if (type !=NO_CHECK_TYPE )return type;
Signature · 1 line
2.40.1