aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/lockd/netns.h12
-rw-r--r--fs/lockd/svc.c45
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
6struct lockd_net {
7 unsigned int nlmsvc_users;
8};
9
10extern 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;
50static struct svc_rqst *nlmsvc_rqst; 52static struct svc_rqst *nlmsvc_rqst;
51unsigned long nlmsvc_timeout; 53unsigned long nlmsvc_timeout;
52 54
55int 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)
316destroy_and_out: 320destroy_and_out:
317 svc_destroy(serv); 321 svc_destroy(serv);
318out: 322out:
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,
500module_param(nsm_use_hostnames, bool, 0644); 508module_param(nsm_use_hostnames, bool, 0644);
501module_param(nlm_max_connections, uint, 0644); 509module_param(nlm_max_connections, uint, 0644);
502 510
511static int lockd_init_net(struct net *net)
512{
513 return 0;
514}
515
516static void lockd_exit_net(struct net *net)
517{
518}
519
520static 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
507static int __init init_nlm(void) 532static 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
547err_pernet:
548#ifdef CONFIG_SYSCTL
549 unregister_sysctl_table(nlm_sysctl_table);
514#endif 550#endif
551err_sysctl:
552 return err;
515} 553}
516 554
517static void __exit exit_nlm(void) 555static 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