diff options
author | Andy Adamson <andros@netapp.com> | 2009-04-03 01:28:32 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2009-04-03 20:41:18 -0400 |
commit | 38eb76a54d803e6792816623651b1a9cb85f8d01 (patch) | |
tree | 090f34b2d92bd92637dabf0fc287cbf544c0cb38 | |
parent | ec6b5d7b5064fde27aee798b81107ea3a830de85 (diff) |
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: Benny Halevy <bhalevy@panasas.com>
[nfsd41: use bool inuse for slot state]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfsd41: revert portion of nfsd4_set_cache_entry]
Signed-off-by: Andy Adamson <andros@netpp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
-rw-r--r-- | fs/nfsd/nfs4state.c | 39 | ||||
-rw-r--r-- | include/linux/nfsd/state.h | 2 |
2 files changed, 28 insertions, 13 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 463ae39df148..58f9797eb09e 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -649,6 +649,8 @@ static inline void | |||
649 | free_client(struct nfs4_client *clp) | 649 | free_client(struct nfs4_client *clp) |
650 | { | 650 | { |
651 | shutdown_callback_client(clp); | 651 | shutdown_callback_client(clp); |
652 | nfsd4_release_respages(clp->cl_slot.sl_cache_entry.ce_respages, | ||
653 | clp->cl_slot.sl_cache_entry.ce_resused); | ||
652 | if (clp->cl_cred.cr_group_info) | 654 | if (clp->cl_cred.cr_group_info) |
653 | put_group_info(clp->cl_cred.cr_group_info); | 655 | put_group_info(clp->cl_cred.cr_group_info); |
654 | kfree(clp->cl_principal); | 656 | kfree(clp->cl_principal); |
@@ -1263,11 +1265,12 @@ out_copy: | |||
1263 | exid->clientid.cl_boot = new->cl_clientid.cl_boot; | 1265 | exid->clientid.cl_boot = new->cl_clientid.cl_boot; |
1264 | exid->clientid.cl_id = new->cl_clientid.cl_id; | 1266 | exid->clientid.cl_id = new->cl_clientid.cl_id; |
1265 | 1267 | ||
1266 | new->cl_seqid = exid->seqid = 1; | 1268 | new->cl_slot.sl_seqid = 0; |
1269 | exid->seqid = 1; | ||
1267 | nfsd4_set_ex_flags(new, exid); | 1270 | nfsd4_set_ex_flags(new, exid); |
1268 | 1271 | ||
1269 | dprintk("nfsd4_exchange_id seqid %d flags %x\n", | 1272 | dprintk("nfsd4_exchange_id seqid %d flags %x\n", |
1270 | new->cl_seqid, new->cl_exchange_flags); | 1273 | new->cl_slot.sl_seqid, new->cl_exchange_flags); |
1271 | status = nfs_ok; | 1274 | status = nfs_ok; |
1272 | 1275 | ||
1273 | out: | 1276 | out: |
@@ -1309,7 +1312,9 @@ nfsd4_create_session(struct svc_rqst *rqstp, | |||
1309 | struct nfsd4_create_session *cr_ses) | 1312 | struct nfsd4_create_session *cr_ses) |
1310 | { | 1313 | { |
1311 | u32 ip_addr = svc_addr_in(rqstp)->sin_addr.s_addr; | 1314 | u32 ip_addr = svc_addr_in(rqstp)->sin_addr.s_addr; |
1315 | struct nfsd4_compoundres *resp = rqstp->rq_resp; | ||
1312 | struct nfs4_client *conf, *unconf; | 1316 | struct nfs4_client *conf, *unconf; |
1317 | struct nfsd4_slot *slot = NULL; | ||
1313 | int status = 0; | 1318 | int status = 0; |
1314 | 1319 | ||
1315 | nfs4_lock_state(); | 1320 | nfs4_lock_state(); |
@@ -1317,19 +1322,24 @@ nfsd4_create_session(struct svc_rqst *rqstp, | |||
1317 | conf = find_confirmed_client(&cr_ses->clientid); | 1322 | conf = find_confirmed_client(&cr_ses->clientid); |
1318 | 1323 | ||
1319 | if (conf) { | 1324 | if (conf) { |
1320 | status = nfs_ok; | 1325 | slot = &conf->cl_slot; |
1321 | if (conf->cl_seqid == cr_ses->seqid) { | 1326 | status = check_slot_seqid(cr_ses->seqid, slot); |
1327 | if (status == nfserr_replay_cache) { | ||
1322 | dprintk("Got a create_session replay! seqid= %d\n", | 1328 | dprintk("Got a create_session replay! seqid= %d\n", |
1323 | conf->cl_seqid); | 1329 | slot->sl_seqid); |
1324 | goto out_replay; | 1330 | cstate->slot = slot; |
1325 | } else if (cr_ses->seqid != conf->cl_seqid + 1) { | 1331 | cstate->status = status; |
1332 | /* Return the cached reply status */ | ||
1333 | status = nfsd4_replay_cache_entry(resp); | ||
1334 | goto out; | ||
1335 | } else if (cr_ses->seqid != conf->cl_slot.sl_seqid + 1) { | ||
1326 | status = nfserr_seq_misordered; | 1336 | status = nfserr_seq_misordered; |
1327 | dprintk("Sequence misordered!\n"); | 1337 | dprintk("Sequence misordered!\n"); |
1328 | dprintk("Expected seqid= %d but got seqid= %d\n", | 1338 | dprintk("Expected seqid= %d but got seqid= %d\n", |
1329 | conf->cl_seqid, cr_ses->seqid); | 1339 | slot->sl_seqid, cr_ses->seqid); |
1330 | goto out; | 1340 | goto out; |
1331 | } | 1341 | } |
1332 | conf->cl_seqid++; | 1342 | conf->cl_slot.sl_seqid++; |
1333 | } else if (unconf) { | 1343 | } else if (unconf) { |
1334 | if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred) || | 1344 | if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred) || |
1335 | (ip_addr != unconf->cl_addr)) { | 1345 | (ip_addr != unconf->cl_addr)) { |
@@ -1337,11 +1347,15 @@ nfsd4_create_session(struct svc_rqst *rqstp, | |||
1337 | goto out; | 1347 | goto out; |
1338 | } | 1348 | } |
1339 | 1349 | ||
1340 | if (unconf->cl_seqid != cr_ses->seqid) { | 1350 | slot = &unconf->cl_slot; |
1351 | status = check_slot_seqid(cr_ses->seqid, slot); | ||
1352 | if (status) { | ||
1353 | /* an unconfirmed replay returns misordered */ | ||
1341 | status = nfserr_seq_misordered; | 1354 | status = nfserr_seq_misordered; |
1342 | goto out; | 1355 | goto out; |
1343 | } | 1356 | } |
1344 | 1357 | ||
1358 | slot->sl_seqid++; /* from 0 to 1 */ | ||
1345 | move_to_confirmed(unconf); | 1359 | move_to_confirmed(unconf); |
1346 | 1360 | ||
1347 | /* | 1361 | /* |
@@ -1360,11 +1374,12 @@ nfsd4_create_session(struct svc_rqst *rqstp, | |||
1360 | if (status) | 1374 | if (status) |
1361 | goto out; | 1375 | goto out; |
1362 | 1376 | ||
1363 | out_replay: | ||
1364 | memcpy(cr_ses->sessionid.data, conf->cl_sessionid.data, | 1377 | memcpy(cr_ses->sessionid.data, conf->cl_sessionid.data, |
1365 | NFS4_MAX_SESSIONID_LEN); | 1378 | NFS4_MAX_SESSIONID_LEN); |
1366 | cr_ses->seqid = conf->cl_seqid; | 1379 | cr_ses->seqid = slot->sl_seqid; |
1367 | 1380 | ||
1381 | slot->sl_inuse = true; | ||
1382 | cstate->slot = slot; | ||
1368 | out: | 1383 | out: |
1369 | nfs4_unlock_state(); | 1384 | nfs4_unlock_state(); |
1370 | dprintk("%s returns %d\n", __func__, ntohl(status)); | 1385 | dprintk("%s returns %d\n", __func__, ntohl(status)); |
diff --git a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h index 692edf4c2e7c..f063df7ad134 100644 --- a/include/linux/nfsd/state.h +++ b/include/linux/nfsd/state.h | |||
@@ -190,7 +190,7 @@ struct nfs4_client { | |||
190 | 190 | ||
191 | /* for nfs41 */ | 191 | /* for nfs41 */ |
192 | struct list_head cl_sessions; | 192 | struct list_head cl_sessions; |
193 | u32 cl_seqid; /* seqid for create_session */ | 193 | struct nfsd4_slot cl_slot; /* create_session slot */ |
194 | u32 cl_exchange_flags; | 194 | u32 cl_exchange_flags; |
195 | struct nfs4_sessionid cl_sessionid; | 195 | struct nfs4_sessionid cl_sessionid; |
196 | }; | 196 | }; |