Commit 927bfc56 authored by NeilBrown's avatar NeilBrown Committed by Chuck Lever

NFSD: change nfsd_create()/nfsd_symlink() to unlock directory before returning.

nfsd_create() usually returns with the directory still locked.
nfsd_symlink() usually returns with it unlocked.  This is clumsy.

Until recently nfsd_create() needed to keep the directory locked until
ACLs and security label had been set.  These are now set inside
nfsd_create() (in nfsd_setattr()) so this need is gone.

So change nfsd_create() and nfsd_symlink() to always unlock, and remove
any fh_unlock() calls that follow calls to these functions.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent c0cbe707
...@@ -388,7 +388,6 @@ nfsd3_proc_mkdir(struct svc_rqst *rqstp) ...@@ -388,7 +388,6 @@ nfsd3_proc_mkdir(struct svc_rqst *rqstp)
fh_init(&resp->fh, NFS3_FHSIZE); fh_init(&resp->fh, NFS3_FHSIZE);
resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len, resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
&attrs, S_IFDIR, 0, &resp->fh); &attrs, S_IFDIR, 0, &resp->fh);
fh_unlock(&resp->dirfh);
return rpc_success; return rpc_success;
} }
...@@ -469,7 +468,6 @@ nfsd3_proc_mknod(struct svc_rqst *rqstp) ...@@ -469,7 +468,6 @@ nfsd3_proc_mknod(struct svc_rqst *rqstp)
type = nfs3_ftypes[argp->ftype]; type = nfs3_ftypes[argp->ftype];
resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len, resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
&attrs, type, rdev, &resp->fh); &attrs, type, rdev, &resp->fh);
fh_unlock(&resp->dirfh);
out: out:
return rpc_success; return rpc_success;
} }
......
...@@ -823,8 +823,6 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -823,8 +823,6 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
create->cr_bmval[2] &= ~FATTR4_WORD2_SECURITY_LABEL; create->cr_bmval[2] &= ~FATTR4_WORD2_SECURITY_LABEL;
if (attrs.na_aclerr) if (attrs.na_aclerr)
create->cr_bmval[0] &= ~FATTR4_WORD0_ACL; create->cr_bmval[0] &= ~FATTR4_WORD0_ACL;
fh_unlock(&cstate->current_fh);
set_change_info(&create->cr_cinfo, &cstate->current_fh); set_change_info(&create->cr_cinfo, &cstate->current_fh);
fh_dup2(&cstate->current_fh, &resfh); fh_dup2(&cstate->current_fh, &resfh);
out: out:
......
...@@ -1379,8 +1379,10 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1379,8 +1379,10 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
fh_lock_nested(fhp, I_MUTEX_PARENT); fh_lock_nested(fhp, I_MUTEX_PARENT);
dchild = lookup_one_len(fname, dentry, flen); dchild = lookup_one_len(fname, dentry, flen);
host_err = PTR_ERR(dchild); host_err = PTR_ERR(dchild);
if (IS_ERR(dchild)) if (IS_ERR(dchild)) {
return nfserrno(host_err); err = nfserrno(host_err);
goto out_unlock;
}
err = fh_compose(resfhp, fhp->fh_export, dchild, fhp); err = fh_compose(resfhp, fhp->fh_export, dchild, fhp);
/* /*
* We unconditionally drop our ref to dchild as fh_compose will have * We unconditionally drop our ref to dchild as fh_compose will have
...@@ -1388,9 +1390,12 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1388,9 +1390,12 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
*/ */
dput(dchild); dput(dchild);
if (err) if (err)
return err; goto out_unlock;
return nfsd_create_locked(rqstp, fhp, fname, flen, attrs, type, err = nfsd_create_locked(rqstp, fhp, fname, flen, attrs, type,
rdev, resfhp); rdev, resfhp);
out_unlock:
fh_unlock(fhp);
return err;
} }
/* /*
...@@ -1467,16 +1472,19 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1467,16 +1472,19 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
goto out; goto out;
host_err = fh_want_write(fhp); host_err = fh_want_write(fhp);
if (host_err) if (host_err) {
goto out_nfserr; err = nfserrno(host_err);
goto out;
}
fh_lock(fhp); fh_lock(fhp);
dentry = fhp->fh_dentry; dentry = fhp->fh_dentry;
dnew = lookup_one_len(fname, dentry, flen); dnew = lookup_one_len(fname, dentry, flen);
host_err = PTR_ERR(dnew); if (IS_ERR(dnew)) {
if (IS_ERR(dnew)) err = nfserrno(PTR_ERR(dnew));
goto out_nfserr; fh_unlock(fhp);
goto out_drop_write;
}
host_err = vfs_symlink(&init_user_ns, d_inode(dentry), dnew, path); host_err = vfs_symlink(&init_user_ns, d_inode(dentry), dnew, path);
err = nfserrno(host_err); err = nfserrno(host_err);
cerr = fh_compose(resfhp, fhp->fh_export, dnew, fhp); cerr = fh_compose(resfhp, fhp->fh_export, dnew, fhp);
...@@ -1485,16 +1493,12 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1485,16 +1493,12 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
fh_unlock(fhp); fh_unlock(fhp);
if (!err) if (!err)
err = nfserrno(commit_metadata(fhp)); err = nfserrno(commit_metadata(fhp));
fh_drop_write(fhp);
dput(dnew); dput(dnew);
if (err==0) err = cerr; if (err==0) err = cerr;
out_drop_write:
fh_drop_write(fhp);
out: out:
return err; return err;
out_nfserr:
err = nfserrno(host_err);
goto out;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment