Make NFSD use the vfs_iocb_iter APIs
Subsystems (2)
Chuck Lever
maintainerv2 cover Make NFSD use the vfs_iocb_iter APIs
From: Chuck Lever <[email protected]>
Mike has expressed interest in making NFSD perform direct, uncached, or asynchronous I/O, independent of how the target file might have been opened by the file cache. To do that, the idea is to pass in RWF_ flags during each VFS read and write.
However, Christoph suggested APIs that already exist which streamline the I/O operation a bit and expose the per-I/O flag setting directly. The suggestion looks to me like a straightforward and sensible general clean up of these code paths.
This series refactors nfsd_iter_read() and nfsd_vfs_write() to use those APIs instead of vfs_iter_read() and vfs_iter_write(), respectively, as a first baby step down this path. No behavior change is expected.
Chuck Lever (2):
NFSD: Use vfs_iocb_iter_read()
NFSD: Use vfs_iocb_iter_write()
fs/nfsd/vfs.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
Signature · 1 line
2.49.0
Chuck Lever
maintainerRFC PATCH v2 1/2 NFSD: Use vfs_iocb_iter_read()
From: Chuck Lever <[email protected]>
Refactor: Enable the use of IOCB flags to control NFSD's individual read operations (when not using splice). This allows the eventual use of atomic, uncached, direct, or asynchronous reads.
--- fs/nfsd/vfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/nfsd/vfs.c +6 -2
@@ -1086,10 +1086,14 @@ __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); + kiocb.ki_pos = offset; + kiocb.ki_flags =0 ; + v =0 ; total = *count;while (total) {
@@ -1104,7 +1108,7 @@ __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);return nfsd_finish_read (rqstp, fhp, file, offset, count, eof, host_err); }
Signature · 1 line
2.49.0
Chuck Lever
maintainerRFC PATCH v2 2/2 NFSD: Use vfs_iocb_iter_write()
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
Refactor: Enable the use of IOCB flags to control NFSD's individual write operations. This allows the eventual use of atomic, uncached, direct, or asynchronous writes.
--- fs/nfsd/vfs.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/nfsd/vfs.c +6 -5
@@ -1174,15 +1174,14 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp,struct nfsd_net *nn =net_generic (SVC_NET (rqstp), nfsd_net_id);struct file *file = nf->nf_file;struct super_block *sb =file_inode (file)->i_sb; +struct kiocb kiocb;struct svc_export *exp;struct iov_iter iter;errseq_t since;__be32 nfserr;int host_err; -loff_t pos = offset;unsigned long exp_op_flags =0 ;unsigned int pflags = current->flags; -rwf_t flags =0 ;bool restore_flags = false;unsigned int nvecs;
@@ -1208,16 +1207,18 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp,if (!EX_ISSYNC (exp)) stable =NFS_UNSTABLE ; - +init_sync_kiocb (&kiocb, file); + kiocb.ki_pos = offset; + kiocb.ki_flags =0 ;if (stable && !fhp->fh_use_wgather) - flags |=RWF_SYNC ; + kiocb.ki_flags |=IOCB_DSYNC ; nvecs =xdr_buf_to_bvec (rqstp->rq_bvec, rqstp->rq_maxpages, payload);iov_iter_bvec (&iter,ITER_SOURCE , rqstp->rq_bvec, nvecs, *cnt); since =READ_ONCE (file->f_wb_err);if (verf)nfsd_copy_write_verifier (verf, nn); - host_err =vfs_iter_write (file, &iter, &pos, flags); + host_err =vfs_iocb_iter_write (file, &kiocb, &iter);if (host_err <0 ) {commit_reset_write_verifier (nn, rqstp, host_err); goto out_nfserr;
Signature · 1 line
2.49.0
Quoted 17 lines · Chuck Lever
From: Chuck Lever <[email protected]>
Mike has expressed interest in making NFSD perform direct, uncached, or asynchronous I/O, independent of how the target file might have been opened by the file cache. To do that, the idea is to pass in
RWF_flags during each VFS read and write.However, Christoph suggested APIs that already exist which streamline the I/O operation a bit and expose the per-I/O flag setting directly. The suggestion looks to me like a straightforward and sensible general clean up of these code paths.
This series refactors
nfsd_iter_read()andnfsd_vfs_write()to use those APIs instead ofvfs_iter_read()andvfs_iter_write(), respectively, as a first baby step down this path. No behavior change is expected.
Quoted 6 lines
Chuck Lever (2):
NFSD: Usevfs_iocb_iter_read()
NFSD: Usevfs_iocb_iter_write()fs/nfsd/vfs.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
Looks like a straightforward change to me. Why the RFC?
Quoted 12 lines · Chuck Lever
From: Chuck Lever <[email protected]>
Mike has expressed interest in making NFSD perform direct, uncached, or asynchronous I/O, independent of how the target file might have been opened by the file cache. To do that, the idea is to pass in
RWF_flags during each VFS read and write.However, Christoph suggested APIs that already exist which streamline the I/O operation a bit and expose the per-I/O flag setting directly. The suggestion looks to me like a straightforward and sensible general clean up of these code paths.
Quoted 8 lines
This series refactors
nfsd_iter_read()andnfsd_vfs_write()to use those APIs instead ofvfs_iter_read()andvfs_iter_write(), respectively, as a first baby step down this path. No behavior change is expected.Chuck Lever (2):
NFSD: Usevfs_iocb_iter_read()
NFSD: Usevfs_iocb_iter_write()
It important part of this change (as I see it) is that we no longer have to go through kiocb_set_rw_flags() (which vfs_iter_read/vfs_iter_write do) but can set the IOCB_ flags directly. Eminently sensible.
Thanks,
NeilBrown
Quoted 8 lines
fs/nfsd/vfs.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)Signature · 1 line
2.49.0
Re: [RFC PATCH v2 1/2] NFSD: Use vfs_iocb_iter_read()
In reply to Chuck Leverfs/nfsd/vfs.c __be32 nfsd_iter_read(struct svc_rqst *rqstp, struct svc_fh *fhp, · line 1095
Quoted 3 lines · Chuck Lever
fs/nfsd/vfs.c +3
-0+init_sync_kiocb (&kiocb, file); + kiocb.ki_pos = offset; + kiocb.ki_flags =0 ;
ki_flags is already cleared by init_sync_kiocb, so the line doing that can be dropped.
Otherwise looks good:
Re: [RFC PATCH v2 2/2] NFSD: Use vfs_iocb_iter_write()
In reply to Chuck Leverfs/nfsd/vfs.c nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, · line 1212
Quoted 1 line · Chuck Lever
fs/nfsd/vfs.c +1
-0+ kiocb.ki_flags =0 ;
Same thing here.
Otherwise looks good: