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.
12 static inline int no_work(struct gdlm_ls *ls)
16 spin_lock(&ls->async_lock);
17 ret = list_empty(&ls->submit);
18 spin_unlock(&ls->async_lock);
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,
37 list_del_init(&lp->delay_list);
38 spin_unlock(&ls->async_lock);
40 spin_lock(&ls->async_lock);
42 spin_unlock(&ls->async_lock);
48 int gdlm_init_threads(struct gdlm_ls *ls)
50 struct task_struct *p;
53 p = kthread_run(gdlm_thread, ls, "lock_dlm");
56 log_error("can't start lock_dlm thread %d", error);
64 void gdlm_release_threads(struct gdlm_ls *ls)
66 kthread_stop(ls->thread);