aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2012-01-31 06:08:05 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-02-15 00:19:47 -0500
commitbb2224df5ffe4f864f5b696199b17db1ce77bc0a (patch)
tree1aa476668966b94ea5f5e399ea15f3aede936f47
parenta9c5d73a8d8cb37601f8c39b35b9b4128e1a5254 (diff)
Lockd: per-net up and down routines introduced
This patch introduces per-net Lockd initialization and destruction routines. The logic is the same as in global Lockd up and down routines. Probably the solution is not the best one. But at least it looks clear. So per-net "up" routine are called only in case of lockd is running already. If per-net resources are not allocated yet, then service is being registered with local portmapper and lockd sockets created. Per-net "down" routine is called on every lockd_down() call in case of global users counter is not zero. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/lockd/svc.c47
-rw-r--r--include/linux/sunrpc/svc.h2
-rw-r--r--net/sunrpc/svc.c3
3 files changed, 49 insertions, 3 deletions
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index 73c9ebf09301..90dec426bfd8 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -251,6 +251,45 @@ out_err:
251 return err; 251 return err;
252} 252}
253 253
254static int lockd_up_net(struct net *net)
255{
256 struct lockd_net *ln = net_generic(net, lockd_net_id);
257 struct svc_serv *serv = nlmsvc_rqst->rq_server;
258 int error;
259
260 if (ln->nlmsvc_users)
261 return 0;
262
263 error = svc_rpcb_setup(serv, net);
264 if (error)
265 goto err_rpcb;
266
267 error = make_socks(serv, net);
268 if (error < 0)
269 goto err_socks;
270 return 0;
271
272err_socks:
273 svc_rpcb_cleanup(serv, net);
274err_rpcb:
275 return error;
276}
277
278static void lockd_down_net(struct net *net)
279{
280 struct lockd_net *ln = net_generic(net, lockd_net_id);
281 struct svc_serv *serv = nlmsvc_rqst->rq_server;
282
283 if (ln->nlmsvc_users) {
284 if (--ln->nlmsvc_users == 0)
285 svc_shutdown_net(serv, net);
286 } else {
287 printk(KERN_ERR "lockd_down_net: no users! task=%p, net=%p\n",
288 nlmsvc_task, net);
289 BUG();
290 }
291}
292
254/* 293/*
255 * Bring up the lockd process if it's not already up. 294 * Bring up the lockd process if it's not already up.
256 */ 295 */
@@ -264,8 +303,10 @@ int lockd_up(void)
264 /* 303 /*
265 * Check whether we're already up and running. 304 * Check whether we're already up and running.
266 */ 305 */
267 if (nlmsvc_rqst) 306 if (nlmsvc_rqst) {
307 error = lockd_up_net(net);
268 goto out; 308 goto out;
309 }
269 310
270 /* 311 /*
271 * Sanity check: if there's no pid, 312 * Sanity check: if there's no pid,
@@ -339,8 +380,10 @@ lockd_down(void)
339{ 380{
340 mutex_lock(&nlmsvc_mutex); 381 mutex_lock(&nlmsvc_mutex);
341 if (nlmsvc_users) { 382 if (nlmsvc_users) {
342 if (--nlmsvc_users) 383 if (--nlmsvc_users) {
384 lockd_down_net(current->nsproxy->net_ns);
343 goto out; 385 goto out;
386 }
344 } else { 387 } else {
345 printk(KERN_ERR "lockd_down: no users! task=%p\n", 388 printk(KERN_ERR "lockd_down: no users! task=%p\n",
346 nlmsvc_task); 389 nlmsvc_task);
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 7b65495aa4ef..51b29ac45a8e 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -414,6 +414,7 @@ struct svc_procedure {
414/* 414/*
415 * Function prototypes. 415 * Function prototypes.
416 */ 416 */
417int svc_rpcb_setup(struct svc_serv *serv, struct net *net);
417void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net); 418void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net);
418struct svc_serv *svc_create(struct svc_program *, unsigned int, 419struct svc_serv *svc_create(struct svc_program *, unsigned int,
419 void (*shutdown)(struct svc_serv *, struct net *net)); 420 void (*shutdown)(struct svc_serv *, struct net *net));
@@ -426,6 +427,7 @@ struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,
426int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int); 427int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
427int svc_pool_stats_open(struct svc_serv *serv, struct file *file); 428int svc_pool_stats_open(struct svc_serv *serv, struct file *file);
428void svc_destroy(struct svc_serv *); 429void svc_destroy(struct svc_serv *);
430void svc_shutdown_net(struct svc_serv *, struct net *);
429int svc_process(struct svc_rqst *); 431int svc_process(struct svc_rqst *);
430int bc_svc_process(struct svc_serv *, struct rpc_rqst *, 432int bc_svc_process(struct svc_serv *, struct rpc_rqst *,
431 struct svc_rqst *); 433 struct svc_rqst *);
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 78abac48985b..4153846984ac 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -369,7 +369,7 @@ svc_pool_for_cpu(struct svc_serv *serv, int cpu)
369 return &serv->sv_pools[pidx % serv->sv_nrpools]; 369 return &serv->sv_pools[pidx % serv->sv_nrpools];
370} 370}
371 371
372static int svc_rpcb_setup(struct svc_serv *serv, struct net *net) 372int svc_rpcb_setup(struct svc_serv *serv, struct net *net)
373{ 373{
374 int err; 374 int err;
375 375
@@ -381,6 +381,7 @@ static int svc_rpcb_setup(struct svc_serv *serv, struct net *net)
381 svc_unregister(serv, net); 381 svc_unregister(serv, net);
382 return 0; 382 return 0;
383} 383}
384EXPORT_SYMBOL_GPL(svc_rpcb_setup);
384 385
385void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net) 386void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net)
386{ 387{