Commit 671f6899 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] nfsd4: move some nfsd4_process_open2 code to nfs4_new_open

Move most of the code in the new_open case of nfsd4_process_open2 to
nfs4_new_open.
Signed-off-by: default avatarAndy Adamson <andros@umich.edu>
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 19f517ff
...@@ -1261,6 +1261,30 @@ nfs4_check_open(struct nfs4_file *fp, struct nfs4_stateowner *sop, struct nfsd4_ ...@@ -1261,6 +1261,30 @@ nfs4_check_open(struct nfs4_file *fp, struct nfs4_stateowner *sop, struct nfsd4_
return status; return status;
} }
static int
nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp,
struct svc_fh *cur_fh, int flags)
{
struct nfs4_stateid *stp;
int status;
stp = kmalloc(sizeof(struct nfs4_stateid), GFP_KERNEL);
if (stp == NULL)
return nfserr_resource;
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++;
stp->st_vfs_set = 1;
*stpp = stp;
return 0;
}
static int static int
nfs4_upgrade_open(struct svc_rqst *rqstp, struct svc_fh *cur_fh, struct nfs4_stateid *stp, struct nfsd4_open *open) nfs4_upgrade_open(struct svc_rqst *rqstp, struct svc_fh *cur_fh, struct nfs4_stateid *stp, struct nfsd4_open *open)
{ {
...@@ -1346,26 +1370,15 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf ...@@ -1346,26 +1370,15 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
if (status) if (status)
goto out; goto out;
} else { } else {
/* Stateid was not found, this is a new OPEN */
int flags = 0; int flags = 0;
status = nfserr_resource;
if ((stp = kmalloc(sizeof(struct nfs4_stateid),
GFP_KERNEL)) == NULL)
goto out;
if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE)
flags = MAY_WRITE; flags = MAY_WRITE;
else else
flags = MAY_READ; flags = MAY_READ;
if ((status = nfsd_open(rqstp, current_fh, S_IFREG, if ((status = nfs4_new_open(rqstp, &stp, current_fh, flags)))
flags, goto out;
&stp->st_vfs_file)) != 0)
goto out_free;
vfsopen++;
init_stateid(stp, fp, sop, open); init_stateid(stp, fp, sop, open);
stp->st_vfs_set = 1;
} }
dprintk("nfs4_process_open2: stateid=(%08x/%08x/%08x/%08x)\n\n", dprintk("nfs4_process_open2: stateid=(%08x/%08x/%08x/%08x)\n\n",
stp->st_stateid.si_boot, stp->st_stateid.si_stateownerid, stp->st_stateid.si_boot, stp->st_stateid.si_stateownerid,
...@@ -1396,9 +1409,6 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf ...@@ -1396,9 +1409,6 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
open->op_rflags |= NFS4_OPEN_RESULT_CONFIRM; open->op_rflags |= NFS4_OPEN_RESULT_CONFIRM;
return status; return status;
out_free:
kfree(stp);
goto out;
} }
static struct work_struct laundromat_work; static struct work_struct laundromat_work;
......
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