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:
parent
f2095915aa
commit
757b637607
4 changed files with 30 additions and 56 deletions
|
|
@ -363,22 +363,21 @@ retry:
|
||||||
if (!recovery_start_or_wait(session->client))
|
if (!recovery_start_or_wait(session->client))
|
||||||
goto do_retry;
|
goto do_retry;
|
||||||
//try to create a new client
|
//try to create a new client
|
||||||
client_state_lost = TRUE;
|
|
||||||
status = nfs41_client_renew(session->client);
|
status = nfs41_client_renew(session->client);
|
||||||
|
|
||||||
|
recovery_finish(session->client);
|
||||||
if (status) {
|
if (status) {
|
||||||
eprintf("nfs41_exchange_id() failed with %d\n", status);
|
eprintf("nfs41_exchange_id() failed with %d\n", status);
|
||||||
status = ERROR_BAD_NET_RESP;
|
status = ERROR_BAD_NET_RESP;
|
||||||
recovery_finish(session->client);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
//fallthru and reestablish the session
|
goto do_retry;
|
||||||
|
|
||||||
case NFS4ERR_BADSESSION:
|
case NFS4ERR_BADSESSION:
|
||||||
if (compound->res.status == NFS4ERR_BADSESSION) {
|
|
||||||
if (!try_recovery)
|
if (!try_recovery)
|
||||||
goto out;
|
goto out;
|
||||||
if (!recovery_start_or_wait(session->client))
|
if (!recovery_start_or_wait(session->client))
|
||||||
goto do_retry;
|
goto do_retry;
|
||||||
}
|
|
||||||
restart_recovery:
|
restart_recovery:
|
||||||
//try to create a new session
|
//try to create a new session
|
||||||
status = nfs41_session_renew(session);
|
status = nfs41_session_renew(session);
|
||||||
|
|
|
||||||
|
|
@ -43,27 +43,14 @@ int nfs41_exchange_id(
|
||||||
OUT nfs41_exchange_id_res *res_out)
|
OUT nfs41_exchange_id_res *res_out)
|
||||||
{
|
{
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
nfs41_compound compound;
|
||||||
|
nfs_argop4 argop;
|
||||||
|
nfs_resop4 resop;
|
||||||
nfs41_exchange_id_args ex_id;
|
nfs41_exchange_id_args ex_id;
|
||||||
|
|
||||||
nfs41_compound_args compound_args;
|
compound_init(&compound, &argop, &resop, "exchange_id");
|
||||||
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_add_op(&compound, OP_EXCHANGE_ID, &ex_id, res_out);
|
||||||
ex_id.eia_clientowner = owner;
|
ex_id.eia_clientowner = owner;
|
||||||
ex_id.eia_flags = flags_in;
|
ex_id.eia_flags = flags_in;
|
||||||
ex_id.eia_state_protect.spa_how = SP4_NONE;
|
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_owner.so_major_id_len = NFS4_OPAQUE_LIMIT;
|
||||||
res_out->server_scope_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)
|
if (status)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
compound_error(status = compound_res.status);
|
compound_error(status = compound.res.status);
|
||||||
out:
|
out:
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
@ -113,30 +101,18 @@ static int set_back_channel_attrs(
|
||||||
return 0;
|
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;
|
int status = 0;
|
||||||
|
nfs41_compound compound;
|
||||||
|
nfs_argop4 argop;
|
||||||
|
nfs_resop4 resop;
|
||||||
nfs41_create_session_args req;
|
nfs41_create_session_args req;
|
||||||
nfs41_create_session_res reply;
|
nfs41_create_session_res reply;
|
||||||
|
|
||||||
nfs41_compound_args compound_args;
|
compound_init(&compound, &argop, &resop, "create_session");
|
||||||
nfs_argop4 argop;
|
|
||||||
nfs41_compound_res compound_res;
|
|
||||||
nfs_resop4 resop;
|
|
||||||
|
|
||||||
dprintf(2, "nfs41_create_session begin\n");
|
compound_add_op(&compound, OP_CREATE_SESSION, &req, &reply);
|
||||||
/* 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;
|
|
||||||
|
|
||||||
ZeroMemory(&req, sizeof(req));
|
ZeroMemory(&req, sizeof(req));
|
||||||
AcquireSRWLockShared(&clnt->exid_lock);
|
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_sessionid = session->session_id;
|
||||||
reply.csr_fore_chan_attrs = &session->fore_chan_attrs;
|
reply.csr_fore_chan_attrs = &session->fore_chan_attrs;
|
||||||
reply.csr_back_chan_attrs = &session->back_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,
|
status = compound_encode_send_decode(session, &compound, try_recovery);
|
||||||
(char *)&compound_res);
|
|
||||||
if (status)
|
if (status)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (compound_error(status = compound_res.status))
|
if (compound_error(status = compound.res.status))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
print_hexbuf(1, (unsigned char *)"session id: ", session->session_id, NFS4_SESSIONID_SIZE);
|
print_hexbuf(1, (unsigned char *)"session id: ", session->session_id, NFS4_SESSIONID_SIZE);
|
||||||
|
|
|
||||||
|
|
@ -884,7 +884,8 @@ int nfs41_exchange_id(
|
||||||
|
|
||||||
int nfs41_create_session(
|
int nfs41_create_session(
|
||||||
IN nfs41_client *clnt,
|
IN nfs41_client *clnt,
|
||||||
OUT nfs41_session *session);
|
OUT nfs41_session *session,
|
||||||
|
IN bool_t try_recovery);
|
||||||
|
|
||||||
enum nfsstat4 nfs41_bind_conn_to_session(
|
enum nfsstat4 nfs41_bind_conn_to_session(
|
||||||
IN nfs41_rpc_clnt *rpc,
|
IN nfs41_rpc_clnt *rpc,
|
||||||
|
|
|
||||||
|
|
@ -284,7 +284,7 @@ int nfs41_session_create(
|
||||||
session->flags |= CREATE_SESSION4_FLAG_CONN_BACK_CHAN;
|
session->flags |= CREATE_SESSION4_FLAG_CONN_BACK_CHAN;
|
||||||
ReleaseSRWLockShared(&client->exid_lock);
|
ReleaseSRWLockShared(&client->exid_lock);
|
||||||
|
|
||||||
status = nfs41_create_session(client, session);
|
status = nfs41_create_session(client, session, TRUE);
|
||||||
if (status) {
|
if (status) {
|
||||||
eprintf("nfs41_create_session failed %d\n", status);
|
eprintf("nfs41_create_session failed %d\n", status);
|
||||||
status = ERROR_BAD_NET_RESP;
|
status = ERROR_BAD_NET_RESP;
|
||||||
|
|
@ -316,7 +316,7 @@ int nfs41_session_renew(
|
||||||
eprintf("init_slot_table failed %d\n", status);
|
eprintf("init_slot_table failed %d\n", status);
|
||||||
goto out_err_session;
|
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) {
|
if (status && status != NFS4ERR_STALE_CLIENTID) {
|
||||||
eprintf("nfs41_create_session failed %d\n", status);
|
eprintf("nfs41_create_session failed %d\n", status);
|
||||||
status = ERROR_BAD_NET_RESP;
|
status = ERROR_BAD_NET_RESP;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue