Thread (3 messages) 3 messages, 3 authors, 2025-06-13

Re: [RFC PATCH] NFSD: Use vfs_iocb_iter_read()

From: "NeilBrown" <neil@brown.name>
Date: 2025-06-13 02:03:33

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

quoted hunk ↗ jump to hunk
---
 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
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help