session: use target_highest_slotid to limit slot table

adds support for CB_RECALL_SLOT with function nfs41_session_recall_slot()

when SEQUENCE or CB_RECALL_SLOT gives us a valid target_highest_slotid, use it to update max_slots

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2012-05-09 13:48:35 -04:00 committed by Olga Kornievskaia
parent 1905abd027
commit a3146af76d
4 changed files with 49 additions and 6 deletions

View file

@ -85,10 +85,12 @@ static enum_t handle_cb_layoutrecall(
/* OP_CB_RECALL_SLOT */ /* OP_CB_RECALL_SLOT */
static enum_t handle_cb_recall_slot( static enum_t handle_cb_recall_slot(
IN nfs41_rpc_clnt *rpc_clnt,
IN struct cb_recall_slot_args *args, IN struct cb_recall_slot_args *args,
OUT struct cb_recall_slot_res *res) OUT struct cb_recall_slot_res *res)
{ {
res->status = NFS4_OK; res->status = nfs41_session_recall_slot(rpc_clnt->client->session,
args->target_highest_slotid);
dprintf(CBSLVL, " OP_CB_RECALL_SLOT { %u } %s\n", dprintf(CBSLVL, " OP_CB_RECALL_SLOT { %u } %s\n",
args->target_highest_slotid, nfs_error_string(res->status)); args->target_highest_slotid, nfs_error_string(res->status));
@ -425,8 +427,8 @@ static void handle_cb_compound(nfs41_rpc_clnt *rpc_clnt, cb_req *req, struct cb_
break; break;
case OP_CB_RECALL_SLOT: case OP_CB_RECALL_SLOT:
dprintf(1, "OP_CB_RECALL_SLOT\n"); dprintf(1, "OP_CB_RECALL_SLOT\n");
res->status = handle_cb_recall_slot(&argop->args.recall_slot, res->status = handle_cb_recall_slot(rpc_clnt,
&resop->res.recall_slot); &argop->args.recall_slot, &resop->res.recall_slot);
break; break;
case OP_CB_SEQUENCE: case OP_CB_SEQUENCE:
dprintf(1, "OP_CB_SEQUENCE\n"); dprintf(1, "OP_CB_SEQUENCE\n");

View file

@ -347,7 +347,8 @@ void nfs41_session_free(
void nfs41_session_bump_seq( void nfs41_session_bump_seq(
IN nfs41_session *session, IN nfs41_session *session,
IN uint32_t slotid); IN uint32_t slotid,
IN uint32_t target_highest_slotid);
void nfs41_session_free_slot( void nfs41_session_free_slot(
IN nfs41_session *session, IN nfs41_session *session,
@ -359,6 +360,10 @@ void nfs41_session_get_slot(
OUT uint32_t *seq, OUT uint32_t *seq,
OUT uint32_t *highest); OUT uint32_t *highest);
int nfs41_session_recall_slot(
IN nfs41_session *session,
IN OUT uint32_t target_highest_slotid);
struct __nfs41_sequence_args; struct __nfs41_sequence_args;
void nfs41_session_sequence( void nfs41_session_sequence(
struct __nfs41_sequence_args *args, struct __nfs41_sequence_args *args,

View file

@ -179,7 +179,8 @@ retry:
if (seq->sr_resok4.sr_status_flags) if (seq->sr_resok4.sr_status_flags)
print_sr_status_flags(1, seq->sr_resok4.sr_status_flags); print_sr_status_flags(1, seq->sr_resok4.sr_status_flags);
nfs41_session_bump_seq(session, args->sa_slotid); nfs41_session_bump_seq(session, args->sa_slotid,
seq->sr_resok4.sr_target_highest_slotid);
/* check sequence status flags for state revocation */ /* check sequence status flags for state revocation */
if (try_recovery && seq->sr_resok4.sr_status_flags) if (try_recovery && seq->sr_resok4.sr_status_flags)

View file

@ -54,9 +54,27 @@ static void init_slot_table(nfs41_slot_table *table)
LeaveCriticalSection(&table->lock); LeaveCriticalSection(&table->lock);
} }
static void resize_slot_table(
IN nfs41_slot_table *table,
IN uint32_t target_highest_slotid)
{
if (target_highest_slotid >= NFS41_MAX_NUM_SLOTS)
target_highest_slotid = NFS41_MAX_NUM_SLOTS - 1;
if (table->max_slots != target_highest_slotid + 1) {
dprintf(2, "updated max_slots %u to %u\n",
table->max_slots, target_highest_slotid + 1);
table->max_slots = target_highest_slotid + 1;
if (slot_table_avail(table))
WakeAllConditionVariable(&table->cond);
}
}
void nfs41_session_bump_seq( void nfs41_session_bump_seq(
IN nfs41_session *session, IN nfs41_session *session,
IN uint32_t slotid) IN uint32_t slotid,
IN uint32_t target_highest_slotid)
{ {
nfs41_slot_table *table = &session->table; nfs41_slot_table *table = &session->table;
@ -66,6 +84,8 @@ void nfs41_session_bump_seq(
if (slotid < NFS41_MAX_NUM_SLOTS) if (slotid < NFS41_MAX_NUM_SLOTS)
table->seq_nums[slotid]++; table->seq_nums[slotid]++;
resize_slot_table(table, target_highest_slotid);
LeaveCriticalSection(&table->lock); LeaveCriticalSection(&table->lock);
ReleaseSRWLockShared(&session->client->session_lock); ReleaseSRWLockShared(&session->client->session_lock);
} }
@ -137,6 +157,21 @@ void nfs41_session_get_slot(
session, *slot, *seqid, *highest); session, *slot, *seqid, *highest);
} }
int nfs41_session_recall_slot(
IN nfs41_session *session,
IN OUT uint32_t target_highest_slotid)
{
nfs41_slot_table *table = &session->table;
AcquireSRWLockShared(&session->client->session_lock);
EnterCriticalSection(&table->lock);
resize_slot_table(table, target_highest_slotid);
LeaveCriticalSection(&table->lock);
ReleaseSRWLockShared(&session->client->session_lock);
return NFS4_OK;
}
void nfs41_session_sequence( void nfs41_session_sequence(
nfs41_sequence_args *args, nfs41_sequence_args *args,
nfs41_session *session, nfs41_session *session,