create_session uses compound_encode_send_decode()

send CREATE_SESSION with compound_encode_send_decode() instead of nfs41_send_compound() for its NFS4ERR_DELAY and NFS4ERR_STALE_CLIENTID handling

added 'try_recovery' argument to nfs41_create_session(), which is passed on to compound_encode_send_decode().  nfs41_session_renew() uses try_recovery=FALSE, because it handles the NFS4ERR_STALE_CLIENTID error on its own.  nfs41_session_create() uses try_recovery=TRUE to make use of the NFS4ERR_STALE_CLIENTID error handling.  modified the NFS4ERR_STALE_CLIENTID block to call nfs41_client_renew() and retry the operation (i.e. CREATE_SESSION), instead of falling through to session recovery

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2011-01-07 11:50:35 -05:00
parent f2095915aa
commit 757b637607
4 changed files with 30 additions and 56 deletions

View file

@ -363,22 +363,21 @@ retry:
if (!recovery_start_or_wait(session->client))
goto do_retry;
//try to create a new client
client_state_lost = TRUE;
status = nfs41_client_renew(session->client);
recovery_finish(session->client);
if (status) {
eprintf("nfs41_exchange_id() failed with %d\n", status);
status = ERROR_BAD_NET_RESP;
recovery_finish(session->client);
goto out;
}
//fallthru and reestablish the session
goto do_retry;
case NFS4ERR_BADSESSION:
if (compound->res.status == NFS4ERR_BADSESSION) {
if (!try_recovery)
goto out;
if (!recovery_start_or_wait(session->client))
goto do_retry;
}
restart_recovery:
//try to create a new session
status = nfs41_session_renew(session);

View file

@ -43,27 +43,14 @@ int nfs41_exchange_id(
OUT nfs41_exchange_id_res *res_out)
{
int status = 0;
nfs41_compound compound;
nfs_argop4 argop;
nfs_resop4 resop;
nfs41_exchange_id_args ex_id;
nfs41_compound_args compound_args;
nfs_argop4 argop;
nfs41_compound_res compound_res;
nfs_resop4 resop;
/* set compound_args.tag, compound_args.tag_len */
compound_args.tag_len = 11;
memcpy(compound_args.tag, "exchange_id", 11);
compound_args.minorversion = 1;
compound_args.argarray_count = 1;
compound_args.argarray = &argop;
argop.op = OP_EXCHANGE_ID;
argop.arg = &ex_id;
compound_res.resarray_count = 1;
compound_res.resarray = &resop;
compound_res.resarray[0].op = compound_args.argarray[0].op;
resop.res = res_out;
compound_init(&compound, &argop, &resop, "exchange_id");
compound_add_op(&compound, OP_EXCHANGE_ID, &ex_id, res_out);
ex_id.eia_clientowner = owner;
ex_id.eia_flags = flags_in;
ex_id.eia_state_protect.spa_how = SP4_NONE;
@ -71,12 +58,13 @@ int nfs41_exchange_id(
res_out->server_owner.so_major_id_len = NFS4_OPAQUE_LIMIT;
res_out->server_scope_len = NFS4_OPAQUE_LIMIT;
status = nfs41_send_compound(rpc, (char *)&compound_args,
(char *)&compound_res);
status = nfs41_send_compound(rpc, (char *)&compound.args,
(char *)&compound.res);
if (status)
goto out;
compound_error(status = compound_res.status);
compound_error(status = compound.res.status);
out:
return status;
}
@ -113,30 +101,18 @@ static int set_back_channel_attrs(
return 0;
}
int nfs41_create_session(nfs41_client *clnt, nfs41_session *session)
int nfs41_create_session(nfs41_client *clnt, nfs41_session *session, bool_t try_recovery)
{
int status = 0;
nfs41_compound compound;
nfs_argop4 argop;
nfs_resop4 resop;
nfs41_create_session_args req;
nfs41_create_session_res reply;
nfs41_compound_args compound_args;
nfs_argop4 argop;
nfs41_compound_res compound_res;
nfs_resop4 resop;
compound_init(&compound, &argop, &resop, "create_session");
dprintf(2, "nfs41_create_session begin\n");
/* set compound_args.tag, compound_args.tag_len */
compound_args.tag_len = 14;
memcpy(compound_args.tag, "create_session", 14);
compound_args.minorversion = 1;
compound_args.argarray_count = 1;
compound_args.argarray = &argop;
argop.op = OP_CREATE_SESSION;
argop.arg = &req;
compound_res.resarray_count = 1;
compound_res.resarray = &resop;
resop.res = &reply;
compound_add_op(&compound, OP_CREATE_SESSION, &req, &reply);
ZeroMemory(&req, sizeof(req));
AcquireSRWLockShared(&clnt->exid_lock);
@ -156,14 +132,12 @@ int nfs41_create_session(nfs41_client *clnt, nfs41_session *session)
reply.csr_sessionid = session->session_id;
reply.csr_fore_chan_attrs = &session->fore_chan_attrs;
reply.csr_back_chan_attrs = &session->back_chan_attrs;
compound_res.resarray[0].op = compound_args.argarray[0].op;
status = nfs41_send_compound(clnt->rpc, (char *)&compound_args,
(char *)&compound_res);
status = compound_encode_send_decode(session, &compound, try_recovery);
if (status)
goto out;
if (compound_error(status = compound_res.status))
if (compound_error(status = compound.res.status))
goto out;
print_hexbuf(1, (unsigned char *)"session id: ", session->session_id, NFS4_SESSIONID_SIZE);

View file

@ -884,7 +884,8 @@ int nfs41_exchange_id(
int nfs41_create_session(
IN nfs41_client *clnt,
OUT nfs41_session *session);
OUT nfs41_session *session,
IN bool_t try_recovery);
enum nfsstat4 nfs41_bind_conn_to_session(
IN nfs41_rpc_clnt *rpc,

View file

@ -284,7 +284,7 @@ int nfs41_session_create(
session->flags |= CREATE_SESSION4_FLAG_CONN_BACK_CHAN;
ReleaseSRWLockShared(&client->exid_lock);
status = nfs41_create_session(client, session);
status = nfs41_create_session(client, session, TRUE);
if (status) {
eprintf("nfs41_create_session failed %d\n", status);
status = ERROR_BAD_NET_RESP;
@ -316,7 +316,7 @@ int nfs41_session_renew(
eprintf("init_slot_table failed %d\n", status);
goto out_err_session;
}
status = nfs41_create_session(session->client, session);
status = nfs41_create_session(session->client, session, FALSE);
if (status && status != NFS4ERR_STALE_CLIENTID) {
eprintf("nfs41_create_session failed %d\n", status);
status = ERROR_BAD_NET_RESP;