Commit 567d9829 authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds

[PATCH] nfsd4: don't reopen for delegated client

We don't really need to be doing a separate open for every stateid.  And in
the case of an open from a client that already has a delegation on a file, it
unnecessarily results in a delegation recall.
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: default avatarNeil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 4a6e43e6
...@@ -1547,6 +1547,24 @@ find_delegation_file(struct nfs4_file *fp, stateid_t *stid) ...@@ -1547,6 +1547,24 @@ find_delegation_file(struct nfs4_file *fp, stateid_t *stid)
return NULL; return NULL;
} }
static void
nfs4_check_deleg(struct nfs4_file *fp, struct nfsd4_open *open,
struct nfs4_delegation **dp)
{
int flags;
int status;
*dp = find_delegation_file(fp, &open->op_delegate_stateid);
if (*dp == NULL)
return;
flags = open->op_share_access == NFS4_SHARE_ACCESS_READ ?
RD_STATE : WR_STATE;
status = nfs4_check_delegmode(*dp, flags);
if (status)
*dp = NULL;
return;
}
static int static int
nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_stateid **stpp) nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_stateid **stpp)
{ {
...@@ -1572,21 +1590,28 @@ nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_state ...@@ -1572,21 +1590,28 @@ nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_state
static int static int
nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp, nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp,
struct nfs4_delegation *dp,
struct svc_fh *cur_fh, int flags) struct svc_fh *cur_fh, int flags)
{ {
struct nfs4_stateid *stp; struct nfs4_stateid *stp;
int status;
stp = kmalloc(sizeof(struct nfs4_stateid), GFP_KERNEL); stp = kmalloc(sizeof(struct nfs4_stateid), GFP_KERNEL);
if (stp == NULL) if (stp == NULL)
return nfserr_resource; return nfserr_resource;
status = nfsd_open(rqstp, cur_fh, S_IFREG, flags, &stp->st_vfs_file); if (dp) {
if (status) { get_file(dp->dl_vfs_file);
if (status == nfserr_dropit) stp->st_vfs_file = dp->dl_vfs_file;
status = nfserr_jukebox; } else {
kfree(stp); int status;
return status; status = nfsd_open(rqstp, cur_fh, S_IFREG, flags,
&stp->st_vfs_file);
if (status) {
if (status == nfserr_dropit)
status = nfserr_jukebox;
kfree(stp);
return status;
}
} }
vfsopen++; vfsopen++;
*stpp = stp; *stpp = stp;
...@@ -1720,6 +1745,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf ...@@ -1720,6 +1745,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
struct nfs4_file *fp = NULL; struct nfs4_file *fp = NULL;
struct inode *ino = current_fh->fh_dentry->d_inode; struct inode *ino = current_fh->fh_dentry->d_inode;
struct nfs4_stateid *stp = NULL; struct nfs4_stateid *stp = NULL;
struct nfs4_delegation *dp = NULL;
int status; int status;
status = nfserr_inval; status = nfserr_inval;
...@@ -1734,6 +1760,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf ...@@ -1734,6 +1760,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
if (fp) { if (fp) {
if ((status = nfs4_check_open(fp, open, &stp))) if ((status = nfs4_check_open(fp, open, &stp)))
goto out; goto out;
nfs4_check_deleg(fp, open, &dp);
} else { } else {
status = nfserr_resource; status = nfserr_resource;
fp = alloc_init_file(ino); fp = alloc_init_file(ino);
...@@ -1757,7 +1784,8 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf ...@@ -1757,7 +1784,8 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
flags = MAY_WRITE; flags = MAY_WRITE;
else else
flags = MAY_READ; flags = MAY_READ;
if ((status = nfs4_new_open(rqstp, &stp, current_fh, flags))) status = nfs4_new_open(rqstp, &stp, dp, current_fh, flags);
if (status)
goto out; goto out;
init_stateid(stp, fp, open); init_stateid(stp, fp, open);
status = nfsd4_truncate(rqstp, current_fh, open); status = nfsd4_truncate(rqstp, current_fh, open);
......
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