linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Jaegeuk Kim <jaegeuk@kernel.org>
Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 21/27] f2fs: Add f2fs_get_read_data_folio()
Date: Fri, 28 Feb 2025 15:37:17 +0800	[thread overview]
Message-ID: <4948a522-1302-462e-9256-1bb31d0ce7aa@kernel.org> (raw)
In-Reply-To: <20250218055203.591403-22-willy@infradead.org>

On 2025/2/18 13:51, Matthew Wilcox (Oracle) wrote:
> Convert f2fs_get_read_data_page() into f2fs_get_read_data_folio() and
> add a compatibility wrapper.  Saves seven hidden calls to compound_head().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>   fs/f2fs/data.c | 35 +++++++++++++++++------------------
>   fs/f2fs/f2fs.h | 14 ++++++++++++--
>   2 files changed, 29 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index fe7fa08b20c7..f0747c7f669d 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1203,18 +1203,17 @@ int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index)
>   	return err;
>   }
>   
> -struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
> -				     blk_opf_t op_flags, bool for_write,
> -				     pgoff_t *next_pgofs)
> +struct folio *f2fs_get_read_data_folio(struct inode *inode, pgoff_t index,
> +		blk_opf_t op_flags, bool for_write, pgoff_t *next_pgofs)
>   {
>   	struct address_space *mapping = inode->i_mapping;
>   	struct dnode_of_data dn;
> -	struct page *page;
> +	struct folio *folio;
>   	int err;
>   
> -	page = f2fs_grab_cache_page(mapping, index, for_write);
> -	if (!page)
> -		return ERR_PTR(-ENOMEM);
> +	folio = f2fs_grab_cache_folio(mapping, index, for_write);
> +	if (IS_ERR(folio))
> +		return folio;
>   
>   	if (f2fs_lookup_read_extent_cache_block(inode, index,
>   						&dn.data_blkaddr)) {
> @@ -1249,9 +1248,9 @@ struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
>   		goto put_err;
>   	}
>   got_it:
> -	if (PageUptodate(page)) {
> -		unlock_page(page);
> -		return page;
> +	if (folio_test_uptodate(folio)) {
> +		folio_unlock(folio);
> +		return folio;
>   	}
>   
>   	/*
> @@ -1262,21 +1261,21 @@ struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
>   	 * f2fs_init_inode_metadata.
>   	 */
>   	if (dn.data_blkaddr == NEW_ADDR) {
> -		zero_user_segment(page, 0, PAGE_SIZE);
> -		if (!PageUptodate(page))
> -			SetPageUptodate(page);
> -		unlock_page(page);
> -		return page;
> +		folio_zero_segment(folio, 0, folio_size(folio));
> +		if (!folio_test_uptodate(folio))
> +			folio_mark_uptodate(folio);
> +		folio_unlock(folio);
> +		return folio;
>   	}
>   
> -	err = f2fs_submit_page_read(inode, page_folio(page), dn.data_blkaddr,
> +	err = f2fs_submit_page_read(inode, folio, dn.data_blkaddr,
>   						op_flags, for_write);
>   	if (err)
>   		goto put_err;
> -	return page;
> +	return folio;
>   
>   put_err:
> -	f2fs_put_page(page, 1);
> +	f2fs_folio_put(folio, true);
>   	return ERR_PTR(err);
>   }
>   
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 8f23bb082c6f..3e02df63499e 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -3895,8 +3895,8 @@ int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count);
>   int f2fs_reserve_new_block(struct dnode_of_data *dn);
>   int f2fs_get_block_locked(struct dnode_of_data *dn, pgoff_t index);
>   int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index);
> -struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
> -			blk_opf_t op_flags, bool for_write, pgoff_t *next_pgofs);
> +struct folio *f2fs_get_read_data_folio(struct inode *inode, pgoff_t index,
> +		blk_opf_t op_flags, bool for_write, pgoff_t *next_pgofs);
>   struct page *f2fs_find_data_page(struct inode *inode, pgoff_t index,
>   							pgoff_t *next_pgofs);
>   struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index,
> @@ -3926,6 +3926,16 @@ int f2fs_init_post_read_wq(struct f2fs_sb_info *sbi);
>   void f2fs_destroy_post_read_wq(struct f2fs_sb_info *sbi);
>   extern const struct iomap_ops f2fs_iomap_ops;
>   
> +static inline struct page *f2fs_get_read_data_page(struct inode *inode,
> +		pgoff_t index, blk_opf_t op_flags, bool for_write,
> +		pgoff_t *next_pgofs)
> +{
> +	struct folio *folio = f2fs_get_read_data_folio(inode, index, op_flags,
> +			for_write, next_pgofs);
> +
	if (IS_ERR(folio))
		return ERR_CAST(folio));

