Freezer: make kernel threads nonfreezable by default
[safe/jmp/linux-2.6] / fs / lockd / svc.c
index 6341392..9fcdef5 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
 #include <linux/mutex.h>
+#include <linux/freezer.h>
 
 #include <linux/sunrpc/types.h>
 #include <linux/sunrpc/stats.h>
@@ -119,13 +120,11 @@ lockd(struct svc_rqst *rqstp)
        complete(&lockd_start_done);
 
        daemonize("lockd");
+       set_freezable();
 
        /* Process request with signals blocked, but allow SIGKILL.  */
        allow_signal(SIGKILL);
 
-       /* kick rpciod */
-       rpciod_up();
-
        dprintk("NFS locking service started (ver " LOCKD_VERSION ").\n");
 
        if (!nlm_timeout)
@@ -141,6 +140,7 @@ lockd(struct svc_rqst *rqstp)
         */
        while ((nlmsvc_users || !signalled()) && nlmsvc_pid == current->pid) {
                long timeout = MAX_SCHEDULE_TIMEOUT;
+               char buf[RPC_MAX_ADDRBUFLEN];
 
                if (signalled()) {
                        flush_signals(current);
@@ -175,11 +175,10 @@ lockd(struct svc_rqst *rqstp)
                        break;
                }
 
-               dprintk("lockd: request from %08x\n",
-                       (unsigned)ntohl(rqstp->rq_addr.sin_addr.s_addr));
+               dprintk("lockd: request from %s\n",
+                               svc_print_addr(rqstp, buf, sizeof(buf)));
 
                svc_process(rqstp);
-
        }
 
        flush_signals(current);
@@ -202,9 +201,6 @@ lockd(struct svc_rqst *rqstp)
        /* Exit the RPC thread */
        svc_exit_thread(rqstp);
 
-       /* release rpciod */
-       rpciod_down();
-
        /* Release module */
        unlock_kernel();
        module_put_and_exit(0);
@@ -223,23 +219,29 @@ static int find_socket(struct svc_serv *serv, int proto)
        return found;
 }
 
+/*
+ * Make any sockets that are needed but not present.
+ * If nlm_udpport or nlm_tcpport were set as module
+ * options, make those sockets unconditionally
+ */
 static int make_socks(struct svc_serv *serv, int proto)
 {
-       /* Make any sockets that are needed but not present.
-        * If nlm_udpport or nlm_tcpport were set as module
-        * options, make those sockets unconditionally
-        */
-       static int              warned;
+       static int warned;
        int err = 0;
+
        if (proto == IPPROTO_UDP || nlm_udpport)
                if (!find_socket(serv, IPPROTO_UDP))
-                       err = svc_makesock(serv, IPPROTO_UDP, nlm_udpport);
-       if (err == 0 && (proto == IPPROTO_TCP || nlm_tcpport))
+                       err = svc_makesock(serv, IPPROTO_UDP, nlm_udpport,
+                                               SVC_SOCK_DEFAULTS);
+       if (err >= 0 && (proto == IPPROTO_TCP || nlm_tcpport))
                if (!find_socket(serv, IPPROTO_TCP))
-                       err= svc_makesock(serv, IPPROTO_TCP, nlm_tcpport);
-       if (!err)
+                       err = svc_makesock(serv, IPPROTO_TCP, nlm_tcpport,
+                                               SVC_SOCK_DEFAULTS);
+
+       if (err >= 0) {
                warned = 0;
-       else if (warned++ == 0)
+               err = 0;
+       } else if (warned++ == 0)
                printk(KERN_WARNING
                       "lockd_up: makesock failed, error=%d\n", err);
        return err;
@@ -353,9 +355,6 @@ EXPORT_SYMBOL(lockd_down);
  * Sysctl parameters (same as module parameters, different interface).
  */
 
-/* Something that isn't CTL_ANY, CTL_NONE or a value that may clash. */
-#define CTL_UNNUMBERED         -2
-
 static ctl_table nlm_sysctls[] = {
        {
                .ctl_name       = CTL_UNNUMBERED,
@@ -437,7 +436,7 @@ static ctl_table nlm_sysctl_root[] = {
 };
 
 /*
- * Module (and driverfs) parameters.
+ * Module (and sysfs) parameters.
  */
 
 #define param_set_min_max(name, type, which_strtol, min, max)          \
@@ -509,7 +508,7 @@ module_param(nsm_use_hostnames, bool, 0644);
 
 static int __init init_nlm(void)
 {
-       nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root, 0);
+       nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root);
        return nlm_sysctl_table ? 0 : -ENOMEM;
 }