From: Trond Myklebust Date: Wed, 15 Aug 2007 08:54:43 -0400 Subject: NFS: Add stateless open to NFSv2 and NFSv3 create operations Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 2 +- fs/nfs/nfs3proc.c | 4 ++++ fs/nfs/proc.c | 10 ++++++++-- include/linux/nfs_fs.h | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index ba90573..a5f6287 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -794,7 +794,7 @@ static int nfs_inode_may_open(struct inode *inode, struct rpc_cred *cred, struct return nfs_may_open(inode, cred, nd->intent.open.flags, force_reval); } -static int nfs_stateless_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd) +int nfs_stateless_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd) { struct file *filp; struct rpc_cred *cred; diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 0a0bf06..03b8054 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -344,6 +344,10 @@ again: if (status != 0) goto out; status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); + if (status != 0) + goto out; + if (nd->flags & LOOKUP_OPEN) + status = nfs_stateless_open(dir, dentry, nd); out: dprintk("NFS reply create: %d\n", status); return status; diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index a57b324..c93e78d 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c @@ -226,8 +226,14 @@ nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, dprintk("NFS call create %s\n", dentry->d_name.name); status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); nfs_mark_for_revalidate(dir); - if (status == 0) - status = nfs_instantiate(dentry, &fhandle, &fattr); + if (status != 0) + goto out; + status = nfs_instantiate(dentry, &fhandle, &fattr); + if (status != 0) + goto out; + if (nd->flags & LOOKUP_OPEN) + status = nfs_stateless_open(dir, dentry, nd); +out: dprintk("NFS reply create: %d\n", status); return status; } diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 4b87a82..d8a9cb3 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -369,6 +369,7 @@ extern struct dentry_operations nfs_dentry_operations; extern void nfs_force_lookup_revalidate(struct inode *dir); extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh, struct nfs_fattr *fattr); +extern int nfs_stateless_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd); extern int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags, int force_reval); extern void nfs_access_zap_cache(struct inode *inode); extern int nfs_generic_permission(struct inode *inode, struct rpc_cred *cred, int mask, int force_reval);