nfsd: cleanup and rename nfs4_check_open
Rename it to better describe what it does, and have it just return the stateid instead of a __be32 (which is now always nfs_ok). Also, do the search for an existing stateid after the delegation check, to reduce cleanup if the delegation check returns error. Signed-off-by: Jeff Layton <jlayton@primarydata.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
baeb4ff0e5
commit
a46cb7f287
fs/nfsd
|
@ -3297,10 +3297,10 @@ nfs4_check_deleg(struct nfs4_client *cl, struct nfsd4_open *open,
|
||||||
return nfs_ok;
|
return nfs_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __be32
|
static struct nfs4_ol_stateid *
|
||||||
nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_ol_stateid **stpp)
|
nfsd4_find_existing_open(struct nfs4_file *fp, struct nfsd4_open *open)
|
||||||
{
|
{
|
||||||
struct nfs4_ol_stateid *local;
|
struct nfs4_ol_stateid *local, *ret = NULL;
|
||||||
struct nfs4_openowner *oo = open->op_openowner;
|
struct nfs4_openowner *oo = open->op_openowner;
|
||||||
|
|
||||||
spin_lock(&fp->fi_lock);
|
spin_lock(&fp->fi_lock);
|
||||||
|
@ -3308,14 +3308,13 @@ nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_ol_st
|
||||||
/* ignore lock owners */
|
/* ignore lock owners */
|
||||||
if (local->st_stateowner->so_is_open_owner == 0)
|
if (local->st_stateowner->so_is_open_owner == 0)
|
||||||
continue;
|
continue;
|
||||||
/* remember if we have seen this open owner */
|
|
||||||
if (local->st_stateowner == &oo->oo_owner) {
|
if (local->st_stateowner == &oo->oo_owner) {
|
||||||
*stpp = local;
|
ret = local;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_unlock(&fp->fi_lock);
|
spin_unlock(&fp->fi_lock);
|
||||||
return nfs_ok;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int nfs4_access_to_access(u32 nfs4_access)
|
static inline int nfs4_access_to_access(u32 nfs4_access)
|
||||||
|
@ -3658,12 +3657,10 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
|
||||||
*/
|
*/
|
||||||
fp = find_or_add_file(ino, open->op_file);
|
fp = find_or_add_file(ino, open->op_file);
|
||||||
if (fp != open->op_file) {
|
if (fp != open->op_file) {
|
||||||
status = nfs4_check_open(fp, open, &stp);
|
|
||||||
if (status)
|
|
||||||
goto out;
|
|
||||||
status = nfs4_check_deleg(cl, open, &dp);
|
status = nfs4_check_deleg(cl, open, &dp);
|
||||||
if (status)
|
if (status)
|
||||||
goto out;
|
goto out;
|
||||||
|
stp = nfsd4_find_existing_open(fp, open);
|
||||||
} else {
|
} else {
|
||||||
open->op_file = NULL;
|
open->op_file = NULL;
|
||||||
status = nfserr_bad_stateid;
|
status = nfserr_bad_stateid;
|
||||||
|
|
Loading…
Reference in New Issue