From: John Hubbard <jhubbard@nvidia.com>
To: Jens Axboe <axboe@kernel.dk>, Jan Kara <jack@suse.cz>,
Christoph Hellwig <hch@infradead.org>,
Dave Chinner <dchinner@redhat.com>,
"Darrick J . Wong" <djwong@kernel.org>,
Theodore Ts'o <tytso@mit.edu>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Miklos Szeredi <miklos@szeredi.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Chaitanya Kulkarni <kch@nvidia.com>
Cc: <linux-block@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>,
<linux-xfs@vger.kernel.org>, <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
John Hubbard <jhubbard@nvidia.com>
Subject: [RFC PATCH 6/7] fuse: convert direct IO paths to use FOLL_PIN
Date: Fri, 25 Feb 2022 00:50:24 -0800 [thread overview]
Message-ID: <20220225085025.3052894-7-jhubbard@nvidia.com> (raw)
In-Reply-To: <20220225085025.3052894-1-jhubbard@nvidia.com>
Convert the fuse filesystem to support the new iov_iter_get_pages()
behavior. That routine now invokes pin_user_pages_fast(), which means that
such pages must be released via unpin_user_page(), rather than via
put_page().
This commit also removes any possibility of kernel pages being handled, in
the fuse_get_user_pages() call. Although this may seem like a steep price
to pay, Christoph Hellwig actually recommended it a few years ago for
nearly the same situation [1].
[1] https://lore.kernel.org/kvm/20190724061750.GA19397@infradead.org/
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
fs/fuse/dev.c | 5 ++++-
fs/fuse/file.c | 23 ++++++++---------------
2 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index e1b4a846c90d..a93037c96b89 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -675,7 +675,10 @@ static void fuse_copy_finish(struct fuse_copy_state *cs)
flush_dcache_page(cs->pg);
set_page_dirty_lock(cs->pg);
}
- put_page(cs->pg);
+ if (cs->pipebufs)
+ put_page(cs->pg);
+ else
+ unpin_user_page(cs->pg);
}
cs->pg = NULL;
}
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 94747bac3489..395c2fb613fb 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -619,7 +619,7 @@ static void fuse_release_user_pages(struct fuse_args_pages *ap,
for (i = 0; i < ap->num_pages; i++) {
if (should_dirty)
set_page_dirty_lock(ap->pages[i]);
- put_page(ap->pages[i]);
+ unpin_user_page(ap->pages[i]);
}
}
@@ -1382,20 +1382,13 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii,
size_t nbytes = 0; /* # bytes already packed in req */
ssize_t ret = 0;
- /* Special case for kernel I/O: can copy directly into the buffer */
- if (iov_iter_is_kvec(ii)) {
- unsigned long user_addr = fuse_get_user_addr(ii);
- size_t frag_size = fuse_get_frag_size(ii, *nbytesp);
-
- if (write)
- ap->args.in_args[1].value = (void *) user_addr;
- else
- ap->args.out_args[0].value = (void *) user_addr;
-
- iov_iter_advance(ii, frag_size);
- *nbytesp = frag_size;
- return 0;
- }
+ /*
+ * TODO: this warning can eventually be removed. It is just to help
+ * developers, during a transitional period, while direct IO code is
+ * moving over to FOLL_PIN pages.
+ */
+ if (WARN_ON_ONCE(!iter_is_iovec(ii)))
+ return -EOPNOTSUPP;
while (nbytes < *nbytesp && ap->num_pages < max_pages) {
unsigned npages;
--
2.35.1
next prev parent reply other threads:[~2022-02-25 8:50 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-25 8:50 [RFC PATCH 0/7] block, fs: convert Direct IO to FOLL_PIN John Hubbard
2022-02-25 8:50 ` [RFC PATCH 1/7] mm/gup: introduce pin_user_page() John Hubbard
2022-02-28 13:27 ` David Hildenbrand
2022-02-28 21:14 ` John Hubbard
2022-03-01 8:11 ` David Hildenbrand
2022-03-01 8:40 ` John Hubbard
2022-03-01 9:30 ` David Hildenbrand
2022-02-25 8:50 ` [RFC PATCH 2/7] block: add dio_w_*() wrappers for pin, unpin user pages John Hubbard
2022-02-25 8:50 ` [RFC PATCH 3/7] block, fs: assert that key paths use iovecs, and nothing else John Hubbard
2022-02-25 8:50 ` [RFC PATCH 4/7] block, bio, fs: initial pin_user_pages_fast() changes John Hubbard
2022-02-25 8:50 ` [RFC PATCH 5/7] NFS: direct-io: convert to FOLL_PIN pages John Hubbard
2022-02-25 8:50 ` John Hubbard [this message]
2022-02-25 8:50 ` [RFC PATCH 7/7] block, direct-io: flip the switch: use pin_user_pages_fast() John Hubbard
2022-02-25 12:05 ` [RFC PATCH 0/7] block, fs: convert Direct IO to FOLL_PIN Jan Kara
2022-02-25 16:14 ` Chaitanya Kulkarni
2022-02-25 16:40 ` Jan Kara
2022-02-25 19:36 ` John Hubbard
2022-02-25 22:20 ` John Hubbard
2022-02-25 13:12 ` David Hildenbrand
2022-02-25 21:10 ` John Hubbard
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=20220225085025.3052894-7-jhubbard@nvidia.com \
--to=jhubbard@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=dchinner@redhat.com \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=kch@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
/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