Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / fs / lockd / svc.c
index b82e470..fdb9412 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
+#include <linux/mutex.h>
 
 #include <linux/sunrpc/types.h>
 #include <linux/sunrpc/stats.h>
@@ -43,13 +44,13 @@ static struct svc_program   nlmsvc_program;
 struct nlmsvc_binding *                nlmsvc_ops;
 EXPORT_SYMBOL(nlmsvc_ops);
 
-static DECLARE_MUTEX(nlmsvc_sema);
+static DEFINE_MUTEX(nlmsvc_mutex);
 static unsigned int            nlmsvc_users;
 static pid_t                   nlmsvc_pid;
 int                            nlmsvc_grace_period;
 unsigned long                  nlmsvc_timeout;
 
-static DECLARE_MUTEX_LOCKED(lockd_start);
+static DECLARE_COMPLETION(lockd_start_done);
 static DECLARE_WAIT_QUEUE_HEAD(lockd_exit);
 
 /*
@@ -112,7 +113,7 @@ lockd(struct svc_rqst *rqstp)
         * Let our maker know we're running.
         */
        nlmsvc_pid = current->pid;
-       up(&lockd_start);
+       complete(&lockd_start_done);
 
        daemonize("lockd");
 
@@ -178,6 +179,8 @@ lockd(struct svc_rqst *rqstp)
 
        }
 
+       flush_signals(current);
+
        /*
         * Check whether there's a new lockd process before
         * shutting down the hosts and clearing the slot.
@@ -191,7 +194,7 @@ lockd(struct svc_rqst *rqstp)
                printk(KERN_DEBUG
                        "lockd: new process, skipping host shutdown\n");
        wake_up(&lockd_exit);
-               
+
        /* Exit the RPC thread */
        svc_exit_thread(rqstp);
 
@@ -213,7 +216,7 @@ lockd_up(void)
        struct svc_serv *       serv;
        int                     error = 0;
 
-       down(&nlmsvc_sema);
+       mutex_lock(&nlmsvc_mutex);
        /*
         * Unconditionally increment the user count ... this is
         * the number of clients who _want_ a lockd process.
@@ -261,7 +264,7 @@ lockd_up(void)
                        "lockd_up: create thread failed, error=%d\n", error);
                goto destroy_and_out;
        }
-       down(&lockd_start);
+       wait_for_completion(&lockd_start_done);
 
        /*
         * Note: svc_serv structures have an initial use count of 1,
@@ -270,7 +273,7 @@ lockd_up(void)
 destroy_and_out:
        svc_destroy(serv);
 out:
-       up(&nlmsvc_sema);
+       mutex_unlock(&nlmsvc_mutex);
        return error;
 }
 EXPORT_SYMBOL(lockd_up);
@@ -283,7 +286,7 @@ lockd_down(void)
 {
        static int warned;
 
-       down(&nlmsvc_sema);
+       mutex_lock(&nlmsvc_mutex);
        if (nlmsvc_users) {
                if (--nlmsvc_users)
                        goto out;
@@ -303,7 +306,7 @@ lockd_down(void)
         * the lockd semaphore, we can't wait around forever ...
         */
        clear_thread_flag(TIF_SIGPENDING);
-       interruptible_sleep_on_timeout(&lockd_exit, HZ);
+       wait_event_timeout(lockd_exit, nlmsvc_pid == 0, HZ);
        if (nlmsvc_pid) {
                printk(KERN_WARNING 
                        "lockd_down: lockd failed to exit, clearing pid\n");
@@ -313,7 +316,7 @@ lockd_down(void)
        recalc_sigpending();
        spin_unlock_irq(&current->sighand->siglock);
 out:
-       up(&nlmsvc_sema);
+       mutex_unlock(&nlmsvc_mutex);
 }
 EXPORT_SYMBOL(lockd_down);
 
@@ -329,7 +332,7 @@ static ctl_table nlm_sysctls[] = {
                .ctl_name       = CTL_UNNUMBERED,
                .procname       = "nlm_grace_period",
                .data           = &nlm_grace_period,
-               .maxlen         = sizeof(int),
+               .maxlen         = sizeof(unsigned long),
                .mode           = 0644,
                .proc_handler   = &proc_doulongvec_minmax,
                .extra1         = (unsigned long *) &nlm_grace_period_min,
@@ -339,7 +342,7 @@ static ctl_table nlm_sysctls[] = {
                .ctl_name       = CTL_UNNUMBERED,
                .procname       = "nlm_timeout",
                .data           = &nlm_timeout,
-               .maxlen         = sizeof(int),
+               .maxlen         = sizeof(unsigned long),
                .mode           = 0644,
                .proc_handler   = &proc_doulongvec_minmax,
                .extra1         = (unsigned long *) &nlm_timeout_min,
@@ -507,7 +510,7 @@ static struct svc_version * nlmsvc_version[] = {
 
 static struct svc_stat         nlmsvc_stats;
 
-#define NLM_NRVERS     (sizeof(nlmsvc_version)/sizeof(nlmsvc_version[0]))
+#define NLM_NRVERS     ARRAY_SIZE(nlmsvc_version)
 static struct svc_program      nlmsvc_program = {
        .pg_prog                = NLM_PROGRAM,          /* program number */
        .pg_nvers               = NLM_NRVERS,           /* number of entries in nlmsvc_version */