diff options
Diffstat (limited to 'fs/nfs/client.c')
-rw-r--r-- | fs/nfs/client.c | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index f51b2795ce07..9e11d2988830 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -55,7 +55,6 @@ | |||
55 | 55 | ||
56 | #define NFSDBG_FACILITY NFSDBG_CLIENT | 56 | #define NFSDBG_FACILITY NFSDBG_CLIENT |
57 | 57 | ||
58 | DEFINE_SPINLOCK(nfs_client_lock); | ||
59 | static DECLARE_WAIT_QUEUE_HEAD(nfs_client_active_wq); | 58 | static DECLARE_WAIT_QUEUE_HEAD(nfs_client_active_wq); |
60 | #ifdef CONFIG_NFS_V4 | 59 | #ifdef CONFIG_NFS_V4 |
61 | 60 | ||
@@ -73,9 +72,9 @@ static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion) | |||
73 | retry: | 72 | retry: |
74 | if (!idr_pre_get(&nn->cb_ident_idr, GFP_KERNEL)) | 73 | if (!idr_pre_get(&nn->cb_ident_idr, GFP_KERNEL)) |
75 | return -ENOMEM; | 74 | return -ENOMEM; |
76 | spin_lock(&nfs_client_lock); | 75 | spin_lock(&nn->nfs_client_lock); |
77 | ret = idr_get_new(&nn->cb_ident_idr, clp, &clp->cl_cb_ident); | 76 | ret = idr_get_new(&nn->cb_ident_idr, clp, &clp->cl_cb_ident); |
78 | spin_unlock(&nfs_client_lock); | 77 | spin_unlock(&nn->nfs_client_lock); |
79 | if (ret == -EAGAIN) | 78 | if (ret == -EAGAIN) |
80 | goto retry; | 79 | goto retry; |
81 | return ret; | 80 | return ret; |
@@ -313,15 +312,18 @@ static void nfs_free_client(struct nfs_client *clp) | |||
313 | */ | 312 | */ |
314 | void nfs_put_client(struct nfs_client *clp) | 313 | void nfs_put_client(struct nfs_client *clp) |
315 | { | 314 | { |
315 | struct nfs_net *nn; | ||
316 | |||
316 | if (!clp) | 317 | if (!clp) |
317 | return; | 318 | return; |
318 | 319 | ||
319 | dprintk("--> nfs_put_client({%d})\n", atomic_read(&clp->cl_count)); | 320 | dprintk("--> nfs_put_client({%d})\n", atomic_read(&clp->cl_count)); |
321 | nn = net_generic(clp->net, nfs_net_id); | ||
320 | 322 | ||
321 | if (atomic_dec_and_lock(&clp->cl_count, &nfs_client_lock)) { | 323 | if (atomic_dec_and_lock(&clp->cl_count, &nn->nfs_client_lock)) { |
322 | list_del(&clp->cl_share_link); | 324 | list_del(&clp->cl_share_link); |
323 | nfs_cb_idr_remove_locked(clp); | 325 | nfs_cb_idr_remove_locked(clp); |
324 | spin_unlock(&nfs_client_lock); | 326 | spin_unlock(&nn->nfs_client_lock); |
325 | 327 | ||
326 | BUG_ON(!list_empty(&clp->cl_superblocks)); | 328 | BUG_ON(!list_empty(&clp->cl_superblocks)); |
327 | 329 | ||
@@ -516,7 +518,7 @@ nfs_get_client(const struct nfs_client_initdata *cl_init, | |||
516 | 518 | ||
517 | /* see if the client already exists */ | 519 | /* see if the client already exists */ |
518 | do { | 520 | do { |
519 | spin_lock(&nfs_client_lock); | 521 | spin_lock(&nn->nfs_client_lock); |
520 | 522 | ||
521 | clp = nfs_match_client(cl_init); | 523 | clp = nfs_match_client(cl_init); |
522 | if (clp) | 524 | if (clp) |
@@ -524,7 +526,7 @@ nfs_get_client(const struct nfs_client_initdata *cl_init, | |||
524 | if (new) | 526 | if (new) |
525 | goto install_client; | 527 | goto install_client; |
526 | 528 | ||
527 | spin_unlock(&nfs_client_lock); | 529 | spin_unlock(&nn->nfs_client_lock); |
528 | 530 | ||
529 | new = nfs_alloc_client(cl_init); | 531 | new = nfs_alloc_client(cl_init); |
530 | } while (!IS_ERR(new)); | 532 | } while (!IS_ERR(new)); |
@@ -536,7 +538,7 @@ nfs_get_client(const struct nfs_client_initdata *cl_init, | |||
536 | install_client: | 538 | install_client: |
537 | clp = new; | 539 | clp = new; |
538 | list_add(&clp->cl_share_link, &nn->nfs_client_list); | 540 | list_add(&clp->cl_share_link, &nn->nfs_client_list); |
539 | spin_unlock(&nfs_client_lock); | 541 | spin_unlock(&nn->nfs_client_lock); |
540 | 542 | ||
541 | error = cl_init->rpc_ops->init_client(clp, timeparms, ip_addr, | 543 | error = cl_init->rpc_ops->init_client(clp, timeparms, ip_addr, |
542 | authflavour, noresvport); | 544 | authflavour, noresvport); |
@@ -551,7 +553,7 @@ install_client: | |||
551 | * - make sure it's ready before returning | 553 | * - make sure it's ready before returning |
552 | */ | 554 | */ |
553 | found_client: | 555 | found_client: |
554 | spin_unlock(&nfs_client_lock); | 556 | spin_unlock(&nn->nfs_client_lock); |
555 | 557 | ||
556 | if (new) | 558 | if (new) |
557 | nfs_free_client(new); | 559 | nfs_free_client(new); |
@@ -1041,24 +1043,25 @@ static void nfs_server_insert_lists(struct nfs_server *server) | |||
1041 | struct nfs_client *clp = server->nfs_client; | 1043 | struct nfs_client *clp = server->nfs_client; |
1042 | struct nfs_net *nn = net_generic(clp->net, nfs_net_id); | 1044 | struct nfs_net *nn = net_generic(clp->net, nfs_net_id); |
1043 | 1045 | ||
1044 | spin_lock(&nfs_client_lock); | 1046 | spin_lock(&nn->nfs_client_lock); |
1045 | list_add_tail_rcu(&server->client_link, &clp->cl_superblocks); | 1047 | list_add_tail_rcu(&server->client_link, &clp->cl_superblocks); |
1046 | list_add_tail(&server->master_link, &nn->nfs_volume_list); | 1048 | list_add_tail(&server->master_link, &nn->nfs_volume_list); |
1047 | clear_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state); | 1049 | clear_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state); |
1048 | spin_unlock(&nfs_client_lock); | 1050 | spin_unlock(&nn->nfs_client_lock); |
1049 | 1051 | ||
1050 | } | 1052 | } |
1051 | 1053 | ||
1052 | static void nfs_server_remove_lists(struct nfs_server *server) | 1054 | static void nfs_server_remove_lists(struct nfs_server *server) |
1053 | { | 1055 | { |
1054 | struct nfs_client *clp = server->nfs_client; | 1056 | struct nfs_client *clp = server->nfs_client; |
1057 | struct nfs_net *nn = net_generic(clp->net, nfs_net_id); | ||
1055 | 1058 | ||
1056 | spin_lock(&nfs_client_lock); | 1059 | spin_lock(&nn->nfs_client_lock); |
1057 | list_del_rcu(&server->client_link); | 1060 | list_del_rcu(&server->client_link); |
1058 | if (clp && list_empty(&clp->cl_superblocks)) | 1061 | if (clp && list_empty(&clp->cl_superblocks)) |
1059 | set_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state); | 1062 | set_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state); |
1060 | list_del(&server->master_link); | 1063 | list_del(&server->master_link); |
1061 | spin_unlock(&nfs_client_lock); | 1064 | spin_unlock(&nn->nfs_client_lock); |
1062 | 1065 | ||
1063 | synchronize_rcu(); | 1066 | synchronize_rcu(); |
1064 | } | 1067 | } |
@@ -1212,11 +1215,11 @@ nfs4_find_client_ident(struct net *net, int cb_ident) | |||
1212 | struct nfs_client *clp; | 1215 | struct nfs_client *clp; |
1213 | struct nfs_net *nn = net_generic(net, nfs_net_id); | 1216 | struct nfs_net *nn = net_generic(net, nfs_net_id); |
1214 | 1217 | ||
1215 | spin_lock(&nfs_client_lock); | 1218 | spin_lock(&nn->nfs_client_lock); |
1216 | clp = idr_find(&nn->cb_ident_idr, cb_ident); | 1219 | clp = idr_find(&nn->cb_ident_idr, cb_ident); |
1217 | if (clp) | 1220 | if (clp) |
1218 | atomic_inc(&clp->cl_count); | 1221 | atomic_inc(&clp->cl_count); |
1219 | spin_unlock(&nfs_client_lock); | 1222 | spin_unlock(&nn->nfs_client_lock); |
1220 | return clp; | 1223 | return clp; |
1221 | } | 1224 | } |
1222 | 1225 | ||
@@ -1235,7 +1238,7 @@ nfs4_find_client_sessionid(const struct sockaddr *addr, | |||
1235 | struct nfs_client *clp; | 1238 | struct nfs_client *clp; |
1236 | struct nfs_net *nn = net_generic(&init_net, nfs_net_id); | 1239 | struct nfs_net *nn = net_generic(&init_net, nfs_net_id); |
1237 | 1240 | ||
1238 | spin_lock(&nfs_client_lock); | 1241 | spin_lock(&nn->nfs_client_lock); |
1239 | list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) { | 1242 | list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) { |
1240 | if (nfs4_cb_match_client(addr, clp, 1) == false) | 1243 | if (nfs4_cb_match_client(addr, clp, 1) == false) |
1241 | continue; | 1244 | continue; |
@@ -1249,10 +1252,10 @@ nfs4_find_client_sessionid(const struct sockaddr *addr, | |||
1249 | continue; | 1252 | continue; |
1250 | 1253 | ||
1251 | atomic_inc(&clp->cl_count); | 1254 | atomic_inc(&clp->cl_count); |
1252 | spin_unlock(&nfs_client_lock); | 1255 | spin_unlock(&nn->nfs_client_lock); |
1253 | return clp; | 1256 | return clp; |
1254 | } | 1257 | } |
1255 | spin_unlock(&nfs_client_lock); | 1258 | spin_unlock(&nn->nfs_client_lock); |
1256 | return NULL; | 1259 | return NULL; |
1257 | } | 1260 | } |
1258 | 1261 | ||
@@ -1849,7 +1852,7 @@ static void *nfs_server_list_start(struct seq_file *m, loff_t *_pos) | |||
1849 | struct nfs_net *nn = net_generic(m->private, nfs_net_id); | 1852 | struct nfs_net *nn = net_generic(m->private, nfs_net_id); |
1850 | 1853 | ||
1851 | /* lock the list against modification */ | 1854 | /* lock the list against modification */ |
1852 | spin_lock(&nfs_client_lock); | 1855 | spin_lock(&nn->nfs_client_lock); |
1853 | return seq_list_start_head(&nn->nfs_client_list, *_pos); | 1856 | return seq_list_start_head(&nn->nfs_client_list, *_pos); |
1854 | } | 1857 | } |
1855 | 1858 | ||
@@ -1868,7 +1871,9 @@ static void *nfs_server_list_next(struct seq_file *p, void *v, loff_t *pos) | |||
1868 | */ | 1871 | */ |
1869 | static void nfs_server_list_stop(struct seq_file *p, void *v) | 1872 | static void nfs_server_list_stop(struct seq_file *p, void *v) |
1870 | { | 1873 | { |
1871 | spin_unlock(&nfs_client_lock); | 1874 | struct nfs_net *nn = net_generic(p->private, nfs_net_id); |
1875 | |||
1876 | spin_unlock(&nn->nfs_client_lock); | ||
1872 | } | 1877 | } |
1873 | 1878 | ||
1874 | /* | 1879 | /* |
@@ -1930,7 +1935,7 @@ static void *nfs_volume_list_start(struct seq_file *m, loff_t *_pos) | |||
1930 | struct nfs_net *nn = net_generic(m->private, nfs_net_id); | 1935 | struct nfs_net *nn = net_generic(m->private, nfs_net_id); |
1931 | 1936 | ||
1932 | /* lock the list against modification */ | 1937 | /* lock the list against modification */ |
1933 | spin_lock(&nfs_client_lock); | 1938 | spin_lock(&nn->nfs_client_lock); |
1934 | return seq_list_start_head(&nn->nfs_volume_list, *_pos); | 1939 | return seq_list_start_head(&nn->nfs_volume_list, *_pos); |
1935 | } | 1940 | } |
1936 | 1941 | ||
@@ -1949,7 +1954,9 @@ static void *nfs_volume_list_next(struct seq_file *p, void *v, loff_t *pos) | |||
1949 | */ | 1954 | */ |
1950 | static void nfs_volume_list_stop(struct seq_file *p, void *v) | 1955 | static void nfs_volume_list_stop(struct seq_file *p, void *v) |
1951 | { | 1956 | { |
1952 | spin_unlock(&nfs_client_lock); | 1957 | struct nfs_net *nn = net_generic(p->private, nfs_net_id); |
1958 | |||
1959 | spin_unlock(&nn->nfs_client_lock); | ||
1953 | } | 1960 | } |
1954 | 1961 | ||
1955 | /* | 1962 | /* |