nfs4proc.c | 52 ++++++++++++++++++++++++++++++---------------------- 1 files changed, 30 insertions(+), 22 deletions(-) diff -u --recursive --new-file --show-c-function linux-2.6.8-36-open_cleanup1/fs/nfs/nfs4proc.c linux-2.6.8-37-open_cleanup2/fs/nfs/nfs4proc.c --- linux-2.6.8-36-open_cleanup1/fs/nfs/nfs4proc.c 2004-08-09 23:14:01.000000000 -0700 +++ linux-2.6.8-37-open_cleanup2/fs/nfs/nfs4proc.c 2004-08-09 23:19:27.000000000 -0700 @@ -248,6 +248,29 @@ int nfs4_open_reclaim(struct nfs4_state_ return err; } +static int _nfs4_proc_open_confirm(struct rpc_clnt *clnt, const struct nfs_fhandle *fh, struct nfs4_state_owner *sp, nfs4_stateid *stateid) +{ + struct nfs_open_confirmargs arg = { + .fh = fh, + .seqid = sp->so_seqid, + .stateid = *stateid, + }; + struct nfs_open_confirmres res; + struct rpc_message msg = { + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_CONFIRM], + .rpc_argp = &arg, + .rpc_resp = &res, + .rpc_cred = sp->so_cred, + }; + int status; + + status = rpc_call_sync(clnt, &msg, 0); + nfs4_increment_seqid(status, sp); + if (status >= 0) + memcpy(stateid, &res.stateid, sizeof(*stateid)); + return status; +} + /* * Returns an nfs4_state + an referenced inode */ @@ -305,6 +328,12 @@ static int _nfs4_do_open(struct inode *d if (status) goto out_err; update_changeattr(dir, &o_res.cinfo); + if(o_res.rflags & NFS4_OPEN_RESULT_CONFIRM) { + status = _nfs4_proc_open_confirm(server->client, &o_res.fh, + sp, &o_res.stateid); + if (status != 0) + goto out_err; + } if (!(f_attr.valid & NFS_ATTR_FATTR)) { error = server->rpc_ops->getattr(server, &o_res.fh, &f_attr); if (error < 0) @@ -318,28 +347,7 @@ static int _nfs4_do_open(struct inode *d state = nfs4_get_open_state(inode, sp); if (!state) goto out_err; - - if(o_res.rflags & NFS4_OPEN_RESULT_CONFIRM) { - struct nfs_open_confirmargs oc_arg = { - .fh = &o_res.fh, - .seqid = sp->so_seqid, - }; - struct nfs_open_confirmres oc_res; - struct rpc_message msg = { - .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_CONFIRM], - .rpc_argp = &oc_arg, - .rpc_resp = &oc_res, - .rpc_cred = cred, - }; - - memcpy(&oc_arg.stateid, &o_res.stateid, sizeof(oc_arg.stateid)); - status = rpc_call_sync(server->client, &msg, 0); - nfs4_increment_seqid(status, sp); - if (status) - goto out_err; - memcpy(&state->stateid, &oc_res.stateid, sizeof(state->stateid)); - } else - memcpy(&state->stateid, &o_res.stateid, sizeof(state->stateid)); + memcpy(&state->stateid, &o_res.stateid, sizeof(state->stateid)); spin_lock(&inode->i_lock); if (flags & FMODE_READ) state->nreaders++;