ipv6: Remove some pointless conditionals before kfree_skb()
[linux/fpc-iii.git] / fs / gfs2 / locking / dlm / thread.c
blob38823efd698c809513f87c6585c91084a9517a43
1 /*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
8 */
10 #include "lock_dlm.h"
12 static inline int no_work(struct gdlm_ls *ls)
14 int ret;
16 spin_lock(&ls->async_lock);
17 ret = list_empty(&ls->submit);
18 spin_unlock(&ls->async_lock);
20 return ret;
23 static int gdlm_thread(void *data)
25 struct gdlm_ls *ls = (struct gdlm_ls *) data;
26 struct gdlm_lock *lp = NULL;
28 while (!kthread_should_stop()) {
29 wait_event_interruptible(ls->thread_wait,
30 !no_work(ls) || kthread_should_stop());
32 spin_lock(&ls->async_lock);
34 if (!list_empty(&ls->submit)) {
35 lp = list_entry(ls->submit.next, struct gdlm_lock,
36 delay_list);
37 list_del_init(&lp->delay_list);
38 spin_unlock(&ls->async_lock);
39 gdlm_do_lock(lp);
40 spin_lock(&ls->async_lock);
42 spin_unlock(&ls->async_lock);
45 return 0;
48 int gdlm_init_threads(struct gdlm_ls *ls)
50 struct task_struct *p;
51 int error;
53 p = kthread_run(gdlm_thread, ls, "lock_dlm");
54 error = IS_ERR(p);
55 if (error) {
56 log_error("can't start lock_dlm thread %d", error);
57 return error;
59 ls->thread = p;
61 return 0;
64 void gdlm_release_threads(struct gdlm_ls *ls)
66 kthread_stop(ls->thread);