linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Eric Biggers <ebiggers@kernel.org>
Cc: tytso@mit.edu, adilger.kernel@dilger.ca,
	linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v2 29/29] ext4: Use a folio in ext4_read_merkle_tree_page
Date: Tue, 18 Apr 2023 14:08:05 +0100	[thread overview]
Message-ID: <ZD6WNSKCjGGEFLB3@casper.infradead.org> (raw)
In-Reply-To: <20230418065042.GA121074@quark.localdomain>

On Mon, Apr 17, 2023 at 11:50:42PM -0700, Eric Biggers wrote:
> Hi Matthew,
> 
> On Fri, Mar 24, 2023 at 06:01:29PM +0000, Matthew Wilcox (Oracle) wrote:
> > This is an implementation of fsverity_operations read_merkle_tree_page,
> > so it must still return the precise page asked for, but we can use the
> > folio API to reduce the number of conversions between folios & pages.
> > 
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> > ---
> >  fs/ext4/verity.c | 14 +++++++-------
> >  1 file changed, 7 insertions(+), 7 deletions(-)
> > 
> > diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c
> > index afe847c967a4..3b01247066dd 100644
> > --- a/fs/ext4/verity.c
> > +++ b/fs/ext4/verity.c
> > @@ -361,21 +361,21 @@ static struct page *ext4_read_merkle_tree_page(struct inode *inode,
> >  					       pgoff_t index,
> >  					       unsigned long num_ra_pages)
> >  {
> > -	struct page *page;
> > +	struct folio *folio;
> >  
> >  	index += ext4_verity_metadata_pos(inode) >> PAGE_SHIFT;
> >  
> > -	page = find_get_page_flags(inode->i_mapping, index, FGP_ACCESSED);
> > -	if (!page || !PageUptodate(page)) {
> > +	folio = __filemap_get_folio(inode->i_mapping, index, FGP_ACCESSED, 0);
> > +	if (!folio || !folio_test_uptodate(folio)) {
> >  		DEFINE_READAHEAD(ractl, NULL, NULL, inode->i_mapping, index);
> >  
> > -		if (page)
> > -			put_page(page);
> > +		if (folio)
> > +			folio_put(folio);
> >  		else if (num_ra_pages > 1)
> >  			page_cache_ra_unbounded(&ractl, num_ra_pages, 0);
> > -		page = read_mapping_page(inode->i_mapping, index, NULL);
> > +		folio = read_mapping_folio(inode->i_mapping, index, NULL);
> >  	}
> > -	return page;
> > +	return folio_file_page(folio, index);
> 
> This is not working at all, since it dereferences ERR_PTR(-ENOENT).  I think it
> needs:

Argh.  Christoph changed the return value of __filemap_get_folio().

>  	folio = __filemap_get_folio(inode->i_mapping, index, FGP_ACCESSED, 0);
> -	if (!folio || !folio_test_uptodate(folio)) {
> +	if (folio == ERR_PTR(-ENOENT) || !folio_test_uptodate(folio)) {

This should be "if (IS_ERR(folio) || !folio_test_uptodate(folio)) {"

But we can't carry this change in Ted's tree because it doesn't have
Christoph's change.  And we can't carry it in Andrew's tree because it
doesn't have my ext4 change.

>  		DEFINE_READAHEAD(ractl, NULL, NULL, inode->i_mapping, index);
>  
> -		if (folio)
> +		if (!IS_ERR(folio))
>  			folio_put(folio);
>  		else if (num_ra_pages > 1)
>  			page_cache_ra_unbounded(&ractl, num_ra_pages, 0);
>  		folio = read_mapping_folio(inode->i_mapping, index, NULL);
>  	}
> +	if (IS_ERR(folio))
> +		return ERR_CAST(folio);

return &folio->page;

>  	return folio_file_page(folio, index);
>  }
>  

  reply	other threads:[~2023-04-18 13:08 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24 18:01 [PATCH v2 00/29] Convert most of ext4 to folios Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 01/29] fs: Add FGP_WRITEBEGIN Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 02/29] fscrypt: Add some folio helper functions Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 03/29] ext4: Convert ext4_bio_write_page() to use a folio Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 04/29] ext4: Convert ext4_finish_bio() to use folios Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 05/29] ext4: Turn mpage_process_page() into mpage_process_folio() Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 06/29] ext4: Convert mpage_submit_page() to mpage_submit_folio() Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 07/29] ext4: Convert mpage_page_done() to mpage_folio_done() Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 08/29] ext4: Convert ext4_bio_write_page() to ext4_bio_write_folio() Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 09/29] ext4: Convert ext4_readpage_inline() to take a folio Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 10/29] ext4: Convert ext4_convert_inline_data_to_extent() to use " Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 11/29] ext4: Convert ext4_try_to_write_inline_data() " Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 12/29] ext4: Convert ext4_da_convert_inline_data_to_extent() " Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 13/29] ext4: Convert ext4_da_write_inline_data_begin() " Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 14/29] ext4: Convert ext4_read_inline_page() to ext4_read_inline_folio() Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 15/29] ext4: Convert ext4_write_inline_data_end() to use a folio Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 16/29] ext4: Convert ext4_write_begin() " Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 17/29] ext4: Convert ext4_write_end() " Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 18/29] ext4: Use a folio in ext4_journalled_write_end() Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 19/29] ext4: Convert ext4_journalled_zero_new_buffers() to use a folio Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 20/29] ext4: Convert __ext4_block_zero_page_range() " Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 21/29] ext4: Convert ext4_page_nomap_can_writeout to ext4_folio_nomap_can_writeout Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 22/29] ext4: Use a folio in ext4_da_write_begin() Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 23/29] ext4: Convert ext4_mpage_readpages() to work on folios Matthew Wilcox (Oracle)
2023-03-24 22:29   ` Eric Biggers
2023-03-26  3:25     ` Matthew Wilcox
2023-03-24 18:01 ` [PATCH v2 24/29] ext4: Convert ext4_block_write_begin() to take a folio Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 25/29] ext4: Use a folio in ext4_page_mkwrite() Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 26/29] ext4: Use a folio iterator in __read_end_io() Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 27/29] ext4: Convert mext_page_mkuptodate() to take a folio Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 28/29] ext4: Convert pagecache_read() to use " Matthew Wilcox (Oracle)
2023-03-24 18:01 ` [PATCH v2 29/29] ext4: Use a folio in ext4_read_merkle_tree_page Matthew Wilcox (Oracle)
2023-04-18  6:50   ` Eric Biggers
2023-04-18 13:08     ` Matthew Wilcox [this message]
2023-04-15  2:29 ` [PATCH v2 00/29] Convert most of ext4 to folios Theodore Ts'o

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=ZD6WNSKCjGGEFLB3@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=adilger.kernel@dilger.ca \
    --cc=ebiggers@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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).