aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@citi.umich.edu>2009-01-11 15:24:04 -0500
committerJ. Bruce Fields <bfields@citi.umich.edu>2009-03-18 17:30:47 -0400
commitf044ff830f1afe91e4388320f0c7b6e08d2e05f8 (patch)
tree0656c99afbc46b094e276ea91078784cca1cf114
parentf1d110caf7d759eae2c02c84343f63d83db9b9be (diff)
nfsd4: split open/lockowner release code
The caller always knows specifically whether it's releasing a lockowner or an openowner, and the code is simpler if we use separate functions (and the apparent recursion is gone). Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
-rw-r--r--fs/nfsd/nfs4state.c57
1 files changed, 34 insertions, 23 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 6ab30772496e..41a3590ef2cc 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -116,9 +116,6 @@ opaque_hashval(const void *ptr, int nbytes)
116 return x; 116 return x;
117} 117}
118 118
119/* forward declarations */
120static void release_stateowner(struct nfs4_stateowner *sop);
121
122/* 119/*
123 * Delegation state 120 * Delegation state
124 */ 121 */
@@ -329,6 +326,26 @@ static void release_lock_stateid(struct nfs4_stateid *stp)
329 free_generic_stateid(stp); 326 free_generic_stateid(stp);
330} 327}
331 328
329static void unhash_lockowner(struct nfs4_stateowner *sop)
330{
331 struct nfs4_stateid *stp;
332
333 list_del(&sop->so_idhash);
334 list_del(&sop->so_strhash);
335 list_del(&sop->so_perstateid);
336 while (!list_empty(&sop->so_stateids)) {
337 stp = list_first_entry(&sop->so_stateids,
338 struct nfs4_stateid, st_perstateowner);
339 release_lock_stateid(stp);
340 }
341}
342
343static void release_lockowner(struct nfs4_stateowner *sop)
344{
345 unhash_lockowner(sop);
346 nfs4_put_stateowner(sop);
347}
348
332static void 349static void
333release_stateid_lockowners(struct nfs4_stateid *open_stp) 350release_stateid_lockowners(struct nfs4_stateid *open_stp)
334{ 351{
@@ -339,7 +356,7 @@ release_stateid_lockowners(struct nfs4_stateid *open_stp)
339 struct nfs4_stateowner, so_perstateid); 356 struct nfs4_stateowner, so_perstateid);
340 /* list_del(&open_stp->st_lockowners); */ 357 /* list_del(&open_stp->st_lockowners); */
341 BUG_ON(lock_sop->so_is_open_owner); 358 BUG_ON(lock_sop->so_is_open_owner);
342 release_stateowner(lock_sop); 359 release_lockowner(lock_sop);
343 } 360 }
344} 361}
345 362
@@ -351,30 +368,24 @@ static void release_open_stateid(struct nfs4_stateid *stp)
351 free_generic_stateid(stp); 368 free_generic_stateid(stp);
352} 369}
353 370
354static void 371static void unhash_openowner(struct nfs4_stateowner *sop)
355unhash_stateowner(struct nfs4_stateowner *sop)
356{ 372{
357 struct nfs4_stateid *stp; 373 struct nfs4_stateid *stp;
358 374
359 list_del(&sop->so_idhash); 375 list_del(&sop->so_idhash);
360 list_del(&sop->so_strhash); 376 list_del(&sop->so_strhash);
361 if (sop->so_is_open_owner) 377 list_del(&sop->so_perclient);
362 list_del(&sop->so_perclient); 378 list_del(&sop->so_perstateid); /* XXX: necessary? */
363 list_del(&sop->so_perstateid);
364 while (!list_empty(&sop->so_stateids)) { 379 while (!list_empty(&sop->so_stateids)) {
365 stp = list_entry(sop->so_stateids.next, 380 stp = list_first_entry(&sop->so_stateids,
366 struct nfs4_stateid, st_perstateowner); 381 struct nfs4_stateid, st_perstateowner);
367 if (sop->so_is_open_owner) 382 release_open_stateid(stp);
368 release_open_stateid(stp);
369 else
370 release_lock_stateid(stp);
371 } 383 }
372} 384}
373 385
374static void 386static void release_openowner(struct nfs4_stateowner *sop)
375release_stateowner(struct nfs4_stateowner *sop)
376{ 387{
377 unhash_stateowner(sop); 388 unhash_openowner(sop);
378 list_del(&sop->so_close_lru); 389 list_del(&sop->so_close_lru);
379 nfs4_put_stateowner(sop); 390 nfs4_put_stateowner(sop);
380} 391}
@@ -488,7 +499,7 @@ expire_client(struct nfs4_client *clp)
488 list_del(&clp->cl_lru); 499 list_del(&clp->cl_lru);
489 while (!list_empty(&clp->cl_openowners)) { 500 while (!list_empty(&clp->cl_openowners)) {
490 sop = list_entry(clp->cl_openowners.next, struct nfs4_stateowner, so_perclient); 501 sop = list_entry(clp->cl_openowners.next, struct nfs4_stateowner, so_perclient);
491 release_stateowner(sop); 502 release_openowner(sop);
492 } 503 }
493 put_nfs4_client(clp); 504 put_nfs4_client(clp);
494} 505}
@@ -1443,7 +1454,7 @@ nfsd4_process_open1(struct nfsd4_open *open)
1443 if (!sop->so_confirmed) { 1454 if (!sop->so_confirmed) {
1444 /* Replace unconfirmed owners without checking for replay. */ 1455 /* Replace unconfirmed owners without checking for replay. */
1445 clp = sop->so_client; 1456 clp = sop->so_client;
1446 release_stateowner(sop); 1457 release_openowner(sop);
1447 open->op_stateowner = NULL; 1458 open->op_stateowner = NULL;
1448 goto renew; 1459 goto renew;
1449 } 1460 }
@@ -1906,7 +1917,7 @@ nfs4_laundromat(void)
1906 } 1917 }
1907 dprintk("NFSD: purging unused open stateowner (so_id %d)\n", 1918 dprintk("NFSD: purging unused open stateowner (so_id %d)\n",
1908 sop->so_id); 1919 sop->so_id);
1909 release_stateowner(sop); 1920 release_openowner(sop);
1910 } 1921 }
1911 if (clientid_val < NFSD_LAUNDROMAT_MINTIMEOUT) 1922 if (clientid_val < NFSD_LAUNDROMAT_MINTIMEOUT)
1912 clientid_val = NFSD_LAUNDROMAT_MINTIMEOUT; 1923 clientid_val = NFSD_LAUNDROMAT_MINTIMEOUT;
@@ -2796,7 +2807,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2796 } 2807 }
2797out: 2808out:
2798 if (status && lock->lk_is_new && lock_sop) 2809 if (status && lock->lk_is_new && lock_sop)
2799 release_stateowner(lock_sop); 2810 release_lockowner(lock_sop);
2800 if (lock->lk_replay_owner) { 2811 if (lock->lk_replay_owner) {
2801 nfs4_get_stateowner(lock->lk_replay_owner); 2812 nfs4_get_stateowner(lock->lk_replay_owner);
2802 cstate->replay_owner = lock->lk_replay_owner; 2813 cstate->replay_owner = lock->lk_replay_owner;
@@ -3045,7 +3056,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
3045 /* unhash_stateowner deletes so_perclient only 3056 /* unhash_stateowner deletes so_perclient only
3046 * for openowners. */ 3057 * for openowners. */
3047 list_del(&sop->so_perclient); 3058 list_del(&sop->so_perclient);
3048 release_stateowner(sop); 3059 release_lockowner(sop);
3049 } 3060 }
3050out: 3061out:
3051 nfs4_unlock_state(); 3062 nfs4_unlock_state();