aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd/svc.c
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2012-01-31 06:07:57 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-02-15 00:19:47 -0500
commita9c5d73a8d8cb37601f8c39b35b9b4128e1a5254 (patch)
tree0ae70dea76c0039e5fa0f62e12001c82a0d1647a /fs/lockd/svc.c
parentc228fa2038a33bb3b87f567482124f452e162a71 (diff)
Lockd: pernet usage counter introduced
Lockd is going to be shared between network namespaces - i.e. going to be able to handle lock requests from different network namespaces. This means, that network namespace related resources have to be allocated not once (like now), but for every network namespace context, from which service is requested to operate. This patch implements Lockd per-net users accounting. New per-net counter is used to determine, when per-net resources have to be freed. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/lockd/svc.c')
-rw-r--r--fs/lockd/svc.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index cba35984dde..73c9ebf0930 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