> +	return &folio->page;
> +}
> +
>   /*
>    * gc.c
>    */


  reply	other threads:[~2025-02-28  7:37 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18  5:51 [PATCH 00/27] f2fs folio conversions for v6.15 Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 01/27] f2fs: Add f2fs_folio_wait_writeback() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 02/27] mm: Remove wait_for_stable_page() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 03/27] f2fs: Add f2fs_folio_put() Matthew Wilcox (Oracle)
2025-02-21  4:55   ` Jaegeuk Kim
2025-02-24  7:19     ` Jaegeuk Kim
2025-02-27 21:31       ` Jaegeuk Kim
2025-02-18  5:51 ` [PATCH 04/27] f2fs: Convert f2fs_flush_inline_data() to use a folio Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 05/27] f2fs: Convert f2fs_sync_node_pages() " Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 06/27] f2fs: Pass a folio to flush_dirty_inode() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 07/27] f2fs: Convert f2fs_fsync_node_pages() to use a folio Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 08/27] f2fs: Convert last_fsync_dnode() " Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 09/27] f2fs: Return a folio from last_fsync_dnode() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 10/27] f2fs: Add f2fs_grab_cache_folio() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 11/27] mm: Remove grab_cache_page_write_begin() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 12/27] f2fs: Use a folio in __get_node_page() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 13/27] f2fs: Use a folio in do_write_page() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 14/27] f2fs: Convert f2fs_write_end_io() to use a folio_iter Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 15/27] f2fs: Mark some functions as taking a const page pointer Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 16/27] f2fs: Convert f2fs_in_warm_node_list() to take a folio Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 17/27] f2fs: Add f2fs_get_node_folio() Matthew Wilcox (Oracle)
2025-03-01  1:15   ` Chao Yu
2025-03-01  1:59     ` Matthew Wilcox
2025-03-01  2:03     ` Matthew Wilcox
2025-03-03  3:15       ` Chao Yu
2025-02-18  5:51 ` [PATCH 18/27] f2fs: Use a folio throughout f2fs_truncate_inode_blocks() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 19/27] f2fs: Use a folio throughout __get_meta_page() Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 20/27] f2fs: Hoist the page_folio() call to the start of f2fs_merge_page_bio() Matthew Wilcox (Oracle)
2025-02-28  7:25   ` Chao Yu
2025-02-18  5:51 ` [PATCH 21/27] f2fs: Add f2fs_get_read_data_folio() Matthew Wilcox (Oracle)
2025-02-28  7:37   ` Chao Yu [this message]
2025-02-18  5:51 ` [PATCH 22/27] f2fs: Add f2fs_get_lock_data_folio() Matthew Wilcox (Oracle)
2025-02-28  7:37   ` Chao Yu
2025-02-18  5:51 ` [PATCH 23/27] f2fs: Convert move_data_page() to use a folio Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 24/27] f2fs: Convert truncate_partial_data_page() " Matthew Wilcox (Oracle)
2025-02-18  5:51 ` [PATCH 25/27] f2fs: Convert gc_data_segment() " Matthew Wilcox (Oracle)
2025-02-18  5:52 ` [PATCH 26/27] f2fs: Add f2fs_find_data_folio() Matthew Wilcox (Oracle)
2025-02-18  5:52 ` [PATCH 27/27] mm: Remove wait_on_page_locked() Matthew Wilcox (Oracle)
2025-02-21  2:27 ` [PATCH 00/27] f2fs folio conversions for v6.15 Jaegeuk Kim
2025-03-04  8:04 ` Chao Yu
2025-03-04 17:10 ` [f2fs-dev] " patchwork-bot+f2fs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4948a522-1302-462e-9256-1bb31d0ce7aa@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).