Re: [PATCH v2 10/14] nfsd: open-code nfsd4_vfs_create() into nfsd4_create_file()
Jeff Layton <[email protected]>
| Newsgroups | gmane.linux.nfs |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 2026-07-06 at 08:19 +1000, NeilBrown wrote: > From: NeilBrown <neil-+NVA1uvv1dVBDLzU/[email protected]> > > Having this sub function separate doesn't really add clarity, and merging > allows for some refactoring and ultimately using a different VFS > interface. > > Signed-off-by: NeilBrown <neil-+NVA1uvv1dVBDLzU/[email protected]> > --- > fs/nfsd/nfs4proc.c | 76 +++++++++++++++++++++------------------------- > 1 file changed, 34 insertions(+), 42 deletions(-) > > diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c > index 973beda7f161..a34731e1714f 100644 > --- a/fs/nfsd/nfs4proc.c > +++ b/fs/nfsd/nfs4proc.c > @@ -201,46 +201,6 @@ static inline bool nfsd4_create_is_exclusive(int createmode) > createmode == NFS4_CREATE_EXCLUSIVE4_1; > } > > -static __be32 > -nfsd4_vfs_create(struct svc_fh *fhp, struct dentry **child, > - struct nfsd4_open *open) > -{ > - struct file *filp; > - struct path path; > - int oflags; > - > - oflags = O_CREAT | O_LARGEFILE; > - /* > - * For the EXCLUSIVE modes we do our own uniqueness tests > - * so don't want O_EXCL. > - */ > - if (open->op_createmode == NFS4_CREATE_GUARDED) > - oflags |= O_EXCL; > - > - switch (open->op_share_access & NFS4_SHARE_ACCESS_BOTH) { > - case NFS4_SHARE_ACCESS_WRITE: > - oflags |= O_WRONLY; > - break; > - case NFS4_SHARE_ACCESS_BOTH: > - oflags |= O_RDWR; > - break; > - default: > - oflags |= O_RDONLY; > - } > - > - path.mnt = fhp->fh_export->ex_path.mnt; > - path.dentry = *child; > - filp = dentry_create(&path, oflags, open->op_iattr.ia_mode, > - current_cred()); > - *child = path.dentry; > - > - if (IS_ERR(filp)) > - return nfserrno(PTR_ERR(filp)); > - > - open->op_filp = filp; > - return nfs_ok; > -} > - > /* > * Implement NFSv4's unchecked, guarded, and exclusive create > * semantics for regular files. Open state for this new file is > @@ -363,9 +323,41 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, > } else if (create_status) { > status = create_status; > } else { > - status = nfsd4_vfs_create(fhp, &child, open); > - if (status == nfs_ok) > + struct file *filp; > + struct path path; > + int oflags; > + > + oflags = O_CREAT | O_LARGEFILE; > + /* > + * For the EXCLUSIVE modes we do our own uniqueness tests > + * so don't want O_EXCL. > + */ > + if (open->op_createmode == NFS4_CREATE_GUARDED) > + oflags |= O_EXCL; > + > + switch (open->op_share_access & NFS4_SHARE_ACCESS_BOTH) { > + case NFS4_SHARE_ACCESS_WRITE: > + oflags |= O_WRONLY; > + break; > + case NFS4_SHARE_ACCESS_BOTH: > + oflags |= O_RDWR; > + break; > + default: > + oflags |= O_RDONLY; > + } > + > + path.mnt = fhp->fh_export->ex_path.mnt; > + path.dentry = child; > + filp = dentry_create(&path, oflags, open->op_iattr.ia_mode, > + current_cred()); > + child = path.dentry; > + > + if (IS_ERR(filp)) { > + status = nfserrno(PTR_ERR(filp)); > + } else { > + open->op_filp = filp; > open->op_created = open->op_filp->f_mode & FMODE_CREATED; > + } > } > end_creating(child); > if (status != nfs_ok) Reviewed-by: Jeff Layton <[email protected]>