diff mbox series

[v3,06/10] fuse: convert fuse_do_readpage to use folios

Message ID 0fe4cfc0e7d290e539abc215501ebebf658fd2b2.1727469663.git.josef@toxicpanda.com (mailing list archive)
State New
Headers show
Series fuse: folio conversions | expand

Commit Message

Josef Bacik Sept. 27, 2024, 8:44 p.m. UTC
Now that the buffered write path is using folios, convert
fuse_do_readpage() to take a folio instead of a page, update it to use
the appropriate folio helpers, and update the callers to pass in the
folio directly instead of a page.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/fuse/file.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

Comments

Joanne Koong Sept. 27, 2024, 10:51 p.m. UTC | #1
On Fri, Sep 27, 2024 at 1:54 PM Josef Bacik <josef@toxicpanda.com> wrote:
>
> Now that the buffered write path is using folios, convert
> fuse_do_readpage() to take a folio instead of a page, update it to use
> the appropriate folio helpers, and update the callers to pass in the
> folio directly instead of a page.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
>  fs/fuse/file.c | 25 ++++++++++++-------------
>  1 file changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 2af9ec67a8e7..8a4621939d3b 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -858,12 +858,13 @@ static void fuse_short_read(struct inode *inode, u64 attr_ver, size_t num_read,
>         }
>  }
>
> -static int fuse_do_readpage(struct file *file, struct page *page)
> +static int fuse_do_readpage(struct file *file, struct folio *folio)

Should we also rename this to fuse_do_readfolio instead of fuse_do_readpage?

