Commit e18bcb33 authored by NeilBrown's avatar NeilBrown Committed by Chuck Lever

NFSD: only call fh_unlock() once in nfsd_link()

On non-error paths, nfsd_link() calls fh_unlock() twice.  This is safe
because fh_unlock() records that the unlock has been done and doesn't
repeat it.
However it makes the code a little confusing and interferes with changes
that are planned for directory locking.

So rearrange the code to ensure fh_unlock() is called exactly once if
fh_lock() was called.
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent b677c0c6
...@@ -1541,9 +1541,10 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp, ...@@ -1541,9 +1541,10 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp,
dirp = d_inode(ddir); dirp = d_inode(ddir);
dnew = lookup_one_len(name, ddir, len); dnew = lookup_one_len(name, ddir, len);
host_err = PTR_ERR(dnew); if (IS_ERR(dnew)) {
if (IS_ERR(dnew)) err = nfserrno(PTR_ERR(dnew));
goto out_nfserr; goto out_unlock;
}
dold = tfhp->fh_dentry; dold = tfhp->fh_dentry;
...@@ -1562,17 +1563,17 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp, ...@@ -1562,17 +1563,17 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp,
else else
err = nfserrno(host_err); err = nfserrno(host_err);
} }
out_dput:
dput(dnew); dput(dnew);
out_unlock: out_drop_write:
fh_unlock(ffhp);
fh_drop_write(tfhp); fh_drop_write(tfhp);
out: out:
return err; return err;
out_nfserr: out_dput:
err = nfserrno(host_err); dput(dnew);
goto out_unlock; out_unlock:
fh_unlock(ffhp);
goto out_drop_write;
} }
static void static void
......
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