linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-xfs <linux-xfs@vger.kernel.org>,
	William Kucharski <william.kucharski@oracle.com>,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com,
	linux-mm@kvack.org, ocfs2-devel@oss.oracle.com,
	Dave Chinner <dchinner@redhat.com>,
	linux-fsdevel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-ext4@vger.kernel.org, linux-erofs@lists.ozlabs.org,
	linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v10 24/25] fuse: Convert from readpages to readahead
Date: Wed, 25 Mar 2020 10:42:56 +0100	[thread overview]
Message-ID: <CAJfpegu7EFcWrg3bP+-2BX_kb52RrzBCo_U3QKYzUkZfe4EjDA@mail.gmail.com> (raw)
In-Reply-To: <20200323202259.13363-25-willy@infradead.org>

On Mon, Mar 23, 2020 at 9:23 PM Matthew Wilcox <willy@infradead.org> wrote:
>
> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
>
> Use the new readahead operation in fuse.  Switching away from the
> read_cache_pages() helper gets rid of an implicit call to put_page(),
> so we can get rid of the get_page() call in fuse_readpages_fill().
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Reviewed-by: Dave Chinner <dchinner@redhat.com>
> Reviewed-by: William Kucharski <william.kucharski@oracle.com>
> ---
>  fs/fuse/file.c | 46 +++++++++++++++++++---------------------------
>  1 file changed, 19 insertions(+), 27 deletions(-)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 9d67b830fb7a..5749505bcff6 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -923,9 +923,8 @@ struct fuse_fill_data {
>         unsigned int max_pages;
>  };
>
> -static int fuse_readpages_fill(void *_data, struct page *page)
> +static int fuse_readpages_fill(struct fuse_fill_data *data, struct page *page)
>  {
> -       struct fuse_fill_data *data = _data;
>         struct fuse_io_args *ia = data->ia;
>         struct fuse_args_pages *ap = &ia->ap;
>         struct inode *inode = data->inode;
> @@ -941,10 +940,8 @@ static int fuse_readpages_fill(void *_data, struct page *page)
>                                         fc->max_pages);
>                 fuse_send_readpages(ia, data->file);
>                 data->ia = ia = fuse_io_alloc(NULL, data->max_pages);
> -               if (!ia) {
> -                       unlock_page(page);
> +               if (!ia)
>                         return -ENOMEM;
> -               }
>                 ap = &ia->ap;
>         }
>
> @@ -954,7 +951,6 @@ static int fuse_readpages_fill(void *_data, struct page *page)
>                 return -EIO;
>         }
>
> -       get_page(page);
>         ap->pages[ap->num_pages] = page;
>         ap->descs[ap->num_pages].length = PAGE_SIZE;
>         ap->num_pages++;
> @@ -962,37 +958,33 @@ static int fuse_readpages_fill(void *_data, struct page *page)
>         return 0;
>  }
>
> -static int fuse_readpages(struct file *file, struct address_space *mapping,
> -                         struct list_head *pages, unsigned nr_pages)
> +static void fuse_readahead(struct readahead_control *rac)
>  {
> -       struct inode *inode = mapping->host;
> +       struct inode *inode = rac->mapping->host;
>         struct fuse_conn *fc = get_fuse_conn(inode);
>         struct fuse_fill_data data;
> -       int err;
> +       struct page *page;
>
> -       err = -EIO;
>         if (is_bad_inode(inode))
> -               goto out;
> +               return;
>
> -       data.file = file;
> +       data.file = rac->file;
>         data.inode = inode;
> -       data.nr_pages = nr_pages;
> -       data.max_pages = min_t(unsigned int, nr_pages, fc->max_pages);
> -;
> +       data.nr_pages = readahead_count(rac);
> +       data.max_pages = min_t(unsigned int, data.nr_pages, fc->max_pages);
>         data.ia = fuse_io_alloc(NULL, data.max_pages);
> -       err = -ENOMEM;
>         if (!data.ia)
> -               goto out;
> +               return;
>
> -       err = read_cache_pages(mapping, pages, fuse_readpages_fill, &data);
> -       if (!err) {
> -               if (data.ia->ap.num_pages)
> -                       fuse_send_readpages(data.ia, file);
> -               else
> -                       fuse_io_free(data.ia);
> +       while ((page = readahead_page(rac))) {
> +               if (fuse_readpages_fill(&data, page) != 0)

Shouldn't this unlock + put page on error?

Otherwise looks good.

Thanks,
Miklos

  reply	other threads:[~2020-03-25  9:43 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-23 20:22 [PATCH v10 00/25] Change readahead API Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 01/25] mm: Move readahead prototypes from mm.h Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 02/25] mm: Return void from various readahead functions Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 03/25] mm: Ignore return value of ->readpages Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 04/25] mm: Move readahead nr_pages check into read_pages Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 05/25] mm: Add new readahead_control API Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 06/25] mm: Use readahead_control to pass arguments Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 07/25] mm: Rename various 'offset' parameters to 'index' Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 08/25] mm: rename readahead loop variable to 'i' Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 09/25] mm: Remove 'page_offset' from readahead loop Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 10/25] mm: Put readahead pages in cache earlier Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 11/25] mm: Add readahead address space operation Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 12/25] mm: Move end_index check out of readahead loop Matthew Wilcox
2020-03-23 20:49   ` Eric Biggers
2020-03-24  8:40   ` Christoph Hellwig
2020-03-23 20:22 ` [PATCH v10 13/25] mm: Add page_cache_readahead_unbounded Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 14/25] mm: Document why we don't set PageReadahead Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 15/25] mm: Use memalloc_nofs_save in readahead path Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 16/25] fs: Convert mpage_readpages to mpage_readahead Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 17/25] btrfs: Convert from readpages to readahead Matthew Wilcox
2020-03-26 16:53   ` David Sterba
2020-03-23 20:22 ` [PATCH v10 18/25] erofs: Convert uncompressed files " Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 19/25] erofs: Convert compressed " Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 20/25] ext4: Convert " Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 21/25] ext4: Pass the inode to ext4_mpage_readpages Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 22/25] f2fs: Convert from readpages to readahead Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 23/25] f2fs: Pass the inode to f2fs_mpage_readpages Matthew Wilcox
2020-03-23 20:22 ` [PATCH v10 24/25] fuse: Convert from readpages to readahead Matthew Wilcox
2020-03-25  9:42   ` Miklos Szeredi [this message]
2020-03-25 12:02     ` Matthew Wilcox
2020-03-25 14:43       ` Miklos Szeredi
2020-03-25 15:32         ` Matthew Wilcox
2020-03-25 15:54           ` Miklos Szeredi
2020-03-23 20:22 ` [PATCH v10 25/25] iomap: " Matthew Wilcox

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=CAJfpegu7EFcWrg3bP+-2BX_kb52RrzBCo_U3QKYzUkZfe4EjDA@mail.gmail.com \
    --to=miklos@szeredi.hu \
    --cc=akpm@linux-foundation.org \
    --cc=cluster-devel@redhat.com \
    --cc=dchinner@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=ocfs2-devel@oss.oracle.com \
    --cc=william.kucharski@oracle.com \
    --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).