diff options
-rw-r--r-- | fs/lockd/netns.h | 12 | ||||
-rw-r--r-- | fs/lockd/svc.c | 45 |
2 files changed, 54 insertions, 3 deletions
diff --git a/fs/lockd/netns.h b/fs/lockd/netns.h new file mode 100644 index 000000000000..ce227e0fbc5c --- /dev/null +++ b/fs/lockd/netns.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef __LOCKD_NETNS_H__ | ||
2 | #define __LOCKD_NETNS_H__ | ||
3 | |||
4 | #include <net/netns/generic.h> | ||
5 | |||
6 | struct lockd_net { | ||
7 | unsigned int nlmsvc_users; | ||
8 | }; | ||
9 | |||
10 | extern int lockd_net_id; | ||
11 | |||
12 | #endif | ||
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index cba35984dde7..73c9ebf09301 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c | |||
@@ -35,6 +35,8 @@ | |||
35 | #include <linux/lockd/lockd.h> | 35 | #include <linux/lockd/lockd.h> |
36 | #include <linux/nfs.h> | 36 | #include <linux/nfs.h> |
37 | 37 | ||
38 | #include "netns.h" | ||
39 | |||
38 | #define NLMDBG_FACILITY NLMDBG_SVC | 40 | #define NLMDBG_FACILITY NLMDBG_SVC |
39 | #define LOCKD_BUFSIZE (1024 + NLMSVC_XDRSIZE) | 41 | #define LOCKD_BUFSIZE (1024 + NLMSVC_XDRSIZE) |
40 | #define ALLOWED_SIGS (sigmask(SIGKILL)) | 42 | #define ALLOWED_SIGS (sigmask(SIGKILL)) |
@@ -50,6 +52,8 @@ static struct task_struct *nlmsvc_task; | |||
50 | static struct svc_rqst *nlmsvc_rqst; | 52 | static struct svc_rqst *nlmsvc_rqst; |
51 | unsigned long nlmsvc_timeout; | 53 | unsigned long nlmsvc_timeout; |
52 | 54 | ||
55 | int lockd_net_id; | ||
56 | |||
53 | /* | 57 | /* |
54 | * These can be set at insmod time (useful for NFS as root filesystem), | 58 | * These can be set at insmod time (useful for NFS as root filesystem), |
55 | * and also changed through the sysctl interface. -- Jamie Lokier, Aug 2003 | 59 | * and also changed through the sysctl interface. -- Jamie Lokier, Aug 2003 |
@@ -316,8 +320,12 @@ int lockd_up(void) | |||
316 | destroy_and_out: | 320 | destroy_and_out: |
317 | svc_destroy(serv); | 321 | svc_destroy(serv); |
318 | out: | 322 | out: |
319 | if (!error) | 323 | if (!error) { |
324 | struct lockd_net *ln = net_generic(net, lockd_net_id); | ||
325 | |||
326 | ln->nlmsvc_users++; | ||
320 | nlmsvc_users++; | 327 | nlmsvc_users++; |
328 | } | ||
321 | mutex_unlock(&nlmsvc_mutex); | 329 | mutex_unlock(&nlmsvc_mutex); |
322 | return error; | 330 | return error; |
323 | } | 331 | } |
@@ -500,24 +508,55 @@ module_param_call(nlm_tcpport, param_set_port, param_get_int, | |||
500 | module_param(nsm_use_hostnames, bool, 0644); | 508 | module_param(nsm_use_hostnames, bool, 0644); |
501 | module_param(nlm_max_connections, uint, 0644); | 509 | module_param(nlm_max_connections, uint, 0644); |
502 | 510 | ||
511 | static int lockd_init_net(struct net *net) | ||
512 | { | ||
513 | return 0; | ||
514 | } | ||
515 | |||
516 | static void lockd_exit_net(struct net *net) | ||
517 | { | ||
518 | } | ||
519 | |||
520 | static struct pernet_operations lockd_net_ops = { | ||
521 | .init = lockd_init_net, | ||
522 | .exit = lockd_exit_net, | ||
523 | .id = &lockd_net_id, | ||
524 | .size = sizeof(struct lockd_net), | ||
525 | }; | ||
526 | |||
527 | |||
503 | /* | 528 | /* |
504 | * Initialising and terminating the module. | 529 | * Initialising and terminating the module. |
505 | */ | 530 | */ |
506 | 531 | ||
507 | static int __init init_nlm(void) | 532 | static int __init init_nlm(void) |
508 | { | 533 | { |
534 | int err; | ||
535 | |||
509 | #ifdef CONFIG_SYSCTL | 536 | #ifdef CONFIG_SYSCTL |
537 | err = -ENOMEM; | ||
510 | nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root); | 538 | nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root); |
511 | return nlm_sysctl_table ? 0 : -ENOMEM; | 539 | if (nlm_sysctl_table == NULL) |
512 | #else | 540 | goto err_sysctl; |
541 | #endif | ||
542 | err = register_pernet_subsys(&lockd_net_ops); | ||
543 | if (err) | ||
544 | goto err_pernet; | ||
513 | return 0; | 545 | return 0; |
546 | |||
547 | err_pernet: | ||
548 | #ifdef CONFIG_SYSCTL | ||
549 | unregister_sysctl_table(nlm_sysctl_table); | ||
514 | #endif | 550 | #endif |
551 | err_sysctl: | ||
552 | return err; | ||
515 | } | 553 | } |
516 | 554 | ||
517 | static void __exit exit_nlm(void) | 555 | static void __exit exit_nlm(void) |
518 | { | 556 | { |
519 | /* FIXME: delete all NLM clients */ | 557 | /* FIXME: delete all NLM clients */ |
520 | nlm_shutdown_hosts(); | 558 | nlm_shutdown_hosts(); |
559 | unregister_pernet_subsys(&lockd_net_ops); | ||
521 | #ifdef CONFIG_SYSCTL | 560 | #ifdef CONFIG_SYSCTL |
522 | unregister_sysctl_table(nlm_sysctl_table); | 561 | unregister_sysctl_table(nlm_sysctl_table); |
523 | #endif | 562 | #endif |