>  {
> -       struct inode *inode = page->mapping->host;
> +       struct inode *inode = folio->mapping->host;
>         struct fuse_mount *fm = get_fuse_mount(inode);
> -       loff_t pos = page_offset(page);
> +       loff_t pos = folio_pos(folio);
>         struct fuse_page_desc desc = { .length = PAGE_SIZE };
> +       struct page *page = &folio->page;
>         struct fuse_io_args ia = {
>                 .ap.args.page_zeroing = true,
>                 .ap.args.out_pages = true,
> @@ -875,11 +876,10 @@ static int fuse_do_readpage(struct file *file, struct page *page)
>         u64 attr_ver;
>
>         /*
> -        * Page writeback can extend beyond the lifetime of the
> -        * page-cache page, so make sure we read a properly synced
> -        * page.
> +        * Folio writeback can extend beyond the lifetime of the
> +        * folio, so make sure we read a properly synced folio.

Is this comment true that folio writeback can extend beyond the
lifetime of the folio? Or is it that folio writeback can extend beyond
the lifetime of the folio in the page cache?

>          */
> -       fuse_wait_on_page_writeback(inode, page->index);
> +       fuse_wait_on_folio_writeback(inode, folio);
>
>         attr_ver = fuse_get_attr_version(fm->fc);
>
> @@ -897,25 +897,24 @@ static int fuse_do_readpage(struct file *file, struct page *page)
>         if (res < desc.length)
>                 fuse_short_read(inode, attr_ver, res, &ia.ap);
>
> -       SetPageUptodate(page);
> +       folio_mark_uptodate(folio);
>
>         return 0;
>  }
>
>  static int fuse_read_folio(struct file *file, struct folio *folio)
>  {
> -       struct page *page = &folio->page;
> -       struct inode *inode = page->mapping->host;
> +       struct inode *inode = folio->mapping->host;
>         int err;
>
>         err = -EIO;
>         if (fuse_is_bad(inode))
>                 goto out;
>
> -       err = fuse_do_readpage(file, page);
> +       err = fuse_do_readpage(file, folio);
>         fuse_invalidate_atime(inode);
>   out:
> -       unlock_page(page);
> +       folio_unlock(folio);
>         return err;
>  }
>
> @@ -2444,7 +2443,7 @@ static int fuse_write_begin(struct file *file, struct address_space *mapping,
>                         folio_zero_segment(folio, 0, off);
>                 goto success;
>         }
> -       err = fuse_do_readpage(file, &folio->page);
> +       err = fuse_do_readpage(file, folio);
>         if (err)
>                 goto cleanup;
>  success:
> --
> 2.43.0
>
>
Josef Bacik Sept. 30, 2024, 1:39 p.m. UTC | #2
On Fri, Sep 27, 2024 at 03:51:17PM -0700, Joanne Koong wrote:
> On Fri, Sep 27, 2024 at 1:54 PM Josef Bacik <josef@toxicpanda.com> wrote:
> >
> > Now that the buffered write path is using folios, convert
> > fuse_do_readpage() to take a folio instead of a page, update it to use
> > the appropriate folio helpers, and update the callers to pass in the
> > folio directly instead of a page.
> >
> > Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> > ---
> >  fs/fuse/file.c | 25 ++++++++++++-------------
> >  1 file changed, 12 insertions(+), 13 deletions(-)
> >
> > diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> > index 2af9ec67a8e7..8a4621939d3b 100644
> > --- a/fs/fuse/file.c
> > +++ b/fs/fuse/file.c
> > @@ -858,12 +858,13 @@ static void fuse_short_read(struct inode *inode, u64 attr_ver, size_t num_read,
> >         }
> >  }
> >
> > -static int fuse_do_readpage(struct file *file, struct page *page)
> > +static int fuse_do_readpage(struct file *file, struct folio *folio)
> 
> Should we also rename this to fuse_do_readfolio instead of fuse_do_readpage?
> 
> >  {
> > -       struct inode *inode = page->mapping->host;
> > +       struct inode *inode = folio->mapping->host;
> >         struct fuse_mount *fm = get_fuse_mount(inode);
> > -       loff_t pos = page_offset(page);
> > +       loff_t pos = folio_pos(folio);
> >         struct fuse_page_desc desc = { .length = PAGE_SIZE };
> > +       struct page *page = &folio->page;
> >         struct fuse_io_args ia = {
> >                 .ap.args.page_zeroing = true,
> >                 .ap.args.out_pages = true,
> > @@ -875,11 +876,10 @@ static int fuse_do_readpage(struct file *file, struct page *page)
> >         u64 attr_ver;
> >
> >         /*
> > -        * Page writeback can extend beyond the lifetime of the
> > -        * page-cache page, so make sure we read a properly synced
> > -        * page.
> > +        * Folio writeback can extend beyond the lifetime of the
> > +        * folio, so make sure we read a properly synced folio.
> 
> Is this comment true that folio writeback can extend beyond the
> lifetime of the folio? Or is it that folio writeback can extend beyond
> the lifetime of the folio in the page cache?

This is true today because of the temporary pages.  We can have writebackout for
the range of the folio outstanding because the temporary pages can still be in
flight and we might have reclaimed the folio that existed for that given range.
Once you delete the temporary pages thing the comment will no longer be correct.
I'll update the comment to be more clear, thanks,

Josef
diff mbox series

Patch

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 2af9ec67a8e7..8a4621939d3b 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -858,12 +858,13 @@  static void fuse_short_read(struct inode *inode, u64 attr_ver, size_t num_read,
 	}
 }
 
-static int fuse_do_readpage(struct file *file, struct page *page)
+static int fuse_do_readpage(struct file *file, struct folio *folio)
 {
-	struct inode *inode = page->mapping->host;
+	struct inode *inode = folio->mapping->host;
 	struct fuse_mount *fm = get_fuse_mount(inode);
-	loff_t pos = page_offset(page);
+	loff_t pos = folio_pos(folio);
 	struct fuse_page_desc desc = { .length = PAGE_SIZE };
+	struct page *page = &folio->page;
 	struct fuse_io_args ia = {
 		.ap.args.page_zeroing = true,
 		.ap.args.out_pages = true,
@@ -875,11 +876,10 @@  static int fuse_do_readpage(struct file *file, struct page *page)
 	u64 attr_ver;
 
 	/*
-	 * Page writeback can extend beyond the lifetime of the
-	 * page-cache page, so make sure we read a properly synced
-	 * page.
+	 * Folio writeback can extend beyond the lifetime of the
+	 * folio, so make sure we read a properly synced folio.
 	 */
-	fuse_wait_on_page_writeback(inode, page->index);
+	fuse_wait_on_folio_writeback(inode, folio);
 
 	attr_ver = fuse_get_attr_version(fm->fc);
 
@@ -897,25 +897,24 @@  static int fuse_do_readpage(struct file *file, struct page *page)
 	if (res < desc.length)
 		fuse_short_read(inode, attr_ver, res, &ia.ap);
 
-	SetPageUptodate(page);
+	folio_mark_uptodate(folio);
 
 	return 0;
 }
 
 static int fuse_read_folio(struct file *file, struct folio *folio)
 {
-	struct page *page = &folio->page;
-	struct inode *inode = page->mapping->host;
+	struct inode *inode = folio->mapping->host;
 	int err;
 
 	err = -EIO;
 	if (fuse_is_bad(inode))
 		goto out;
 
-	err = fuse_do_readpage(file, page);
+	err = fuse_do_readpage(file, folio);
 	fuse_invalidate_atime(inode);
  out:
-	unlock_page(page);
+	folio_unlock(folio);
 	return err;
 }
 
@@ -2444,7 +2443,7 @@  static int fuse_write_begin(struct file *file, struct address_space *mapping,
 			folio_zero_segment(folio, 0, off);
 		goto success;
 	}
-	err = fuse_do_readpage(file, &folio->page);
+	err = fuse_do_readpage(file, folio);
 	if (err)
 		goto cleanup;
 success: