aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorAndy Adamson <andros@netapp.com>2009-04-03 01:28:32 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2009-04-03 20:41:18 -0400
commit38eb76a54d803e6792816623651b1a9cb85f8d01 (patch)
tree090f34b2d92bd92637dabf0fc287cbf544c0cb38 /fs/nfsd
parentec6b5d7b5064fde27aee798b81107ea3a830de85 (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>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfs4state.c39
1 files changed, 27 insertions, 12 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
649free_client(struct nfs4_client *clp) 649free_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
1273out: 1276out:
@@ -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
1363out_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;
1368out: 1383out:
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));