nfs4proc.c | 53 ++++++++++++++++++++++++++++++----------------------- 1 files changed, 30 insertions(+), 23 deletions(-) diff -u --recursive --new-file --show-c-function linux-2.6.7-13-open_cleanup1/fs/nfs/nfs4proc.c linux-2.6.7-14-open_cleanup2/fs/nfs/nfs4proc.c --- linux-2.6.7-13-open_cleanup1/fs/nfs/nfs4proc.c 2004-06-10 19:25:24.000000000 -0400 +++ linux-2.6.7-14-open_cleanup2/fs/nfs/nfs4proc.c 2004-06-10 19:28:45.000000000 -0400 @@ -233,6 +233,29 @@ nfs4_open_reclaim(struct nfs4_state_owne return status; } +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 */ @@ -280,13 +303,18 @@ static struct nfs4_state * _nfs4_do_open down(&sp->so_sema); o_arg.seqid = sp->so_seqid; o_arg.id = sp->so_id; - o_arg.clientid = clp->cl_clientid, + o_arg.clientid = clp->cl_clientid; status = rpc_call_sync(server->client, &msg, 0); nfs4_increment_seqid(status, sp); 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) + goto out_err; + } status = -ENOMEM; inode = nfs_fhget(dir->i_sb, &o_res.fh, &f_attr); @@ -295,28 +323,7 @@ static struct nfs4_state * _nfs4_do_open 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++;