Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: Goldwyn Rodrigues <rgoldwyn@suse.de>
Cc: linux-btrfs@vger.kernel.org, Goldwyn Rodrigues <rgoldwyn@suse.com>
Subject: Re: [PATCH 4/4] btrfs: page to folio conversion in put_file_data()
Date: Thu, 18 Jan 2024 13:48:06 -0800	[thread overview]
Message-ID: <20240118214806.GD1356080@zen.localdomain> (raw)
In-Reply-To: <861fb1618d04ccb56c00ac78b4c6ca81dc9a59e4.1705605787.git.rgoldwyn@suse.com>

On Thu, Jan 18, 2024 at 01:46:40PM -0600, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> 
> Use folio instead of page in put_file_data(). This converts usage of all
> page based functions to folio-based.
> 
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>

Reviewed-by: Boris Burkov <boris@bur.io>

> ---
>  fs/btrfs/send.c | 42 +++++++++++++++++++++---------------------
>  1 file changed, 21 insertions(+), 21 deletions(-)
> 
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index 7902298c1f25..0de3d4163f6b 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -5257,10 +5257,11 @@ static int put_file_data(struct send_ctx *sctx, u64 offset, u32 len)
>  {
>  	struct btrfs_root *root = sctx->send_root;
>  	struct btrfs_fs_info *fs_info = root->fs_info;
> -	struct page *page;
> +	struct folio *folio;
>  	pgoff_t index = offset >> PAGE_SHIFT;
>  	pgoff_t last_index;
>  	unsigned pg_offset = offset_in_page(offset);
> +	struct address_space *mapping = sctx->cur_inode->i_mapping;
>  	int ret;
>  
>  	ret = put_data_header(sctx, len);
> @@ -5273,44 +5274,43 @@ static int put_file_data(struct send_ctx *sctx, u64 offset, u32 len)
>  		unsigned cur_len = min_t(unsigned, len,
>  					 PAGE_SIZE - pg_offset);
>  
> -		page = find_lock_page(sctx->cur_inode->i_mapping, index);
> -		if (!page) {
> -			page_cache_sync_readahead(sctx->cur_inode->i_mapping,
> +		folio = filemap_lock_folio(mapping, index);
> +		if (IS_ERR(folio)) {
> +			page_cache_sync_readahead(mapping,
>  						  &sctx->ra, NULL, index,
>  						  last_index + 1 - index);
>  
> -			page = find_or_create_page(sctx->cur_inode->i_mapping,
> -						   index, GFP_KERNEL);
> -			if (!page) {
> -				ret = -ENOMEM;
> +	                folio = filemap_grab_folio(mapping, index);
> +			if (IS_ERR(folio)) {
> +				ret = PTR_ERR(folio);
>  				break;
>  			}
>  		}
>  
> -		if (PageReadahead(page))
> -			page_cache_async_readahead(sctx->cur_inode->i_mapping,
> -						   &sctx->ra, NULL, page_folio(page),
> +		if (folio_test_readahead(folio))
> +			page_cache_async_readahead(mapping,
> +						   &sctx->ra, NULL, folio,
>  						   index, last_index + 1 - index);
>  
> -		if (!PageUptodate(page)) {
> -			btrfs_read_folio(NULL, page_folio(page));
> -			lock_page(page);
> -			if (!PageUptodate(page)) {
> -				unlock_page(page);
> +		if (!folio_test_uptodate(folio)) {
> +			btrfs_read_folio(NULL, folio);
> +			folio_lock(folio);
> +			if (!folio_test_uptodate(folio)) {
> +				folio_unlock(folio);
>  				btrfs_err(fs_info,
>  			"send: IO error at offset %llu for inode %llu root %llu",
> -					page_offset(page), sctx->cur_ino,
> +					folio_pos(folio), sctx->cur_ino,
>  					sctx->send_root->root_key.objectid);
> -				put_page(page);
> +				folio_put(folio);
>  				ret = -EIO;
>  				break;
>  			}
>  		}
>  
> -		memcpy_from_page(sctx->send_buf + sctx->send_size, page,
> +		memcpy_from_folio(sctx->send_buf + sctx->send_size, folio,
>  				 pg_offset, cur_len);
> -		unlock_page(page);
> -		put_page(page);
> +		folio_unlock(folio);
> +		folio_put(folio);
>  		index++;
>  		pg_offset = 0;
>  		len -= cur_len;
> -- 
> 2.43.0
> 

  reply	other threads:[~2024-01-18 21:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1705605787.git.rgoldwyn@suse.com>
2024-01-18 19:46 ` [PATCH 1/4] btrfs: Use IS_ERR() instead of checking folio for NULL Goldwyn Rodrigues
2024-01-18 21:31   ` Boris Burkov
2024-01-19 14:53   ` David Sterba
2024-01-19 14:58     ` Goldwyn Rodrigues
2024-01-18 19:46 ` [PATCH 2/4] btrfs: page to folio conversion: prealloc_file_extent_cluster() Goldwyn Rodrigues
2024-01-18 21:34   ` Boris Burkov
2024-01-22 20:44   ` David Sterba
2024-01-18 19:46 ` [PATCH 3/4] btrfs: convert relocate_one_page() to relocate_one_folio() Goldwyn Rodrigues
2024-01-18 21:43   ` Boris Burkov
2024-01-22 20:53     ` David Sterba
2024-01-22 20:52   ` David Sterba
2024-01-23 16:36     ` Goldwyn Rodrigues
2024-01-18 19:46 ` [PATCH 4/4] btrfs: page to folio conversion in put_file_data() Goldwyn Rodrigues
2024-01-18 21:48   ` Boris Burkov [this message]
2024-01-22 20:55   ` David Sterba

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=20240118214806.GD1356080@zen.localdomain \
    --to=boris@bur.io \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=rgoldwyn@suse.com \
    --cc=rgoldwyn@suse.de \
    /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