From: Josef Bacik <josef@toxicpanda.com>
To: Joanne Koong <joannelkoong@gmail.com>
Cc: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org,
bernd.schubert@fastmail.fm, willy@infradead.org,
kernel-team@meta.com
Subject: Re: [PATCH 12/13] fuse: convert direct io to use folios
Date: Fri, 18 Oct 2024 16:02:45 -0400 [thread overview]
Message-ID: <20241018200245.GC2473677@perftesting> (raw)
In-Reply-To: <20241002165253.3872513-13-joannelkoong@gmail.com>
On Wed, Oct 02, 2024 at 09:52:52AM -0700, Joanne Koong wrote:
> Convert direct io requests to use folios instead of pages.
>
> No functional changes.
>
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> ---
> fs/fuse/file.c | 88 ++++++++++++++++++++++----------------------------
> 1 file changed, 38 insertions(+), 50 deletions(-)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 1fa870fb3cc4..38ed9026f286 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -665,11 +665,11 @@ static void fuse_release_user_pages(struct fuse_args_pages *ap,
> {
> unsigned int i;
>
> - for (i = 0; i < ap->num_pages; i++) {
> + for (i = 0; i < ap->num_folios; i++) {
> if (should_dirty)
> - set_page_dirty_lock(ap->pages[i]);
> + folio_mark_dirty_lock(ap->folios[i]);
> if (ap->args.is_pinned)
> - unpin_user_page(ap->pages[i]);
> + unpin_folio(ap->folios[i]);
> }
> }
>
> @@ -739,24 +739,6 @@ static void fuse_aio_complete(struct fuse_io_priv *io, int err, ssize_t pos)
> kref_put(&io->refcnt, fuse_io_release);
> }
>
> -static struct fuse_io_args *fuse_io_alloc(struct fuse_io_priv *io,
> - unsigned int npages)
> -{
> - struct fuse_io_args *ia;
> -
> - ia = kzalloc(sizeof(*ia), GFP_KERNEL);
> - if (ia) {
> - ia->io = io;
> - ia->ap.pages = fuse_pages_alloc(npages, GFP_KERNEL,
> - &ia->ap.descs);
> - if (!ia->ap.pages) {
> - kfree(ia);
> - ia = NULL;
> - }
> - }
> - return ia;
> -}
> -
> static struct fuse_io_args *fuse_io_folios_alloc(struct fuse_io_priv *io,
> unsigned int nfolios)
> {
> @@ -776,12 +758,6 @@ static struct fuse_io_args *fuse_io_folios_alloc(struct fuse_io_priv *io,
> return ia;
> }
>
> -static void fuse_io_free(struct fuse_io_args *ia)
> -{
> - kfree(ia->ap.pages);
> - kfree(ia);
> -}
> -
> static void fuse_io_folios_free(struct fuse_io_args *ia)
> {
> kfree(ia->ap.folios);
> @@ -814,7 +790,7 @@ static void fuse_aio_complete_req(struct fuse_mount *fm, struct fuse_args *args,
> }
>
> fuse_aio_complete(io, err, pos);
> - fuse_io_free(ia);
> + fuse_io_folios_free(ia);
> }
>
> static ssize_t fuse_async_req_send(struct fuse_mount *fm,
> @@ -1518,10 +1494,11 @@ static inline size_t fuse_get_frag_size(const struct iov_iter *ii,
>
> static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii,
> size_t *nbytesp, int write,
> - unsigned int max_pages)
> + unsigned int max_folios)
> {
> size_t nbytes = 0; /* # bytes already packed in req */
> ssize_t ret = 0;
> + ssize_t i = 0;
>
> /* Special case for kernel I/O: can copy directly into the buffer */
> if (iov_iter_is_kvec(ii)) {
> @@ -1538,15 +1515,23 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii,
> return 0;
> }
>
> - while (nbytes < *nbytesp && ap->num_pages < max_pages) {
> - unsigned npages;
> + /*
> + * Until there is support for iov_iter_extract_folios(), we have to
> + * manually extract pages using iov_iter_extract_pages() and then
> + * copy that to a folios array.
> + */
> + struct page **pages = kzalloc((max_folios - ap->num_folios) * sizeof(struct page *),
> + GFP_KERNEL);
> + if (!pages)
> + return -ENOMEM;
> +
> + while (nbytes < *nbytesp && ap->num_folios < max_folios) {
> + unsigned nfolios;
> size_t start;
> - struct page **pt_pages;
>
> - pt_pages = &ap->pages[ap->num_pages];
> - ret = iov_iter_extract_pages(ii, &pt_pages,
> + ret = iov_iter_extract_pages(ii, &pages,
> *nbytesp - nbytes,
> - max_pages - ap->num_pages,
> + max_folios - ap->num_folios,
> 0, &start);
> if (ret < 0)
> break;
> @@ -1554,15 +1539,18 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii,
> nbytes += ret;
>
> ret += start;
> - npages = DIV_ROUND_UP(ret, PAGE_SIZE);
> + nfolios = DIV_ROUND_UP(ret, PAGE_SIZE);
>
> - ap->descs[ap->num_pages].offset = start;
> - fuse_page_descs_length_init(ap->descs, ap->num_pages, npages);
> + ap->folio_descs[ap->num_folios].offset = start;
> + fuse_folio_descs_length_init(ap->folio_descs, ap->num_folios, nfolios);
With this conversion fuse_page_descs_length_init now has no users, so I'd add a
followup patch at the end of the series to remove it. Thanks,
Josef
next prev parent reply other threads:[~2024-10-18 20:02 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-02 16:52 [PATCH 00/13] fuse: use folios instead of pages for requests Joanne Koong
2024-10-02 16:52 ` [PATCH 01/13] fuse: support folios in struct fuse_args_pages and fuse_copy_pages() Joanne Koong
2024-10-18 19:48 ` Josef Bacik
2024-10-02 16:52 ` [PATCH 02/13] fuse: add support in virtio for requests using folios Joanne Koong
2024-10-02 16:52 ` [PATCH 03/13] fuse: convert cuse to use folios Joanne Koong
2024-10-02 16:52 ` [PATCH 04/13] fuse: convert readlink " Joanne Koong
2024-10-02 16:52 ` [PATCH 05/13] fuse: convert readdir " Joanne Koong
2024-10-02 16:52 ` [PATCH 06/13] fuse: convert reads " Joanne Koong
2024-10-02 16:52 ` [PATCH 07/13] fuse: convert writes (non-writeback) " Joanne Koong
2024-10-02 16:52 ` [PATCH 08/13] fuse: convert ioctls " Joanne Koong
2024-10-02 16:52 ` [PATCH 09/13] fuse: convert retrieves " Joanne Koong
2024-10-02 16:52 ` [PATCH 10/13] fuse: convert writebacks " Joanne Koong
2024-10-02 16:52 ` [PATCH 11/13] mm/writeback: add folio_mark_dirty_lock() Joanne Koong
2024-10-18 20:01 ` Josef Bacik
2024-10-22 18:05 ` Joanne Koong
2024-10-02 16:52 ` [PATCH 12/13] fuse: convert direct io to use folios Joanne Koong
2024-10-18 20:02 ` Josef Bacik [this message]
2024-10-21 22:02 ` Joanne Koong
2024-10-02 16:52 ` [PATCH 13/13] fuse: remove pages for requests and exclusively " Joanne Koong
2024-10-18 20:07 ` [PATCH 00/13] fuse: use folios instead of pages for requests Josef Bacik
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=20241018200245.GC2473677@perftesting \
--to=josef@toxicpanda.com \
--cc=bernd.schubert@fastmail.fm \
--cc=joannelkoong@gmail.com \
--cc=kernel-team@meta.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--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).