]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
SUNRPC: unregister service on creation in current network namespace
authorStanislav Kinsbursky <skinsbursky@parallels.com>
Fri, 13 Jan 2012 10:03:04 +0000 (14:03 +0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 1 Feb 2012 00:28:14 +0000 (19:28 -0500)
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>
fs/nfsd/nfssvc.c
include/linux/sunrpc/svc.h
net/sunrpc/svc.c

index eda7d7e55e05c45aa309f1465f60368bf3f00242..fce472f5f39e74f2fb9ab36bdf70019f573a73af 100644 (file)
@@ -251,13 +251,13 @@ static void nfsd_shutdown(void)
        nfsd_up = false;
 }
 
-static void nfsd_last_thread(struct svc_serv *serv)
+static void nfsd_last_thread(struct svc_serv *serv, struct net *net)
 {
        /* When last nfsd thread exits we need to do some clean-up */
        nfsd_serv = NULL;
        nfsd_shutdown();
 
-       svc_rpcb_cleanup(serv);
+       svc_rpcb_cleanup(serv, net);
 
        printk(KERN_WARNING "nfsd: last server has exited, flushing export "
                            "cache\n");
index d3563c2a5808bbaafee69a5a099a66eecab5c7e7..7b65495aa4ef4497108ba8f479c9ec6c25310143 100644 (file)
@@ -84,7 +84,8 @@ struct svc_serv {
        unsigned int            sv_nrpools;     /* number of thread pools */
        struct svc_pool *       sv_pools;       /* array of thread pools */
 
-       void                    (*sv_shutdown)(struct svc_serv *serv);
+       void                    (*sv_shutdown)(struct svc_serv *serv,
+                                              struct net *net);
                                                /* Callback to use when last thread
                                                 * exits.
                                                 */
@@ -413,14 +414,14 @@ struct svc_procedure {
 /*
  * Function prototypes.
  */
-void svc_rpcb_cleanup(struct svc_serv *serv);
+void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net);
 struct svc_serv *svc_create(struct svc_program *, unsigned int,
-                           void (*shutdown)(struct svc_serv *));
+                           void (*shutdown)(struct svc_serv *, struct net *net));
 struct svc_rqst *svc_prepare_thread(struct svc_serv *serv,
                                        struct svc_pool *pool, int node);
 void              svc_exit_thread(struct svc_rqst *);
 struct svc_serv *  svc_create_pooled(struct svc_program *, unsigned int,
-                       void (*shutdown)(struct svc_serv *),
+                       void (*shutdown)(struct svc_serv *, struct net *net),
                        svc_thread_fn, struct module *);
 int               svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
 int               svc_pool_stats_open(struct svc_serv *serv, struct file *file);
index cb2caaee2af97c8b4b2a839af3cbc8a3afe16037..a8b49a0446192eff5e772b710a370ceff1a68f48 100644 (file)
@@ -382,10 +382,10 @@ static int svc_rpcb_setup(struct svc_serv *serv, struct net *net)
        return 0;
 }
 
-void svc_rpcb_cleanup(struct svc_serv *serv)
+void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net)
 {
-       svc_unregister(serv, &init_net);
-       rpcb_put_local(&init_net);
+       svc_unregister(serv, net);
+       rpcb_put_local(net);
 }
 EXPORT_SYMBOL_GPL(svc_rpcb_cleanup);
 
@@ -411,7 +411,7 @@ static int svc_uses_rpcbind(struct svc_serv *serv)
  */
 static struct svc_serv *
 __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
-            void (*shutdown)(struct svc_serv *serv))
+            void (*shutdown)(struct svc_serv *serv, struct net *net))
 {
        struct svc_serv *serv;
        unsigned int vers;
@@ -485,7 +485,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
 
 struct svc_serv *
 svc_create(struct svc_program *prog, unsigned int bufsize,
-          void (*shutdown)(struct svc_serv *serv))
+          void (*shutdown)(struct svc_serv *serv, struct net *net))
 {
        return __svc_create(prog, bufsize, /*npools*/1, shutdown);
 }
@@ -493,7 +493,7 @@ EXPORT_SYMBOL_GPL(svc_create);
 
 struct svc_serv *
 svc_create_pooled(struct svc_program *prog, unsigned int bufsize,
-                 void (*shutdown)(struct svc_serv *serv),
+                 void (*shutdown)(struct svc_serv *serv, struct net *net),
                  svc_thread_fn func, struct module *mod)
 {
        struct svc_serv *serv;
@@ -542,7 +542,7 @@ svc_destroy(struct svc_serv *serv)
        svc_close_all(serv);
 
        if (serv->sv_shutdown)
-               serv->sv_shutdown(serv);
+               serv->sv_shutdown(serv, current->nsproxy->net_ns);
 
        cache_clean_deferred(serv);