提交 38eb76a5 编写于 作者: A Andy Adamson 提交者: J. Bruce Fields

nfsd41: Add a create session replay cache

Replace the nfs4_client cl_seqid field with a single struct nfs41_slot used
for the create session replay cache.

The CREATE_SESSION slot sets the sl_session pointer to NULL. Otherwise, the
slot and it's replay cache are used just like the session slots.

Fix unconfirmed create_session replay response by initializing the
create_session slot sequence id to 0.

A future patch will set the CREATE_SESSION cache when a SEQUENCE operation
preceeds the CREATE_SESSION operation. This compound is currently only cached
in the session slot table.

Signed-off-by: Andy Adamson<andros@netapp.com>
Signed-off-by: NBenny Halevy <bhalevy@panasas.com>
[nfsd41: use bool inuse for slot state]
Signed-off-by: NBenny Halevy <bhalevy@panasas.com>
[nfsd41: revert portion of nfsd4_set_cache_entry]
Signed-off-by: NAndy Adamson <andros@netpp.com>
Signed-off-by: NBenny Halevy <bhalevy@panasas.com>
Signed-off-by: NJ. Bruce Fields <bfields@citi.umich.edu>
上级 ec6b5d7b
...@@ -649,6 +649,8 @@ static inline void ...@@ -649,6 +649,8 @@ static inline void
free_client(struct nfs4_client *clp) free_client(struct nfs4_client *clp)
{ {
shutdown_callback_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) if (clp->cl_cred.cr_group_info)
put_group_info(clp->cl_cred.cr_group_info); put_group_info(clp->cl_cred.cr_group_info);
kfree(clp->cl_principal); kfree(clp->cl_principal);
...@@ -1263,11 +1265,12 @@ nfsd4_exchange_id(struct svc_rqst *rqstp, ...@@ -1263,11 +1265,12 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
exid->clientid.cl_boot = new->cl_clientid.cl_boot; exid->clientid.cl_boot = new->cl_clientid.cl_boot;
exid->clientid.cl_id = new->cl_clientid.cl_id; 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); nfsd4_set_ex_flags(new, exid);
dprintk("nfsd4_exchange_id seqid %d flags %x\n", 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; status = nfs_ok;
out: out:
...@@ -1309,7 +1312,9 @@ nfsd4_create_session(struct svc_rqst *rqstp, ...@@ -1309,7 +1312,9 @@ nfsd4_create_session(struct svc_rqst *rqstp,
struct nfsd4_create_session *cr_ses) struct nfsd4_create_session *cr_ses)
{ {
u32 ip_addr = svc_addr_in(rqstp)->sin_addr.s_addr; u32 ip_addr = svc_addr_in(rqstp)->sin_addr.s_addr;
struct nfsd4_compoundres *resp = rqstp->rq_resp;
struct nfs4_client *conf, *unconf; struct nfs4_client *conf, *unconf;
struct nfsd4_slot *slot = NULL;
int status = 0; int status = 0;
nfs4_lock_state(); nfs4_lock_state();
...@@ -1317,19 +1322,24 @@ nfsd4_create_session(struct svc_rqst *rqstp, ...@@ -1317,19 +1322,24 @@ nfsd4_create_session(struct svc_rqst *rqstp,
conf = find_confirmed_client(&cr_ses->clientid); conf = find_confirmed_client(&cr_ses->clientid);
if (conf) { if (conf) {
status = nfs_ok; slot = &conf->cl_slot;
if (conf->cl_seqid == cr_ses->seqid) { status = check_slot_seqid(cr_ses->seqid, slot);
if (status == nfserr_replay_cache) {
dprintk("Got a create_session replay! seqid= %d\n", dprintk("Got a create_session replay! seqid= %d\n",
conf->cl_seqid); slot->sl_seqid);
goto out_replay; cstate->slot = slot;
} else if (cr_ses->seqid != conf->cl_seqid + 1) { 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; status = nfserr_seq_misordered;
dprintk("Sequence misordered!\n"); dprintk("Sequence misordered!\n");
dprintk("Expected seqid= %d but got seqid= %d\n", dprintk("Expected seqid= %d but got seqid= %d\n",
conf->cl_seqid, cr_ses->seqid); slot->sl_seqid, cr_ses->seqid);
goto out; goto out;
} }
conf->cl_seqid++; conf->cl_slot.sl_seqid++;
} else if (unconf) { } else if (unconf) {
if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred) || if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred) ||
(ip_addr != unconf->cl_addr)) { (ip_addr != unconf->cl_addr)) {
...@@ -1337,11 +1347,15 @@ nfsd4_create_session(struct svc_rqst *rqstp, ...@@ -1337,11 +1347,15 @@ nfsd4_create_session(struct svc_rqst *rqstp,
goto out; 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; status = nfserr_seq_misordered;
goto out; goto out;
} }
slot->sl_seqid++; /* from 0 to 1 */
move_to_confirmed(unconf); move_to_confirmed(unconf);
/* /*
...@@ -1360,11 +1374,12 @@ nfsd4_create_session(struct svc_rqst *rqstp, ...@@ -1360,11 +1374,12 @@ nfsd4_create_session(struct svc_rqst *rqstp,
if (status) if (status)
goto out; goto out;
out_replay:
memcpy(cr_ses->sessionid.data, conf->cl_sessionid.data, memcpy(cr_ses->sessionid.data, conf->cl_sessionid.data,
NFS4_MAX_SESSIONID_LEN); NFS4_MAX_SESSIONID_LEN);
cr_ses->seqid = conf->cl_seqid; cr_ses->seqid = slot->sl_seqid;
slot->sl_inuse = true;
cstate->slot = slot;
out: out:
nfs4_unlock_state(); nfs4_unlock_state();
dprintk("%s returns %d\n", __func__, ntohl(status)); dprintk("%s returns %d\n", __func__, ntohl(status));
......
...@@ -190,7 +190,7 @@ struct nfs4_client { ...@@ -190,7 +190,7 @@ struct nfs4_client {
/* for nfs41 */ /* for nfs41 */
struct list_head cl_sessions; struct list_head cl_sessions;
u32 cl_seqid; /* seqid for create_session */ struct nfsd4_slot cl_slot; /* create_session slot */
u32 cl_exchange_flags; u32 cl_exchange_flags;
struct nfs4_sessionid cl_sessionid; struct nfs4_sessionid cl_sessionid;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册