nfsd41: Use separate DRC for setclientid
Instead of trying to share the generic 4.1 reply cache code for the CREATE_SESSION reply cache, it's simpler to handle CREATE_SESSION separately. The nfs41 single slot clientid DRC holds the results of create session processing. CREATE_SESSION can be preceeded by a SEQUENCE operation (an embedded CREATE_SESSION) and the create session single slot cache must be maintained. nfsd4_replay_cache_entry() and nfsd4_store_cache_entry() do not implement the replay of an embedded CREATE_SESSION. The clientid DRC slot does not need the inuse, cachethis or other fields that the multiple slot session cache uses. Replace the clientid DRC cache struct nfs4_slot cache with a new nfsd4_clid_slot cache. Save the xdr struct nfsd4_create_session into the cache at the end of processing, and on a replay, replace the struct for the replay request with the cached version all while under the state lock. nfsd4_proc_compound will handle both the solo and embedded CREATE_SESSION case via the normal use of encode_operation. Errors that do not change the create session cache: A create session NFS4ERR_STALE_CLIENTID error means that a client record (and associated create session slot) could not be found and therefore can't be changed. NFSERR_SEQ_MISORDERED errors do not change the slot cache. All other errors get cached. Remove the clientid DRC specific check in nfs4svc_encode_compoundres to put the session only if cstate.session is set which will now always be true. Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
This commit is contained in:
committed by
J. Bruce Fields
parent
88e588d56a
commit
49557cc74c
@@ -1120,7 +1120,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
|
|||||||
BUG_ON(op->status == nfs_ok);
|
BUG_ON(op->status == nfs_ok);
|
||||||
|
|
||||||
encode_op:
|
encode_op:
|
||||||
/* Only from SEQUENCE or CREATE_SESSION */
|
/* Only from SEQUENCE */
|
||||||
if (resp->cstate.status == nfserr_replay_cache) {
|
if (resp->cstate.status == nfserr_replay_cache) {
|
||||||
dprintk("%s NFS4.1 replay from cache\n", __func__);
|
dprintk("%s NFS4.1 replay from cache\n", __func__);
|
||||||
if (nfsd4_not_cached(resp))
|
if (nfsd4_not_cached(resp))
|
||||||
|
|||||||
@@ -653,8 +653,6 @@ 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);
|
||||||
@@ -1293,12 +1291,11 @@ out_copy:
|
|||||||
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_slot.sl_seqid = 0;
|
|
||||||
exid->seqid = 1;
|
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_slot.sl_seqid, new->cl_exchange_flags);
|
new->cl_cs_slot.sl_seqid, new->cl_exchange_flags);
|
||||||
status = nfs_ok;
|
status = nfs_ok;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
@@ -1334,15 +1331,35 @@ check_slot_seqid(u32 seqid, u32 slot_seqid, int slot_inuse)
|
|||||||
return nfserr_seq_misordered;
|
return nfserr_seq_misordered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cache the create session result into the create session single DRC
|
||||||
|
* slot cache by saving the xdr structure. sl_seqid has been set.
|
||||||
|
* Do this for solo or embedded create session operations.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
nfsd4_cache_create_session(struct nfsd4_create_session *cr_ses,
|
||||||
|
struct nfsd4_clid_slot *slot, int nfserr)
|
||||||
|
{
|
||||||
|
slot->sl_status = nfserr;
|
||||||
|
memcpy(&slot->sl_cr_ses, cr_ses, sizeof(*cr_ses));
|
||||||
|
}
|
||||||
|
|
||||||
|
static __be32
|
||||||
|
nfsd4_replay_create_session(struct nfsd4_create_session *cr_ses,
|
||||||
|
struct nfsd4_clid_slot *slot)
|
||||||
|
{
|
||||||
|
memcpy(cr_ses, &slot->sl_cr_ses, sizeof(*cr_ses));
|
||||||
|
return slot->sl_status;
|
||||||
|
}
|
||||||
|
|
||||||
__be32
|
__be32
|
||||||
nfsd4_create_session(struct svc_rqst *rqstp,
|
nfsd4_create_session(struct svc_rqst *rqstp,
|
||||||
struct nfsd4_compound_state *cstate,
|
struct nfsd4_compound_state *cstate,
|
||||||
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;
|
struct nfsd4_clid_slot *cs_slot = NULL;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
nfs4_lock_state();
|
nfs4_lock_state();
|
||||||
@@ -1350,25 +1367,22 @@ 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) {
|
||||||
slot = &conf->cl_slot;
|
cs_slot = &conf->cl_cs_slot;
|
||||||
status = check_slot_seqid(cr_ses->seqid, slot->sl_seqid,
|
status = check_slot_seqid(cr_ses->seqid, cs_slot->sl_seqid, 0);
|
||||||
slot->sl_inuse);
|
|
||||||
if (status == nfserr_replay_cache) {
|
if (status == nfserr_replay_cache) {
|
||||||
dprintk("Got a create_session replay! seqid= %d\n",
|
dprintk("Got a create_session replay! seqid= %d\n",
|
||||||
slot->sl_seqid);
|
cs_slot->sl_seqid);
|
||||||
cstate->slot = slot;
|
|
||||||
cstate->status = status;
|
|
||||||
/* Return the cached reply status */
|
/* Return the cached reply status */
|
||||||
status = nfsd4_replay_cache_entry(resp, NULL);
|
status = nfsd4_replay_create_session(cr_ses, cs_slot);
|
||||||
goto out;
|
goto out;
|
||||||
} else if (cr_ses->seqid != conf->cl_slot.sl_seqid + 1) {
|
} else if (cr_ses->seqid != cs_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",
|
||||||
slot->sl_seqid, cr_ses->seqid);
|
cs_slot->sl_seqid, cr_ses->seqid);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
conf->cl_slot.sl_seqid++;
|
cs_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)) {
|
||||||
@@ -1376,16 +1390,15 @@ nfsd4_create_session(struct svc_rqst *rqstp,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
slot = &unconf->cl_slot;
|
cs_slot = &unconf->cl_cs_slot;
|
||||||
status = check_slot_seqid(cr_ses->seqid, slot->sl_seqid,
|
status = check_slot_seqid(cr_ses->seqid, cs_slot->sl_seqid, 0);
|
||||||
slot->sl_inuse);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* an unconfirmed replay returns misordered */
|
/* an unconfirmed replay returns misordered */
|
||||||
status = nfserr_seq_misordered;
|
status = nfserr_seq_misordered;
|
||||||
goto out;
|
goto out_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
slot->sl_seqid++; /* from 0 to 1 */
|
cs_slot->sl_seqid++; /* from 0 to 1 */
|
||||||
move_to_confirmed(unconf);
|
move_to_confirmed(unconf);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1406,12 +1419,11 @@ nfsd4_create_session(struct svc_rqst *rqstp,
|
|||||||
|
|
||||||
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 = slot->sl_seqid;
|
cr_ses->seqid = cs_slot->sl_seqid;
|
||||||
|
|
||||||
slot->sl_inuse = true;
|
out_cache:
|
||||||
cstate->slot = slot;
|
/* cache solo and embedded create sessions under the state lock */
|
||||||
/* Ensure a page is used for the cache */
|
nfsd4_cache_create_session(cr_ses, cs_slot, status);
|
||||||
slot->sl_cache_entry.ce_cachethis = 1;
|
|
||||||
out:
|
out:
|
||||||
nfs4_unlock_state();
|
nfs4_unlock_state();
|
||||||
dprintk("%s returns %d\n", __func__, ntohl(status));
|
dprintk("%s returns %d\n", __func__, ntohl(status));
|
||||||
|
|||||||
@@ -3313,7 +3313,6 @@ nfs4svc_encode_compoundres(struct svc_rqst *rqstp, __be32 *p, struct nfsd4_compo
|
|||||||
dprintk("%s: SET SLOT STATE TO AVAILABLE\n", __func__);
|
dprintk("%s: SET SLOT STATE TO AVAILABLE\n", __func__);
|
||||||
resp->cstate.slot->sl_inuse = 0;
|
resp->cstate.slot->sl_inuse = 0;
|
||||||
}
|
}
|
||||||
if (resp->cstate.session)
|
|
||||||
nfsd4_put_session(resp->cstate.session);
|
nfsd4_put_session(resp->cstate.session);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -127,6 +127,25 @@ struct nfsd4_channel_attrs {
|
|||||||
u32 rdma_attrs;
|
u32 rdma_attrs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct nfsd4_create_session {
|
||||||
|
clientid_t clientid;
|
||||||
|
struct nfs4_sessionid sessionid;
|
||||||
|
u32 seqid;
|
||||||
|
u32 flags;
|
||||||
|
struct nfsd4_channel_attrs fore_channel;
|
||||||
|
struct nfsd4_channel_attrs back_channel;
|
||||||
|
u32 callback_prog;
|
||||||
|
u32 uid;
|
||||||
|
u32 gid;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The single slot clientid cache structure */
|
||||||
|
struct nfsd4_clid_slot {
|
||||||
|
u32 sl_seqid;
|
||||||
|
__be32 sl_status;
|
||||||
|
struct nfsd4_create_session sl_cr_ses;
|
||||||
|
};
|
||||||
|
|
||||||
struct nfsd4_session {
|
struct nfsd4_session {
|
||||||
struct kref se_ref;
|
struct kref se_ref;
|
||||||
struct list_head se_hash; /* hash by sessionid */
|
struct list_head se_hash; /* hash by sessionid */
|
||||||
@@ -193,7 +212,7 @@ struct nfs4_client {
|
|||||||
|
|
||||||
/* for nfs41 */
|
/* for nfs41 */
|
||||||
struct list_head cl_sessions;
|
struct list_head cl_sessions;
|
||||||
struct nfsd4_slot cl_slot; /* create_session slot */
|
struct nfsd4_clid_slot cl_cs_slot; /* create_session slot */
|
||||||
u32 cl_exchange_flags;
|
u32 cl_exchange_flags;
|
||||||
struct nfs4_sessionid cl_sessionid;
|
struct nfs4_sessionid cl_sessionid;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -366,18 +366,6 @@ struct nfsd4_exchange_id {
|
|||||||
int spa_how;
|
int spa_how;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nfsd4_create_session {
|
|
||||||
clientid_t clientid;
|
|
||||||
struct nfs4_sessionid sessionid;
|
|
||||||
u32 seqid;
|
|
||||||
u32 flags;
|
|
||||||
struct nfsd4_channel_attrs fore_channel;
|
|
||||||
struct nfsd4_channel_attrs back_channel;
|
|
||||||
u32 callback_prog;
|
|
||||||
u32 uid;
|
|
||||||
u32 gid;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct nfsd4_sequence {
|
struct nfsd4_sequence {
|
||||||
struct nfs4_sessionid sessionid; /* request/response */
|
struct nfs4_sessionid sessionid; /* request/response */
|
||||||
u32 seqid; /* request/response */
|
u32 seqid; /* request/response */
|
||||||
|
|||||||
Reference in New Issue
Block a user