]> Pileus Git - ~andy/linux/blobdiff - fs/lockd/svc.c
Merge branch 'tracing-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[~andy/linux] / fs / lockd / svc.c
index 64f1c31b58533317d65a256b79e1d5c474620421..1a54ae14a192d551ff02d57a559c109709903c57 100644 (file)
@@ -52,17 +52,6 @@ static struct task_struct    *nlmsvc_task;
 static struct svc_rqst         *nlmsvc_rqst;
 unsigned long                  nlmsvc_timeout;
 
-/*
- * If the kernel has IPv6 support available, always listen for
- * both AF_INET and AF_INET6 requests.
- */
-#if (defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)) && \
-       defined(CONFIG_SUNRPC_REGISTER_V4)
-static const sa_family_t       nlmsvc_family = AF_INET6;
-#else  /* (CONFIG_IPV6 || CONFIG_IPV6_MODULE) && CONFIG_SUNRPC_REGISTER_V4 */
-static const sa_family_t       nlmsvc_family = AF_INET;
-#endif /* (CONFIG_IPV6 || CONFIG_IPV6_MODULE) && CONFIG_SUNRPC_REGISTER_V4 */
-
 /*
  * These can be set at insmod time (useful for NFS as root filesystem),
  * and also changed through the sysctl interface.  -- Jamie Lokier, Aug 2003
@@ -115,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
  */
@@ -160,10 +159,7 @@ lockd(void *vrqstp)
 
                if (signalled()) {
                        flush_signals(current);
-                       if (nlmsvc_ops) {
-                               nlmsvc_invalidate_all();
-                               set_grace_period();
-                       }
+                       restart_grace();
                        continue;
                }
 
@@ -204,19 +200,30 @@ lockd(void *vrqstp)
        return 0;
 }
 
-static int create_lockd_listener(struct svc_serv *serv, char *name,
-                                unsigned short port)
+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, 0, 0);
+       xprt = svc_find_xprt(serv, name, family, 0);
        if (xprt == NULL)
-               return svc_create_xprt(serv, name, port, SVC_SOCK_DEFAULTS);
-
+               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.
  *
@@ -232,13 +239,15 @@ static int make_socks(struct svc_serv *serv)
        static int warned;
        int err;
 
-       err = create_lockd_listener(serv, "udp", nlm_udpport);
+       err = create_lockd_family(serv, PF_INET);
        if (err < 0)
                goto out_err;
 
-       err = create_lockd_listener(serv, "tcp", nlm_tcpport);
-       if (err < 0)
+#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;
@@ -274,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, nlmsvc_family, NULL);
+       serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, NULL);
        if (!serv) {
                printk(KERN_WARNING "lockd_up: create service failed\n");
                goto out;