* [RFC PATCH] NFSD: Use vfs_iocb_iter_read()
@ 2025-06-13 0:36 Chuck Lever
2025-06-13 2:03 ` NeilBrown
2025-06-13 5:35 ` Christoph Hellwig
0 siblings, 2 replies; 3+ messages in thread
From: Chuck Lever @ 2025-06-13 0:36 UTC (permalink / raw)
To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey
Cc: linux-nfs, Chuck Lever, Christoph Hellwig
From: Chuck Lever <chuck.lever@oracle.com>
Refactor: Enable the use of RWF_ flags to control individual I/O
operations.
Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/nfsd/vfs.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index cd689df2ca5d..f20bacd9b224 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1086,10 +1086,18 @@ __be32 nfsd_iter_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
{
unsigned long v, total;
struct iov_iter iter;
- loff_t ppos = offset;
+ struct kiocb kiocb;
ssize_t host_err;
size_t len;
+ init_sync_kiocb(&kiocb, file);
+ host_err = kiocb_set_rw_flags(&kiocb, 0, READ);
+ if (host_err) {
+ *count = 0;
+ goto out;
+ }
+ kiocb.ki_pos = offset;
+
v = 0;
total = *count;
while (total) {
@@ -1104,7 +1112,8 @@ __be32 nfsd_iter_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
trace_nfsd_read_vector(rqstp, fhp, offset, *count);
iov_iter_bvec(&iter, ITER_DEST, rqstp->rq_bvec, v, *count);
- host_err = vfs_iter_read(file, &iter, &ppos, 0);
+ host_err = vfs_iocb_iter_read(file, &kiocb, &iter);
+out:
return nfsd_finish_read(rqstp, fhp, file, offset, count, eof, host_err);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] NFSD: Use vfs_iocb_iter_read()
2025-06-13 0:36 [RFC PATCH] NFSD: Use vfs_iocb_iter_read() Chuck Lever
@ 2025-06-13 2:03 ` NeilBrown
2025-06-13 5:35 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: NeilBrown @ 2025-06-13 2:03 UTC (permalink / raw)
To: Chuck Lever
Cc: Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey, linux-nfs,
Chuck Lever, Christoph Hellwig
On Fri, 13 Jun 2025, Chuck Lever wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
>
> Refactor: Enable the use of RWF_ flags to control individual I/O
> operations.
RWF_ flags such as .... ???
I'm guessing RWF_DIRECT and maybe RWF_NOWAIT based on the earlier
conversation. Might be useful to provide this as explicit motivation.
But seeing they will be passed to kiocb_set_rw_flags(), shouldn't we be
talking about the IOCB_ versions of the flags? The only caller of
kiocb_set_rw_flags() I can find which doesn't pass zero is aio_prep_rw()
and it uses the IOCB_ versions.
And should we be changing the vfs_iter_write() to vfs_iocb_iter_write()
too, just for consistency?
>
> Suggested-by: Christoph Hellwig <hch@infradead.org>
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: NeilBrown <neil@brown.name>
3 more callers to go and vfs_iter_read() could be discarded.
NeilBrown
> ---
> fs/nfsd/vfs.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index cd689df2ca5d..f20bacd9b224 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -1086,10 +1086,18 @@ __be32 nfsd_iter_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
> {
> unsigned long v, total;
> struct iov_iter iter;
> - loff_t ppos = offset;
> + struct kiocb kiocb;
> ssize_t host_err;
> size_t len;
>
> + init_sync_kiocb(&kiocb, file);
> + host_err = kiocb_set_rw_flags(&kiocb, 0, READ);
> + if (host_err) {
> + *count = 0;
> + goto out;
> + }
> + kiocb.ki_pos = offset;
> +
> v = 0;
> total = *count;
> while (total) {
> @@ -1104,7 +1112,8 @@ __be32 nfsd_iter_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
>
> trace_nfsd_read_vector(rqstp, fhp, offset, *count);
> iov_iter_bvec(&iter, ITER_DEST, rqstp->rq_bvec, v, *count);
> - host_err = vfs_iter_read(file, &iter, &ppos, 0);
> + host_err = vfs_iocb_iter_read(file, &kiocb, &iter);
> +out:
> return nfsd_finish_read(rqstp, fhp, file, offset, count, eof, host_err);
> }
>
> --
> 2.49.0
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] NFSD: Use vfs_iocb_iter_read()
2025-06-13 0:36 [RFC PATCH] NFSD: Use vfs_iocb_iter_read() Chuck Lever
2025-06-13 2:03 ` NeilBrown
@ 2025-06-13 5:35 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2025-06-13 5:35 UTC (permalink / raw)
To: Chuck Lever
Cc: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey,
linux-nfs, Chuck Lever, Christoph Hellwig
On Thu, Jun 12, 2025 at 08:36:53PM -0400, Chuck Lever wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
>
> Refactor: Enable the use of RWF_ flags to control individual I/O
> operations.
The IOCB_ ones, really.
> + host_err = kiocb_set_rw_flags(&kiocb, 0, READ);
> + if (host_err) {
> + *count = 0;
> + goto out;
> + }
And if you don't want to explicitly convert from RWF_* flags, this
is pointless. Just drop it for now and explicitly set the IOCB_
flags we want once we add some.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-13 5:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-13 0:36 [RFC PATCH] NFSD: Use vfs_iocb_iter_read() Chuck Lever
2025-06-13 2:03 ` NeilBrown
2025-06-13 5:35 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox