lockd: Remove un-used nfsd headers #includes
[safe/jmp/linux-2.6] / fs / lockd / svc.c
index 56b0767..1a54ae1 100644 (file)
@@ -35,7 +35,6 @@
 #include <linux/sunrpc/svcsock.h>
 #include <net/ip.h>
 #include <linux/lockd/lockd.h>
-#include <linux/lockd/sm_inter.h>
 #include <linux/nfs.h>
 
 #define NLMDBG_FACILITY                NLMDBG_SVC
@@ -45,7 +44,7 @@
 static struct svc_program      nlmsvc_program;
 
 struct nlmsvc_binding *                nlmsvc_ops;
-EXPORT_SYMBOL(nlmsvc_ops);
+EXPORT_SYMBOL_GPL(nlmsvc_ops);
 
 static DEFINE_MUTEX(nlmsvc_mutex);
 static unsigned int            nlmsvc_users;
@@ -60,7 +59,9 @@ unsigned long                 nlmsvc_timeout;
 static unsigned long           nlm_grace_period;
 static unsigned long           nlm_timeout = LOCKD_DFLT_TIMEO;
 static int                     nlm_udpport, nlm_tcpport;
-int                            nsm_use_hostnames = 0;
+
+/* RLIM_NOFILE defaults to 1024. That seems like a reasonable default here. */
+static unsigned int            nlm_max_connections = 1024;
 
 /*
  * Constants needed for the sysctl interface.
@@ -103,6 +104,16 @@ static void set_grace_period(void)
        schedule_delayed_work(&grace_period_end, grace_period);
 }
 
+static void restart_grace(void)
+{
+       if (nlmsvc_ops) {
+               cancel_delayed_work_sync(&grace_period_end);
+               locks_end_grace(&lockd_manager);
+               nlmsvc_invalidate_all();
+               set_grace_period();
+       }
+}
+
 /*
  * This is the lockd kernel thread
  */
@@ -143,12 +154,12 @@ lockd(void *vrqstp)
                long timeout = MAX_SCHEDULE_TIMEOUT;
                RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
 
+               /* update sv_maxconn if it has changed */
+               rqstp->rq_server->sv_maxconn = nlm_max_connections;
+
                if (signalled()) {
                        flush_signals(current);
-                       if (nlmsvc_ops) {
-                               nlmsvc_invalidate_all();
-                               set_grace_period();
-                       }
+                       restart_grace();
                        continue;
                }
 
@@ -189,6 +200,30 @@ lockd(void *vrqstp)
        return 0;
 }
 
+static int create_lockd_listener(struct svc_serv *serv, const char *name,
+                                const int family, const unsigned short port)
+{
+       struct svc_xprt *xprt;
+
+       xprt = svc_find_xprt(serv, name, family, 0);
+       if (xprt == NULL)
+               return svc_create_xprt(serv, name, family, port,
+                                               SVC_SOCK_DEFAULTS);
+       svc_xprt_put(xprt);
+       return 0;
+}
+
+static int create_lockd_family(struct svc_serv *serv, const int family)
+{
+       int err;
+
+       err = create_lockd_listener(serv, "udp", family, nlm_udpport);
+       if (err < 0)
+               return err;
+
+       return create_lockd_listener(serv, "tcp", family, nlm_tcpport);
+}
+
 /*
  * Ensure there are active UDP and TCP listeners for lockd.
  *
@@ -202,29 +237,25 @@ lockd(void *vrqstp)
 static int make_socks(struct svc_serv *serv)
 {
        static int warned;
-       struct svc_xprt *xprt;
-       int err = 0;
+       int err;
 
-       xprt = svc_find_xprt(serv, "udp", 0, 0);
-       if (!xprt)
-               err = svc_create_xprt(serv, "udp", nlm_udpport,
-                                     SVC_SOCK_DEFAULTS);
-       else
-               svc_xprt_put(xprt);
-       if (err >= 0) {
-               xprt = svc_find_xprt(serv, "tcp", 0, 0);
-               if (!xprt)
-                       err = svc_create_xprt(serv, "tcp", nlm_tcpport,
-                                             SVC_SOCK_DEFAULTS);
-               else
-                       svc_xprt_put(xprt);
-       }
-       if (err >= 0) {
-               warned = 0;
-               err = 0;
-       } else if (warned++ == 0)
+       err = create_lockd_family(serv, PF_INET);
+       if (err < 0)
+               goto out_err;
+
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+       err = create_lockd_family(serv, PF_INET6);
+       if (err < 0 && err != -EAFNOSUPPORT)
+               goto out_err;
+#endif /* CONFIG_IPV6 || CONFIG_IPV6_MODULE */
+
+       warned = 0;
+       return 0;
+
+out_err:
+       if (warned++ == 0)
                printk(KERN_WARNING
-                      "lockd_up: makesock failed, error=%d\n", err);
+                       "lockd_up: makesock failed, error=%d\n", err);
        return err;
 }
 
@@ -252,7 +283,7 @@ int lockd_up(void)
                        "lockd_up: no pid, %d users??\n", nlmsvc_users);
 
        error = -ENOMEM;
-       serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, AF_INET, NULL);
+       serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, NULL);
        if (!serv) {
                printk(KERN_WARNING "lockd_up: create service failed\n");
                goto out;
@@ -276,6 +307,7 @@ int lockd_up(void)
        }
 
        svc_sock_update_bufs(serv);
+       serv->sv_maxconn = nlm_max_connections;
 
        nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, serv->sv_name);
        if (IS_ERR(nlmsvc_task)) {
@@ -300,7 +332,7 @@ out:
        mutex_unlock(&nlmsvc_mutex);
        return error;
 }
-EXPORT_SYMBOL(lockd_up);
+EXPORT_SYMBOL_GPL(lockd_up);
 
 /*
  * Decrement the user count and bring down lockd if we're the last.
@@ -329,7 +361,7 @@ lockd_down(void)
 out:
        mutex_unlock(&nlmsvc_mutex);
 }
-EXPORT_SYMBOL(lockd_down);
+EXPORT_SYMBOL_GPL(lockd_down);
 
 #ifdef CONFIG_SYSCTL
 
@@ -485,6 +517,7 @@ module_param_call(nlm_udpport, param_set_port, param_get_int,
 module_param_call(nlm_tcpport, param_set_port, param_get_int,
                  &nlm_tcpport, 0644);
 module_param(nsm_use_hostnames, bool, 0644);
+module_param(nlm_max_connections, uint, 0644);
 
 /*
  * Initialising and terminating the module.