diff options
author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2012-01-31 06:08:13 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-02-15 00:19:48 -0500 |
commit | 66697bfd6aec0a9ca9331c1aa544ac20324a7561 (patch) | |
tree | f4e16eba25d9b757e256f96d0a1eca58b65a68cb | |
parent | bb2224df5ffe4f864f5b696199b17db1ce77bc0a (diff) |
LockD: make nlm hosts network namespace aware
This object depends on RPC client, and thus on network namespace.
So let's make it's allocation and lookup in network namespace context.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/lockd/clntlock.c | 3 | ||||
-rw-r--r-- | fs/lockd/host.c | 16 | ||||
-rw-r--r-- | fs/nfs/client.c | 1 | ||||
-rw-r--r-- | include/linux/lockd/bind.h | 1 | ||||
-rw-r--r-- | include/linux/lockd/lockd.h | 4 |
5 files changed, 21 insertions, 4 deletions
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c index 8d4ea8351e3d..ba1dc2eebd1e 100644 --- a/fs/lockd/clntlock.c +++ b/fs/lockd/clntlock.c | |||
@@ -62,7 +62,8 @@ struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init) | |||
62 | 62 | ||
63 | host = nlmclnt_lookup_host(nlm_init->address, nlm_init->addrlen, | 63 | host = nlmclnt_lookup_host(nlm_init->address, nlm_init->addrlen, |
64 | nlm_init->protocol, nlm_version, | 64 | nlm_init->protocol, nlm_version, |
65 | nlm_init->hostname, nlm_init->noresvport); | 65 | nlm_init->hostname, nlm_init->noresvport, |
66 | nlm_init->net); | ||
66 | if (host == NULL) { | 67 | if (host == NULL) { |
67 | lockd_down(); | 68 | lockd_down(); |
68 | return ERR_PTR(-ENOLCK); | 69 | return ERR_PTR(-ENOLCK); |
diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 6f29836ec0cb..9ebd91dc42c3 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/lockd/lockd.h> | 17 | #include <linux/lockd/lockd.h> |
18 | #include <linux/mutex.h> | 18 | #include <linux/mutex.h> |
19 | 19 | ||
20 | #include <linux/sunrpc/svc_xprt.h> | ||
21 | |||
20 | #include <net/ipv6.h> | 22 | #include <net/ipv6.h> |
21 | 23 | ||
22 | #define NLMDBG_FACILITY NLMDBG_HOSTCACHE | 24 | #define NLMDBG_FACILITY NLMDBG_HOSTCACHE |
@@ -54,6 +56,7 @@ struct nlm_lookup_host_info { | |||
54 | const char *hostname; /* remote's hostname */ | 56 | const char *hostname; /* remote's hostname */ |
55 | const size_t hostname_len; /* it's length */ | 57 | const size_t hostname_len; /* it's length */ |
56 | const int noresvport; /* use non-priv port */ | 58 | const int noresvport; /* use non-priv port */ |
59 | struct net *net; /* network namespace to bind */ | ||
57 | }; | 60 | }; |
58 | 61 | ||
59 | /* | 62 | /* |
@@ -155,6 +158,7 @@ static struct nlm_host *nlm_alloc_host(struct nlm_lookup_host_info *ni, | |||
155 | INIT_LIST_HEAD(&host->h_reclaim); | 158 | INIT_LIST_HEAD(&host->h_reclaim); |
156 | host->h_nsmhandle = nsm; | 159 | host->h_nsmhandle = nsm; |
157 | host->h_addrbuf = nsm->sm_addrbuf; | 160 | host->h_addrbuf = nsm->sm_addrbuf; |
161 | host->net = ni->net; | ||
158 | 162 | ||
159 | out: | 163 | out: |
160 | return host; | 164 | return host; |
@@ -206,7 +210,8 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, | |||
206 | const unsigned short protocol, | 210 | const unsigned short protocol, |
207 | const u32 version, | 211 | const u32 version, |
208 | const char *hostname, | 212 | const char *hostname, |
209 | int noresvport) | 213 | int noresvport, |
214 | struct net *net) | ||
210 | { | 215 | { |
211 | struct nlm_lookup_host_info ni = { | 216 | struct nlm_lookup_host_info ni = { |
212 | .server = 0, | 217 | .server = 0, |
@@ -217,6 +222,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, | |||
217 | .hostname = hostname, | 222 | .hostname = hostname, |
218 | .hostname_len = strlen(hostname), | 223 | .hostname_len = strlen(hostname), |
219 | .noresvport = noresvport, | 224 | .noresvport = noresvport, |
225 | .net = net, | ||
220 | }; | 226 | }; |
221 | struct hlist_head *chain; | 227 | struct hlist_head *chain; |
222 | struct hlist_node *pos; | 228 | struct hlist_node *pos; |
@@ -231,6 +237,8 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, | |||
231 | 237 | ||
232 | chain = &nlm_client_hosts[nlm_hash_address(sap)]; | 238 | chain = &nlm_client_hosts[nlm_hash_address(sap)]; |
233 | hlist_for_each_entry(host, pos, chain, h_hash) { | 239 | hlist_for_each_entry(host, pos, chain, h_hash) { |
240 | if (host->net != net) | ||
241 | continue; | ||
234 | if (!rpc_cmp_addr(nlm_addr(host), sap)) | 242 | if (!rpc_cmp_addr(nlm_addr(host), sap)) |
235 | continue; | 243 | continue; |
236 | 244 | ||
@@ -318,6 +326,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, | |||
318 | struct nsm_handle *nsm = NULL; | 326 | struct nsm_handle *nsm = NULL; |
319 | struct sockaddr *src_sap = svc_daddr(rqstp); | 327 | struct sockaddr *src_sap = svc_daddr(rqstp); |
320 | size_t src_len = rqstp->rq_daddrlen; | 328 | size_t src_len = rqstp->rq_daddrlen; |
329 | struct net *net = rqstp->rq_xprt->xpt_net; | ||
321 | struct nlm_lookup_host_info ni = { | 330 | struct nlm_lookup_host_info ni = { |
322 | .server = 1, | 331 | .server = 1, |
323 | .sap = svc_addr(rqstp), | 332 | .sap = svc_addr(rqstp), |
@@ -326,6 +335,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, | |||
326 | .version = rqstp->rq_vers, | 335 | .version = rqstp->rq_vers, |
327 | .hostname = hostname, | 336 | .hostname = hostname, |
328 | .hostname_len = hostname_len, | 337 | .hostname_len = hostname_len, |
338 | .net = net, | ||
329 | }; | 339 | }; |
330 | 340 | ||
331 | dprintk("lockd: %s(host='%*s', vers=%u, proto=%s)\n", __func__, | 341 | dprintk("lockd: %s(host='%*s', vers=%u, proto=%s)\n", __func__, |
@@ -339,6 +349,8 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, | |||
339 | 349 | ||
340 | chain = &nlm_server_hosts[nlm_hash_address(ni.sap)]; | 350 | chain = &nlm_server_hosts[nlm_hash_address(ni.sap)]; |
341 | hlist_for_each_entry(host, pos, chain, h_hash) { | 351 | hlist_for_each_entry(host, pos, chain, h_hash) { |
352 | if (host->net != net) | ||
353 | continue; | ||
342 | if (!rpc_cmp_addr(nlm_addr(host), ni.sap)) | 354 | if (!rpc_cmp_addr(nlm_addr(host), ni.sap)) |
343 | continue; | 355 | continue; |
344 | 356 | ||
@@ -431,7 +443,7 @@ nlm_bind_host(struct nlm_host *host) | |||
431 | .to_retries = 5U, | 443 | .to_retries = 5U, |
432 | }; | 444 | }; |
433 | struct rpc_create_args args = { | 445 | struct rpc_create_args args = { |
434 | .net = &init_net, | 446 | .net = host->net, |
435 | .protocol = host->h_proto, | 447 | .protocol = host->h_proto, |
436 | .address = nlm_addr(host), | 448 | .address = nlm_addr(host), |
437 | .addrsize = host->h_addrlen, | 449 | .addrsize = host->h_addrlen, |
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 2328dcbf6c0b..1a5cd49dff80 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -707,6 +707,7 @@ static int nfs_start_lockd(struct nfs_server *server) | |||
707 | .nfs_version = clp->rpc_ops->version, | 707 | .nfs_version = clp->rpc_ops->version, |
708 | .noresvport = server->flags & NFS_MOUNT_NORESVPORT ? | 708 | .noresvport = server->flags & NFS_MOUNT_NORESVPORT ? |
709 | 1 : 0, | 709 | 1 : 0, |
710 | .net = clp->net, | ||
710 | }; | 711 | }; |
711 | 712 | ||
712 | if (nlm_init.nfs_version > 3) | 713 | if (nlm_init.nfs_version > 3) |
diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h index fbc48f898521..11a966e5f829 100644 --- a/include/linux/lockd/bind.h +++ b/include/linux/lockd/bind.h | |||
@@ -42,6 +42,7 @@ struct nlmclnt_initdata { | |||
42 | unsigned short protocol; | 42 | unsigned short protocol; |
43 | u32 nfs_version; | 43 | u32 nfs_version; |
44 | int noresvport; | 44 | int noresvport; |
45 | struct net *net; | ||
45 | }; | 46 | }; |
46 | 47 | ||
47 | /* | 48 | /* |
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h index 8949167a148d..94b3d13be426 100644 --- a/include/linux/lockd/lockd.h +++ b/include/linux/lockd/lockd.h | |||
@@ -67,6 +67,7 @@ struct nlm_host { | |||
67 | struct list_head h_reclaim; /* Locks in RECLAIM state */ | 67 | struct list_head h_reclaim; /* Locks in RECLAIM state */ |
68 | struct nsm_handle *h_nsmhandle; /* NSM status handle */ | 68 | struct nsm_handle *h_nsmhandle; /* NSM status handle */ |
69 | char *h_addrbuf; /* address eyecatcher */ | 69 | char *h_addrbuf; /* address eyecatcher */ |
70 | struct net *net; /* host net */ | ||
70 | }; | 71 | }; |
71 | 72 | ||
72 | /* | 73 | /* |
@@ -222,7 +223,8 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, | |||
222 | const unsigned short protocol, | 223 | const unsigned short protocol, |
223 | const u32 version, | 224 | const u32 version, |
224 | const char *hostname, | 225 | const char *hostname, |
225 | int noresvport); | 226 | int noresvport, |
227 | struct net *net); | ||
226 | void nlmclnt_release_host(struct nlm_host *); | 228 | void nlmclnt_release_host(struct nlm_host *); |
227 | struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, | 229 | struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, |
228 | const char *hostname, | 230 | const char *hostname, |