free_client(struct nfs4_client *clp)
{
shutdown_callback_client(clp);
+ nfsd4_release_respages(clp->cl_slot.sl_cache_entry.ce_respages,
+ clp->cl_slot.sl_cache_entry.ce_resused);
if (clp->cl_cred.cr_group_info)
put_group_info(clp->cl_cred.cr_group_info);
kfree(clp->cl_principal);
exid->clientid.cl_boot = new->cl_clientid.cl_boot;
exid->clientid.cl_id = new->cl_clientid.cl_id;
- new->cl_seqid = exid->seqid = 1;
+ new->cl_slot.sl_seqid = 0;
+ exid->seqid = 1;
nfsd4_set_ex_flags(new, exid);
dprintk("nfsd4_exchange_id seqid %d flags %x\n",
- new->cl_seqid, new->cl_exchange_flags);
+ new->cl_slot.sl_seqid, new->cl_exchange_flags);
status = nfs_ok;
out:
struct nfsd4_create_session *cr_ses)
{
u32 ip_addr = svc_addr_in(rqstp)->sin_addr.s_addr;
+ struct nfsd4_compoundres *resp = rqstp->rq_resp;
struct nfs4_client *conf, *unconf;
+ struct nfsd4_slot *slot = NULL;
int status = 0;
nfs4_lock_state();
conf = find_confirmed_client(&cr_ses->clientid);
if (conf) {
- status = nfs_ok;
- if (conf->cl_seqid == cr_ses->seqid) {
+ slot = &conf->cl_slot;
+ status = check_slot_seqid(cr_ses->seqid, slot);
+ if (status == nfserr_replay_cache) {
dprintk("Got a create_session replay! seqid= %d\n",
- conf->cl_seqid);
- goto out_replay;
- } else if (cr_ses->seqid != conf->cl_seqid + 1) {
+ slot->sl_seqid);
+ cstate->slot = slot;
+ cstate->status = status;
+ /* Return the cached reply status */
+ status = nfsd4_replay_cache_entry(resp);
+ goto out;
+ } else if (cr_ses->seqid != conf->cl_slot.sl_seqid + 1) {
status = nfserr_seq_misordered;
dprintk("Sequence misordered!\n");
dprintk("Expected seqid= %d but got seqid= %d\n",
- conf->cl_seqid, cr_ses->seqid);
+ slot->sl_seqid, cr_ses->seqid);
goto out;
}
- conf->cl_seqid++;
+ conf->cl_slot.sl_seqid++;
} else if (unconf) {
if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred) ||
(ip_addr != unconf->cl_addr)) {
goto out;
}
- if (unconf->cl_seqid != cr_ses->seqid) {
+ slot = &unconf->cl_slot;
+ status = check_slot_seqid(cr_ses->seqid, slot);
+ if (status) {
+ /* an unconfirmed replay returns misordered */
status = nfserr_seq_misordered;
goto out;
}
+ slot->sl_seqid++; /* from 0 to 1 */
move_to_confirmed(unconf);
/*
if (status)
goto out;
-out_replay:
memcpy(cr_ses->sessionid.data, conf->cl_sessionid.data,
NFS4_MAX_SESSIONID_LEN);
- cr_ses->seqid = conf->cl_seqid;
+ cr_ses->seqid = slot->sl_seqid;
+ slot->sl_inuse = true;
+ cstate->slot = slot;
out:
nfs4_unlock_state();
dprintk("%s returns %d\n", __func__, ntohl(status));