aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4state.c
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2012-11-14 10:21:26 -0500
committerJ. Bruce Fields <bfields@redhat.com>2012-11-15 07:40:44 -0500
commit382a62e76cbf91fb364a4cd8732761e4ecf62153 (patch)
treece6a72d2f464712352ba34324930baec9e6e896c /fs/nfsd/nfs4state.c
parent8daae4dc0d09d44d38194f72bc91740b46a6ce53 (diff)
nfsd: make conf_name_tree per net
This tree holds nfs4_clients info, which are network namespace aware. So let's make it per network namespace. 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.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 6df427773d01..d40e57b9051a 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -404,9 +404,6 @@ static unsigned int clientstr_hashval(const char *name)
404} 404}
405 405
406/* 406/*
407 * conf_id_hashtbl[], and conf_name_tree hold confirmed
408 * setclientid_confirmed info.
409 *
410 * unconf_id_hashtbl[] and unconf_name_tree hold unconfirmed 407 * unconf_id_hashtbl[] and unconf_name_tree hold unconfirmed
411 * setclientid info. 408 * setclientid info.
412 * 409 *
@@ -419,7 +416,6 @@ static unsigned int clientstr_hashval(const char *name)
419 * All of the above fields are protected by the client_mutex. 416 * All of the above fields are protected by the client_mutex.
420 */ 417 */
421static struct list_head unconf_id_hashtbl[CLIENT_HASH_SIZE]; 418static struct list_head unconf_id_hashtbl[CLIENT_HASH_SIZE];
422static struct rb_root conf_name_tree;
423static struct rb_root unconf_name_tree; 419static struct rb_root unconf_name_tree;
424static struct list_head client_lru; 420static struct list_head client_lru;
425static struct list_head close_lru; 421static struct list_head close_lru;
@@ -1114,6 +1110,7 @@ destroy_client(struct nfs4_client *clp)
1114 struct nfs4_openowner *oo; 1110 struct nfs4_openowner *oo;
1115 struct nfs4_delegation *dp; 1111 struct nfs4_delegation *dp;
1116 struct list_head reaplist; 1112 struct list_head reaplist;
1113 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
1117 1114
1118 INIT_LIST_HEAD(&reaplist); 1115 INIT_LIST_HEAD(&reaplist);
1119 spin_lock(&recall_lock); 1116 spin_lock(&recall_lock);
@@ -1136,7 +1133,7 @@ destroy_client(struct nfs4_client *clp)
1136 svc_xprt_put(clp->cl_cb_conn.cb_xprt); 1133 svc_xprt_put(clp->cl_cb_conn.cb_xprt);
1137 list_del(&clp->cl_idhash); 1134 list_del(&clp->cl_idhash);
1138 if (test_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags)) 1135 if (test_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags))
1139 rb_erase(&clp->cl_namenode, &conf_name_tree); 1136 rb_erase(&clp->cl_namenode, &nn->conf_name_tree);
1140 else 1137 else
1141 rb_erase(&clp->cl_namenode, &unconf_name_tree); 1138 rb_erase(&clp->cl_namenode, &unconf_name_tree);
1142 spin_lock(&client_lock); 1139 spin_lock(&client_lock);
@@ -1389,7 +1386,7 @@ move_to_confirmed(struct nfs4_client *clp)
1389 dprintk("NFSD: move_to_confirm nfs4_client %p\n", clp); 1386 dprintk("NFSD: move_to_confirm nfs4_client %p\n", clp);
1390 list_move(&clp->cl_idhash, &nn->conf_id_hashtbl[idhashval]); 1387 list_move(&clp->cl_idhash, &nn->conf_id_hashtbl[idhashval]);
1391 rb_erase(&clp->cl_namenode, &unconf_name_tree); 1388 rb_erase(&clp->cl_namenode, &unconf_name_tree);
1392 add_clp_to_name_tree(clp, &conf_name_tree); 1389 add_clp_to_name_tree(clp, &nn->conf_name_tree);
1393 set_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags); 1390 set_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags);
1394 renew_client(clp); 1391 renew_client(clp);
1395} 1392}
@@ -1433,9 +1430,9 @@ static bool clp_used_exchangeid(struct nfs4_client *clp)
1433} 1430}
1434 1431
1435static struct nfs4_client * 1432static struct nfs4_client *
1436find_confirmed_client_by_name(struct xdr_netobj *name) 1433find_confirmed_client_by_name(struct xdr_netobj *name, struct nfsd_net *nn)
1437{ 1434{
1438 return find_clp_in_name_tree(name, &conf_name_tree); 1435 return find_clp_in_name_tree(name, &nn->conf_name_tree);
1439} 1436}
1440 1437
1441static struct nfs4_client * 1438static struct nfs4_client *
@@ -1635,7 +1632,7 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
1635 1632
1636 /* Cases below refer to rfc 5661 section 18.35.4: */ 1633 /* Cases below refer to rfc 5661 section 18.35.4: */
1637 nfs4_lock_state(); 1634 nfs4_lock_state();
1638 conf = find_confirmed_client_by_name(&exid->clname); 1635 conf = find_confirmed_client_by_name(&exid->clname, nn);
1639 if (conf) { 1636 if (conf) {
1640 bool creds_match = same_creds(&conf->cl_cred, &rqstp->rq_cred); 1637 bool creds_match = same_creds(&conf->cl_cred, &rqstp->rq_cred);
1641 bool verfs_match = same_verf(&verf, &conf->cl_verifier); 1638 bool verfs_match = same_verf(&verf, &conf->cl_verifier);
@@ -1829,7 +1826,7 @@ nfsd4_create_session(struct svc_rqst *rqstp,
1829 status = nfserr_seq_misordered; 1826 status = nfserr_seq_misordered;
1830 goto out_free_conn; 1827 goto out_free_conn;
1831 } 1828 }
1832 old = find_confirmed_client_by_name(&unconf->cl_name); 1829 old = find_confirmed_client_by_name(&unconf->cl_name, nn);
1833 if (old) 1830 if (old)
1834 expire_client(old); 1831 expire_client(old);
1835 move_to_confirmed(unconf); 1832 move_to_confirmed(unconf);
@@ -2227,7 +2224,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2227 2224
2228 /* Cases below refer to rfc 3530 section 14.2.33: */ 2225 /* Cases below refer to rfc 3530 section 14.2.33: */
2229 nfs4_lock_state(); 2226 nfs4_lock_state();
2230 conf = find_confirmed_client_by_name(&clname); 2227 conf = find_confirmed_client_by_name(&clname, nn);
2231 if (conf) { 2228 if (conf) {
2232 /* case 0: */ 2229 /* case 0: */
2233 status = nfserr_clid_inuse; 2230 status = nfserr_clid_inuse;
@@ -2309,7 +2306,7 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
2309 nfsd4_probe_callback(conf); 2306 nfsd4_probe_callback(conf);
2310 expire_client(unconf); 2307 expire_client(unconf);
2311 } else { /* case 3: normal case; new or rebooted client */ 2308 } else { /* case 3: normal case; new or rebooted client */
2312 conf = find_confirmed_client_by_name(&unconf->cl_name); 2309 conf = find_confirmed_client_by_name(&unconf->cl_name, nn);
2313 if (conf) 2310 if (conf)
2314 expire_client(conf); 2311 expire_client(conf);
2315 move_to_confirmed(unconf); 2312 move_to_confirmed(unconf);
@@ -4726,7 +4723,6 @@ nfs4_state_init(void)
4726 for (i = 0; i < CLIENT_HASH_SIZE; i++) { 4723 for (i = 0; i < CLIENT_HASH_SIZE; i++) {
4727 INIT_LIST_HEAD(&unconf_id_hashtbl[i]); 4724 INIT_LIST_HEAD(&unconf_id_hashtbl[i]);
4728 } 4725 }
4729 conf_name_tree = RB_ROOT;
4730 unconf_name_tree = RB_ROOT; 4726 unconf_name_tree = RB_ROOT;
4731 for (i = 0; i < SESSION_HASH_SIZE; i++) 4727 for (i = 0; i < SESSION_HASH_SIZE; i++)
4732 INIT_LIST_HEAD(&sessionid_hashtbl[i]); 4728 INIT_LIST_HEAD(&sessionid_hashtbl[i]);
@@ -4772,12 +4768,17 @@ static int nfs4_state_start_net(struct net *net)
4772 nn->conf_id_hashtbl = kmalloc(sizeof(struct list_head) * 4768 nn->conf_id_hashtbl = kmalloc(sizeof(struct list_head) *
4773 CLIENT_HASH_SIZE, GFP_KERNEL); 4769 CLIENT_HASH_SIZE, GFP_KERNEL);
4774 if (!nn->conf_id_hashtbl) 4770 if (!nn->conf_id_hashtbl)
4775 return -ENOMEM; 4771 goto err;
4776 4772
4777 for (i = 0; i < CLIENT_HASH_SIZE; i++) 4773 for (i = 0; i < CLIENT_HASH_SIZE; i++) {
4778 INIT_LIST_HEAD(&nn->conf_id_hashtbl[i]); 4774 INIT_LIST_HEAD(&nn->conf_id_hashtbl[i]);
4775 }
4776 nn->conf_name_tree = RB_ROOT;
4779 4777
4780 return 0; 4778 return 0;
4779
4780err:
4781 return -ENOMEM;
4781} 4782}
4782 4783
4783static void 4784static void