Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[pandora-kernel.git] / fs / gfs2 / locking / dlm / thread.c
index 1aca51e..521694f 100644 (file)
@@ -268,27 +268,18 @@ static inline int check_drop(struct gdlm_ls *ls)
        return 0;
 }
 
-static int gdlm_thread(void *data)
+static int gdlm_thread(void *data, int blist)
 {
        struct gdlm_ls *ls = (struct gdlm_ls *) data;
        struct gdlm_lock *lp = NULL;
-       int blist = 0;
        uint8_t complete, blocking, submit, drop;
-       DECLARE_WAITQUEUE(wait, current);
 
        /* Only thread1 is allowed to do blocking callbacks since gfs
           may wait for a completion callback within a blocking cb. */
 
-       if (current == ls->thread1)
-               blist = 1;
-
        while (!kthread_should_stop()) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               add_wait_queue(&ls->thread_wait, &wait);
-               if (no_work(ls, blist))
-                       schedule();
-               remove_wait_queue(&ls->thread_wait, &wait);
-               set_current_state(TASK_RUNNING);
+               wait_event_interruptible(ls->thread_wait,
+                               !no_work(ls, blist) || kthread_should_stop());
 
                complete = blocking = submit = drop = 0;
 
@@ -333,12 +324,22 @@ static int gdlm_thread(void *data)
        return 0;
 }
 
+static int gdlm_thread1(void *data)
+{
+       return gdlm_thread(data, 1);
+}
+
+static int gdlm_thread2(void *data)
+{
+       return gdlm_thread(data, 0);
+}
+
 int gdlm_init_threads(struct gdlm_ls *ls)
 {
        struct task_struct *p;
        int error;
 
-       p = kthread_run(gdlm_thread, ls, "lock_dlm1");
+       p = kthread_run(gdlm_thread1, ls, "lock_dlm1");
        error = IS_ERR(p);
        if (error) {
                log_error("can't start lock_dlm1 thread %d", error);
@@ -346,7 +347,7 @@ int gdlm_init_threads(struct gdlm_ls *ls)
        }
        ls->thread1 = p;
 
-       p = kthread_run(gdlm_thread, ls, "lock_dlm2");
+       p = kthread_run(gdlm_thread2, ls, "lock_dlm2");
        error = IS_ERR(p);
        if (error) {
                log_error("can't start lock_dlm2 thread %d", error);