aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4state.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-01-17 22:04:24 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-01-31 18:20:28 -0500
commitd1e284d50a1506aab8ad7895f31b5f93b5647fc9 (patch)
tree128f19f0646c77d4de820e39f0a724ce37ae1d57 /fs/nfs/nfs4state.c
parent1313e6034a73a55d6293dbdc62b8853dd067771a (diff)
NFSv4: Clean up nfs4_get_state_owner
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4state.c')
-rw-r--r--fs/nfs/nfs4state.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index a53f33b4ac3a..a8a42a677d8f 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -444,13 +444,17 @@ nfs4_remove_state_owner_locked(struct nfs4_state_owner *sp)
444 * 444 *
445 */ 445 */
446static struct nfs4_state_owner * 446static struct nfs4_state_owner *
447nfs4_alloc_state_owner(void) 447nfs4_alloc_state_owner(struct nfs_server *server,
448 struct rpc_cred *cred,
449 gfp_t gfp_flags)
448{ 450{
449 struct nfs4_state_owner *sp; 451 struct nfs4_state_owner *sp;
450 452
451 sp = kzalloc(sizeof(*sp),GFP_NOFS); 453 sp = kzalloc(sizeof(*sp), gfp_flags);
452 if (!sp) 454 if (!sp)
453 return NULL; 455 return NULL;
456 sp->so_server = server;
457 sp->so_cred = get_rpccred(cred);
454 spin_lock_init(&sp->so_lock); 458 spin_lock_init(&sp->so_lock);
455 INIT_LIST_HEAD(&sp->so_states); 459 INIT_LIST_HEAD(&sp->so_states);
456 rpc_init_wait_queue(&sp->so_sequence.wait, "Seqid_waitqueue"); 460 rpc_init_wait_queue(&sp->so_sequence.wait, "Seqid_waitqueue");
@@ -516,7 +520,8 @@ static void nfs4_gc_state_owners(struct nfs_server *server)
516 * Returns a pointer to an instantiated nfs4_state_owner struct, or NULL. 520 * Returns a pointer to an instantiated nfs4_state_owner struct, or NULL.
517 */ 521 */
518struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server, 522struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server,
519 struct rpc_cred *cred) 523 struct rpc_cred *cred,
524 gfp_t gfp_flags)
520{ 525{
521 struct nfs_client *clp = server->nfs_client; 526 struct nfs_client *clp = server->nfs_client;
522 struct nfs4_state_owner *sp, *new; 527 struct nfs4_state_owner *sp, *new;
@@ -526,20 +531,13 @@ struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server,
526 spin_unlock(&clp->cl_lock); 531 spin_unlock(&clp->cl_lock);
527 if (sp != NULL) 532 if (sp != NULL)
528 goto out; 533 goto out;
529 new = nfs4_alloc_state_owner(); 534 new = nfs4_alloc_state_owner(server, cred, gfp_flags);
530 if (new == NULL) 535 if (new == NULL)
531 goto out; 536 goto out;
532 new->so_server = server;
533 new->so_cred = cred;
534 spin_lock(&clp->cl_lock);
535 sp = nfs4_insert_state_owner_locked(new); 537 sp = nfs4_insert_state_owner_locked(new);
536 spin_unlock(&clp->cl_lock); 538 spin_unlock(&clp->cl_lock);
537 if (sp == new) 539 if (sp != new)
538 get_rpccred(cred); 540 nfs4_free_state_owner(new);
539 else {
540 rpc_destroy_wait_queue(&new->so_sequence.wait);
541 kfree(new);
542 }
543out: 541out:
544 nfs4_gc_state_owners(server); 542 nfs4_gc_state_owners(server);
545 return sp; 543 return sp;