aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4state.c
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2012-11-14 10:21:16 -0500
committerJ. Bruce Fields <bfields@redhat.com>2012-11-15 07:40:43 -0500
commit52e19c09a183d82d99f10c284bc8b27933b1d1fc (patch)
tree7a4f21eecd888cea675d7ccddddfd03774337af4 /fs/nfsd/nfs4state.c
parentc212cecfa21b3d30cd5cc2389754a46973ad9027 (diff)
nfsd: make reclaim_str_hashtbl allocated per net
This hash holds nfs4_clients info, which are network namespace aware. So let's make it allocated per network namespace. Note: this hash is used only by legacy tracker. So let's allocate hash in tracker init. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r--fs/nfsd/nfs4state.c42
1 files changed, 15 insertions, 27 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 001bbc99d7a..ba478555950 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -393,11 +393,6 @@ unhash_delegation(struct nfs4_delegation *dp)
393/* client_lock protects the client lru list and session hash table */ 393/* client_lock protects the client lru list and session hash table */
394static DEFINE_SPINLOCK(client_lock); 394static DEFINE_SPINLOCK(client_lock);
395 395
396/* Hash tables for nfs4_clientid state */
397#define CLIENT_HASH_BITS 4
398#define CLIENT_HASH_SIZE (1 << CLIENT_HASH_BITS)
399#define CLIENT_HASH_MASK (CLIENT_HASH_SIZE - 1)
400
401static unsigned int clientid_hashval(u32 id) 396static unsigned int clientid_hashval(u32 id)
402{ 397{
403 return id & CLIENT_HASH_MASK; 398 return id & CLIENT_HASH_MASK;
@@ -409,11 +404,8 @@ static unsigned int clientstr_hashval(const char *name)
409} 404}
410 405
411/* 406/*
412 * reclaim_str_hashtbl[] holds known client info from previous reset/reboot
413 * used in reboot/reset lease grace period processing
414 *
415 * conf_id_hashtbl[], and conf_name_tree hold confirmed 407 * conf_id_hashtbl[], and conf_name_tree hold confirmed
416 * setclientid_confirmed info. 408 * setclientid_confirmed info.
417 * 409 *
418 * unconf_id_hashtbl[] and unconf_name_tree hold unconfirmed 410 * unconf_id_hashtbl[] and unconf_name_tree hold unconfirmed
419 * setclientid info. 411 * setclientid info.
@@ -426,8 +418,6 @@ static unsigned int clientstr_hashval(const char *name)
426 * 418 *
427 * All of the above fields are protected by the client_mutex. 419 * All of the above fields are protected by the client_mutex.
428 */ 420 */
429static struct list_head reclaim_str_hashtbl[CLIENT_HASH_SIZE];
430static int reclaim_str_hashtbl_size = 0;
431static struct list_head conf_id_hashtbl[CLIENT_HASH_SIZE]; 421static struct list_head conf_id_hashtbl[CLIENT_HASH_SIZE];
432static struct list_head unconf_id_hashtbl[CLIENT_HASH_SIZE]; 422static struct list_head unconf_id_hashtbl[CLIENT_HASH_SIZE];
433static struct rb_root conf_name_tree; 423static struct rb_root conf_name_tree;
@@ -4509,11 +4499,11 @@ alloc_reclaim(void)
4509} 4499}
4510 4500
4511bool 4501bool
4512nfs4_has_reclaimed_state(const char *name) 4502nfs4_has_reclaimed_state(const char *name, struct nfsd_net *nn)
4513{ 4503{
4514 struct nfs4_client_reclaim *crp; 4504 struct nfs4_client_reclaim *crp;
4515 4505
4516 crp = nfsd4_find_reclaim_client(name); 4506 crp = nfsd4_find_reclaim_client(name, nn);
4517 return (crp && crp->cr_clp); 4507 return (crp && crp->cr_clp);
4518} 4508}
4519 4509
@@ -4521,7 +4511,7 @@ nfs4_has_reclaimed_state(const char *name)
4521 * failure => all reset bets are off, nfserr_no_grace... 4511 * failure => all reset bets are off, nfserr_no_grace...
4522 */ 4512 */
4523struct nfs4_client_reclaim * 4513struct nfs4_client_reclaim *
4524nfs4_client_to_reclaim(const char *name) 4514nfs4_client_to_reclaim(const char *name, struct nfsd_net *nn)
4525{ 4515{
4526 unsigned int strhashval; 4516 unsigned int strhashval;
4527 struct nfs4_client_reclaim *crp; 4517 struct nfs4_client_reclaim *crp;
@@ -4531,42 +4521,42 @@ nfs4_client_to_reclaim(const char *name)
4531 if (crp) { 4521 if (crp) {
4532 strhashval = clientstr_hashval(name); 4522 strhashval = clientstr_hashval(name);
4533 INIT_LIST_HEAD(&crp->cr_strhash); 4523 INIT_LIST_HEAD(&crp->cr_strhash);
4534 list_add(&crp->cr_strhash, &reclaim_str_hashtbl[strhashval]); 4524 list_add(&crp->cr_strhash, &nn->reclaim_str_hashtbl[strhashval]);
4535 memcpy(crp->cr_recdir, name, HEXDIR_LEN); 4525 memcpy(crp->cr_recdir, name, HEXDIR_LEN);
4536 crp->cr_clp = NULL; 4526 crp->cr_clp = NULL;
4537 reclaim_str_hashtbl_size++; 4527 nn->reclaim_str_hashtbl_size++;
4538 } 4528 }
4539 return crp; 4529 return crp;
4540} 4530}
4541 4531
4542void 4532void
4543nfs4_remove_reclaim_record(struct nfs4_client_reclaim *crp) 4533nfs4_remove_reclaim_record(struct nfs4_client_reclaim *crp, struct nfsd_net *nn)
4544{ 4534{
4545 list_del(&crp->cr_strhash); 4535 list_del(&crp->cr_strhash);
4546 kfree(crp); 4536 kfree(crp);
4547 reclaim_str_hashtbl_size--; 4537 nn->reclaim_str_hashtbl_size--;
4548} 4538}
4549 4539
4550void 4540void
4551nfs4_release_reclaim(void) 4541nfs4_release_reclaim(struct nfsd_net *nn)
4552{ 4542{
4553 struct nfs4_client_reclaim *crp = NULL; 4543 struct nfs4_client_reclaim *crp = NULL;
4554 int i; 4544 int i;
4555 4545
4556 for (i = 0; i < CLIENT_HASH_SIZE; i++) { 4546 for (i = 0; i < CLIENT_HASH_SIZE; i++) {
4557 while (!list_empty(&reclaim_str_hashtbl[i])) { 4547 while (!list_empty(&nn->reclaim_str_hashtbl[i])) {
4558 crp = list_entry(reclaim_str_hashtbl[i].next, 4548 crp = list_entry(nn->reclaim_str_hashtbl[i].next,
4559 struct nfs4_client_reclaim, cr_strhash); 4549 struct nfs4_client_reclaim, cr_strhash);
4560 nfs4_remove_reclaim_record(crp); 4550 nfs4_remove_reclaim_record(crp, nn);
4561 } 4551 }
4562 } 4552 }
4563 BUG_ON(reclaim_str_hashtbl_size); 4553 BUG_ON(nn->reclaim_str_hashtbl_size);
4564} 4554}
4565 4555
4566/* 4556/*
4567 * called from OPEN, CLAIM_PREVIOUS with a new clientid. */ 4557 * called from OPEN, CLAIM_PREVIOUS with a new clientid. */
4568struct nfs4_client_reclaim * 4558struct nfs4_client_reclaim *
4569nfsd4_find_reclaim_client(const char *recdir) 4559nfsd4_find_reclaim_client(const char *recdir, struct nfsd_net *nn)
4570{ 4560{
4571 unsigned int strhashval; 4561 unsigned int strhashval;
4572 struct nfs4_client_reclaim *crp = NULL; 4562 struct nfs4_client_reclaim *crp = NULL;
@@ -4574,7 +4564,7 @@ nfsd4_find_reclaim_client(const char *recdir)
4574 dprintk("NFSD: nfs4_find_reclaim_client for recdir %s\n", recdir); 4564 dprintk("NFSD: nfs4_find_reclaim_client for recdir %s\n", recdir);
4575 4565
4576 strhashval = clientstr_hashval(recdir); 4566 strhashval = clientstr_hashval(recdir);
4577 list_for_each_entry(crp, &reclaim_str_hashtbl[strhashval], cr_strhash) { 4567 list_for_each_entry(crp, &nn->reclaim_str_hashtbl[strhashval], cr_strhash) {
4578 if (same_name(crp->cr_recdir, recdir)) { 4568 if (same_name(crp->cr_recdir, recdir)) {
4579 return crp; 4569 return crp;
4580 } 4570 }
@@ -4732,7 +4722,6 @@ nfs4_state_init(void)
4732 for (i = 0; i < CLIENT_HASH_SIZE; i++) { 4722 for (i = 0; i < CLIENT_HASH_SIZE; i++) {
4733 INIT_LIST_HEAD(&conf_id_hashtbl[i]); 4723 INIT_LIST_HEAD(&conf_id_hashtbl[i]);
4734 INIT_LIST_HEAD(&unconf_id_hashtbl[i]); 4724 INIT_LIST_HEAD(&unconf_id_hashtbl[i]);
4735 INIT_LIST_HEAD(&reclaim_str_hashtbl[i]);
4736 } 4725 }
4737 conf_name_tree = RB_ROOT; 4726 conf_name_tree = RB_ROOT;
4738 unconf_name_tree = RB_ROOT; 4727 unconf_name_tree = RB_ROOT;
@@ -4749,7 +4738,6 @@ nfs4_state_init(void)
4749 INIT_LIST_HEAD(&close_lru); 4738 INIT_LIST_HEAD(&close_lru);
4750 INIT_LIST_HEAD(&client_lru); 4739 INIT_LIST_HEAD(&client_lru);
4751 INIT_LIST_HEAD(&del_recall_lru); 4740 INIT_LIST_HEAD(&del_recall_lru);
4752 reclaim_str_hashtbl_size = 0;
4753} 4741}
4754 4742
4755/* 4743/*