aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2012-01-13 05:03:04 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-01-31 19:28:14 -0500
commit5ecebb7c7fd737cf387a552994df319c063973db (patch)
tree5442ab61f417961b8908f1d2e82f837204830b80
parentbee42f688c915b510a4aabae4f7a99457137d6f3 (diff)
SUNRPC: unregister service on creation in current network namespace
On service shutdown we can be sure, that no more users of it left except current. Thus it looks like using current network namespace context is safe in this case. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfsd/nfssvc.c4
-rw-r--r--include/linux/sunrpc/svc.h9
-rw-r--r--net/sunrpc/svc.c14
3 files changed, 14 insertions, 13 deletions
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index eda7d7e55e0..fce472f5f39 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -251,13 +251,13 @@ static void nfsd_shutdown(void)
251 nfsd_up = false; 251 nfsd_up = false;
252} 252}
253 253
254static void nfsd_last_thread(struct svc_serv *serv) 254static void nfsd_last_thread(struct svc_serv *serv, struct net *net)
255{ 255{
256 /* When last nfsd thread exits we need to do some clean-up */ 256 /* When last nfsd thread exits we need to do some clean-up */
257 nfsd_serv = NULL; 257 nfsd_serv = NULL;
258 nfsd_shutdown(); 258 nfsd_shutdown();
259 259
260 svc_rpcb_cleanup(serv); 260 svc_rpcb_cleanup(serv, net);
261 261
262 printk(KERN_WARNING "nfsd: last server has exited, flushing export " 262 printk(KERN_WARNING "nfsd: last server has exited, flushing export "
263 "cache\n"); 263 "cache\n");
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index d3563c2a580..7b65495aa4e 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -84,7 +84,8 @@ struct svc_serv {
84 unsigned int sv_nrpools; /* number of thread pools */ 84 unsigned int sv_nrpools; /* number of thread pools */
85 struct svc_pool * sv_pools; /* array of thread pools */ 85 struct svc_pool * sv_pools; /* array of thread pools */
86 86
87 void (*sv_shutdown)(struct svc_serv *serv); 87 void (*sv_shutdown)(struct svc_serv *serv,
88 struct net *net);
88 /* Callback to use when last thread 89 /* Callback to use when last thread
89 * exits. 90 * exits.
90 */ 91 */
@@ -413,14 +414,14 @@ struct svc_procedure {
413/* 414/*
414 * Function prototypes. 415 * Function prototypes.
415 */ 416 */
416void svc_rpcb_cleanup(struct svc_serv *serv); 417void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net);
417struct svc_serv *svc_create(struct svc_program *, unsigned int, 418struct svc_serv *svc_create(struct svc_program *, unsigned int,
418 void (*shutdown)(struct svc_serv *)); 419 void (*shutdown)(struct svc_serv *, struct net *net));
419struct svc_rqst *svc_prepare_thread(struct svc_serv *serv, 420struct svc_rqst *svc_prepare_thread(struct svc_serv *serv,
420 struct svc_pool *pool, int node); 421 struct svc_pool *pool, int node);
421void svc_exit_thread(struct svc_rqst *); 422void svc_exit_thread(struct svc_rqst *);
422struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, 423struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,
423 void (*shutdown)(struct svc_serv *), 424 void (*shutdown)(struct svc_serv *, struct net *net),
424 svc_thread_fn, struct module *); 425 svc_thread_fn, struct module *);
425int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int); 426int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
426int svc_pool_stats_open(struct svc_serv *serv, struct file *file); 427int svc_pool_stats_open(struct svc_serv *serv, struct file *file);
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index cb2caaee2af..a8b49a04461 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -382,10 +382,10 @@ static int svc_rpcb_setup(struct svc_serv *serv, struct net *net)
382 return 0; 382 return 0;
383} 383}
384 384
385void svc_rpcb_cleanup(struct svc_serv *serv) 385void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net)
386{ 386{
387 svc_unregister(serv, &init_net); 387 svc_unregister(serv, net);
388 rpcb_put_local(&init_net); 388 rpcb_put_local(net);
389} 389}
390EXPORT_SYMBOL_GPL(svc_rpcb_cleanup); 390EXPORT_SYMBOL_GPL(svc_rpcb_cleanup);
391 391
@@ -411,7 +411,7 @@ static int svc_uses_rpcbind(struct svc_serv *serv)
411 */ 411 */
412static struct svc_serv * 412static struct svc_serv *
413__svc_create(struct svc_program *prog, unsigned int bufsize, int npools, 413__svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
414 void (*shutdown)(struct svc_serv *serv)) 414 void (*shutdown)(struct svc_serv *serv, struct net *net))
415{ 415{
416 struct svc_serv *serv; 416 struct svc_serv *serv;
417 unsigned int vers; 417 unsigned int vers;
@@ -485,7 +485,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
485 485
486struct svc_serv * 486struct svc_serv *
487svc_create(struct svc_program *prog, unsigned int bufsize, 487svc_create(struct svc_program *prog, unsigned int bufsize,
488 void (*shutdown)(struct svc_serv *serv)) 488 void (*shutdown)(struct svc_serv *serv, struct net *net))
489{ 489{
490 return __svc_create(prog, bufsize, /*npools*/1, shutdown); 490 return __svc_create(prog, bufsize, /*npools*/1, shutdown);
491} 491}
@@ -493,7 +493,7 @@ EXPORT_SYMBOL_GPL(svc_create);
493 493
494struct svc_serv * 494struct svc_serv *
495svc_create_pooled(struct svc_program *prog, unsigned int bufsize, 495svc_create_pooled(struct svc_program *prog, unsigned int bufsize,
496 void (*shutdown)(struct svc_serv *serv), 496 void (*shutdown)(struct svc_serv *serv, struct net *net),
497 svc_thread_fn func, struct module *mod) 497 svc_thread_fn func, struct module *mod)
498{ 498{
499 struct svc_serv *serv; 499 struct svc_serv *serv;
@@ -542,7 +542,7 @@ svc_destroy(struct svc_serv *serv)
542 svc_close_all(serv); 542 svc_close_all(serv);
543 543
544 if (serv->sv_shutdown) 544 if (serv->sv_shutdown)
545 serv->sv_shutdown(serv); 545 serv->sv_shutdown(serv, current->nsproxy->net_ns);
546 546
547 cache_clean_deferred(serv); 547 cache_clean_deferred(serv);
548 548