All of lore.kernel.org
 help / color / mirror / Atom feed
From: Goldwyn Rodrigues <rgoldwyn@suse.de>
To: David Sterba <dsterba@suse.cz>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: Re: [PATCH 3/4] btrfs: convert relocate_one_page() to relocate_one_folio()
Date: Tue, 23 Jan 2024 10:36:45 -0600	[thread overview]
Message-ID: <dyk4c6cip5qfbdmtlgmkxzuhsoyeub6xzppe33rxrbpz3cwekw@eassyo2qkoqn> (raw)
In-Reply-To: <20240122205244.GY31555@twin.jikos.cz>

On 21:52 22/01, David Sterba wrote:
> On Thu, Jan 18, 2024 at 01:46:39PM -0600, Goldwyn Rodrigues wrote:
> > From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> > 
> > Convert page references to folios and call the respective folio
> > functions.
> > 
> > Since find_or_create_page() takes a mask argument, call
> > __filemap_get_folio() instead of filemap_grab_folio().
> > 
> > Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
> > ---
> >  fs/btrfs/relocation.c | 87 ++++++++++++++++++++++---------------------
> >  1 file changed, 44 insertions(+), 43 deletions(-)
> > 
> > diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> > index c365bfc60652..f4fd4257adae 100644
> > --- a/fs/btrfs/relocation.c
> > +++ b/fs/btrfs/relocation.c
> > @@ -2849,7 +2849,7 @@ static noinline_for_stack int prealloc_file_extent_cluster(
> >  	 * btrfs_do_readpage() call of previously relocated file cluster.
> >  	 *
> >  	 * If the current cluster starts in the above range, btrfs_do_readpage()
> > -	 * will skip the read, and relocate_one_page() will later writeback
> > +	 * will skip the read, and relocate_one_folio() will later writeback
> >  	 * the padding zeros as new data, causing data corruption.
> >  	 *
> >  	 * Here we have to manually invalidate the range (i_size, PAGE_END + 1).
> > @@ -2983,68 +2983,69 @@ static u64 get_cluster_boundary_end(const struct file_extent_cluster *cluster,
> >  	return cluster->boundary[cluster_nr + 1] - 1;
> >  }
> >  
> > -static int relocate_one_page(struct inode *inode, struct file_ra_state *ra,
> > +static int relocate_one_folio(struct inode *inode, struct file_ra_state *ra,
> >  			     const struct file_extent_cluster *cluster,
> > -			     int *cluster_nr, unsigned long page_index)
> > +			     int *cluster_nr, unsigned long index)
> >  {
> >  	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
> >  	u64 offset = BTRFS_I(inode)->index_cnt;
> >  	const unsigned long last_index = (cluster->end - offset) >> PAGE_SHIFT;
> >  	gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping);
> > -	struct page *page;
> > -	u64 page_start;
> > -	u64 page_end;
> > +	struct folio *folio;
> > +	u64 start;
> > +	u64 end;
> >  	u64 cur;
> >  	int ret;
> >  
> > -	ASSERT(page_index <= last_index);
> > -	page = find_lock_page(inode->i_mapping, page_index);
> > -	if (!page) {
> > +	ASSERT(index <= last_index);
> > +	folio = filemap_lock_folio(inode->i_mapping, index);
> > +	if (IS_ERR(folio)) {
> >  		page_cache_sync_readahead(inode->i_mapping, ra, NULL,
> 
> How do page_cache_sync_readahead and folios interact? We still have
> page == folio but the large folios are on the way, so do we need
> something to make it work? If there's an assumption about pages and
> folios this could be turned to an assertion so we don't forget about
> that later.

For now page and folio are the same and the assumption is folio size is
PAGE_SIZE. I am adding WARN_ON(folio_order(folio)) after an uptodate
folio is received to warn if the folio size changes.

-- 
Goldwyn

  reply	other threads:[~2024-01-23 16:35 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 [this message]
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
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=dyk4c6cip5qfbdmtlgmkxzuhsoyeub6xzppe33rxrbpz3cwekw@eassyo2qkoqn \
    --to=rgoldwyn@suse.de \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.