Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164599
b: refs/heads/master
c: 49557cc
h: refs/heads/master
i:
  164597: cf527e4
  164595: e34526d
  164591: 6b221c5
v: v3
  • Loading branch information
Andy Adamson authored and J. Bruce Fields committed Jul 28, 2009
1 parent fe9cd09 commit 6639ef2
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 43 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 88e588d56a2f0226a34386b94a03fda97d2b8e67
refs/heads/master: 49557cc74c7bdf6a984be227ead9a84b3a26f053
2 changes: 1 addition & 1 deletion trunk/fs/nfsd/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
BUG_ON(op->status == nfs_ok);

encode_op:
/* Only from SEQUENCE or CREATE_SESSION */
/* Only from SEQUENCE */
if (resp->cstate.status == nfserr_replay_cache) {
dprintk("%s NFS4.1 replay from cache\n", __func__);
if (nfsd4_not_cached(resp))
Expand Down
64 changes: 38 additions & 26 deletions trunk/fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,6 @@ static inline void
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);
Expand Down Expand Up @@ -1293,12 +1291,11 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
exid->clientid.cl_boot = new->cl_clientid.cl_boot;
exid->clientid.cl_id = new->cl_clientid.cl_id;

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_slot.sl_seqid, new->cl_exchange_flags);
new->cl_cs_slot.sl_seqid, new->cl_exchange_flags);
status = nfs_ok;

out:
Expand Down Expand Up @@ -1334,58 +1331,74 @@ check_slot_seqid(u32 seqid, u32 slot_seqid, int slot_inuse)
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
nfsd4_create_session(struct svc_rqst *rqstp,
struct nfsd4_compound_state *cstate,
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;
struct nfsd4_clid_slot *cs_slot = NULL;
int status = 0;

nfs4_lock_state();
unconf = find_unconfirmed_client(&cr_ses->clientid);
conf = find_confirmed_client(&cr_ses->clientid);

if (conf) {
slot = &conf->cl_slot;
status = check_slot_seqid(cr_ses->seqid, slot->sl_seqid,
slot->sl_inuse);
cs_slot = &conf->cl_cs_slot;
status = check_slot_seqid(cr_ses->seqid, cs_slot->sl_seqid, 0);
if (status == nfserr_replay_cache) {
dprintk("Got a create_session replay! seqid= %d\n",
slot->sl_seqid);
cstate->slot = slot;
cstate->status = status;
cs_slot->sl_seqid);
/* Return the cached reply status */
status = nfsd4_replay_cache_entry(resp, NULL);
status = nfsd4_replay_create_session(cr_ses, cs_slot);
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;
dprintk("Sequence misordered!\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;
}
conf->cl_slot.sl_seqid++;
cs_slot->sl_seqid++;
} else if (unconf) {
if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred) ||
(ip_addr != unconf->cl_addr)) {
status = nfserr_clid_inuse;
goto out;
}

slot = &unconf->cl_slot;
status = check_slot_seqid(cr_ses->seqid, slot->sl_seqid,
slot->sl_inuse);
cs_slot = &unconf->cl_cs_slot;
status = check_slot_seqid(cr_ses->seqid, cs_slot->sl_seqid, 0);
if (status) {
/* an unconfirmed replay returns 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);

/*
Expand All @@ -1406,12 +1419,11 @@ nfsd4_create_session(struct svc_rqst *rqstp,

memcpy(cr_ses->sessionid.data, conf->cl_sessionid.data,
NFS4_MAX_SESSIONID_LEN);
cr_ses->seqid = slot->sl_seqid;
cr_ses->seqid = cs_slot->sl_seqid;

slot->sl_inuse = true;
cstate->slot = slot;
/* Ensure a page is used for the cache */
slot->sl_cache_entry.ce_cachethis = 1;
out_cache:
/* cache solo and embedded create sessions under the state lock */
nfsd4_cache_create_session(cr_ses, cs_slot, status);
out:
nfs4_unlock_state();
dprintk("%s returns %d\n", __func__, ntohl(status));
Expand Down
3 changes: 1 addition & 2 deletions trunk/fs/nfsd/nfs4xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3313,8 +3313,7 @@ nfs4svc_encode_compoundres(struct svc_rqst *rqstp, __be32 *p, struct nfsd4_compo
dprintk("%s: SET SLOT STATE TO AVAILABLE\n", __func__);
resp->cstate.slot->sl_inuse = 0;
}
if (resp->cstate.session)
nfsd4_put_session(resp->cstate.session);
nfsd4_put_session(resp->cstate.session);
}
return 1;
}
Expand Down
21 changes: 20 additions & 1 deletion trunk/include/linux/nfsd/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ struct nfsd4_channel_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 kref se_ref;
struct list_head se_hash; /* hash by sessionid */
Expand Down Expand Up @@ -193,7 +212,7 @@ struct nfs4_client {

/* for nfs41 */
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;
struct nfs4_sessionid cl_sessionid;
};
Expand Down
12 changes: 0 additions & 12 deletions trunk/include/linux/nfsd/xdr4.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,18 +366,6 @@ struct nfsd4_exchange_id {
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 nfs4_sessionid sessionid; /* request/response */
u32 seqid; /* request/response */
Expand Down

0 comments on commit 6639ef2

Please sign in to comment.