Commit 6eb3a1d0 authored by Jeff Layton's avatar Jeff Layton Committed by J. Bruce Fields

nfsd: set stateid access and deny bits in nfs4_get_vfs_file

Cleanup -- ensure that the stateid bits are set at the same time that
the file access refcounts are incremented. Keeping them coherent like
this makes it easier to ensure that we account for all of the
references.

Since the initialization of the st_*_bmap fields is done when it's
hashed, we go ahead and hash the stateid before getting access to the
file and unhash it if that function returns error. This will be
necessary anyway in a follow-on patch that will overhaul deny mode
handling.
Signed-off-by: default avatarJeff Layton <jlayton@primarydata.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent c11c591f
...@@ -3300,7 +3300,8 @@ nfsd4_truncate(struct svc_rqst *rqstp, struct svc_fh *fh, ...@@ -3300,7 +3300,8 @@ nfsd4_truncate(struct svc_rqst *rqstp, struct svc_fh *fh,
} }
static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp, static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp,
struct svc_fh *cur_fh, struct nfsd4_open *open) struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp,
struct nfsd4_open *open)
{ {
struct file *filp = NULL; struct file *filp = NULL;
__be32 status; __be32 status;
...@@ -3330,6 +3331,9 @@ static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp, ...@@ -3330,6 +3331,9 @@ static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp,
if (status) if (status)
goto out_put_access; goto out_put_access;
/* Set access and deny bits in stateid */
set_access(open->op_share_access, stp);
set_deny(open->op_share_deny, stp);
return nfs_ok; return nfs_ok;
out_put_access: out_put_access:
...@@ -3341,20 +3345,15 @@ static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp, ...@@ -3341,20 +3345,15 @@ static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp,
static __be32 static __be32
nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, struct nfsd4_open *open) nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, struct nfsd4_open *open)
{ {
u32 op_share_access = open->op_share_access;
__be32 status; __be32 status;
if (!test_access(op_share_access, stp)) if (!test_access(open->op_share_access, stp))
status = nfs4_get_vfs_file(rqstp, fp, cur_fh, open); status = nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open);
else else
status = nfsd4_truncate(rqstp, cur_fh, open); status = nfsd4_truncate(rqstp, cur_fh, open);
if (status) if (status)
return status; return status;
/* remember the open */
set_access(op_share_access, stp);
set_deny(open->op_share_deny, stp);
return nfs_ok; return nfs_ok;
} }
...@@ -3602,12 +3601,14 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf ...@@ -3602,12 +3601,14 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
if (status) if (status)
goto out; goto out;
} else { } else {
status = nfs4_get_vfs_file(rqstp, fp, current_fh, open);
if (status)
goto out;
stp = open->op_stp; stp = open->op_stp;
open->op_stp = NULL; open->op_stp = NULL;
init_open_stateid(stp, fp, open); init_open_stateid(stp, fp, open);
status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open);
if (status) {
release_open_stateid(stp);
goto out;
}
} }
update_stateid(&stp->st_stid.sc_stateid); update_stateid(&stp->st_stid.sc_stateid);
memcpy(&open->op_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t)); memcpy(&open->op_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));
......
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