diff mbox series

[f2fs-dev,2/8] f2fs: convert f2fs_write_end() to use folio

Message ID 20240819012023.3871272-2-chao@kernel.org (mailing list archive)
State Superseded
Headers show
Series [f2fs-dev,1/8] f2fs: convert f2fs_write_begin() to use folio | expand

Commit Message

Chao Yu Aug. 19, 2024, 1:20 a.m. UTC
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/Zp8fgUSIBGQ1TN0D@casper.infradead.org/

Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Chao Yu <chao@kernel.org>
---
 fs/f2fs/data.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

Comments

Li Zetao Aug. 20, 2024, 3:04 a.m. UTC | #1
Hi,

在 2024/8/19 9:20, 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/Zp8fgUSIBGQ1TN0D@casper.infradead.org/
> 
> Cc: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
>   fs/f2fs/data.c | 19 ++++++++++---------
>   1 file changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 9e1ade13060c..e114d738b6b4 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -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,
This has been changed in the first patch, it is redundant here.
>   					&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 Aug. 20, 2024, 3:12 a.m. UTC | #2
On 2024/8/20 11:04, Li Zetao wrote:
> Hi,
> 
> 在 2024/8/19 9:20, 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/Zp8fgUSIBGQ1TN0D@casper.infradead.org/
>>
>> Cc: Matthew Wilcox <willy@infradead.org>
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>>   fs/f2fs/data.c | 19 ++++++++++---------
>>   1 file changed, 10 insertions(+), 9 deletions(-)
>>
>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
>> index 9e1ade13060c..e114d738b6b4 100644
>> --- a/fs/f2fs/data.c
>> +++ b/fs/f2fs/data.c
>> @@ -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,

Thanks for your reminder, I removed comma after @len in patch 1/8 by
mistake, let me fix it.

Thanks,

> This has been changed in the first patch, it is redundant here.
>>                       &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)) {
diff mbox series

Patch

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 9e1ade13060c..e114d738b6b4 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -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)) {