Commit 6d768177c282637a7943e72b4b2b148e7553ecf1

Authored by David Teigland
1 parent 05c32f47bf

dlm: use wait_event_timeout

Use wait_event_timeout to avoid using a timer
directly.

Signed-off-by: David Teigland <teigland@redhat.com>

Showing 1 changed file with 11 additions and 18 deletions Side-by-side Diff

... ... @@ -36,30 +36,23 @@
36 36 * (LS_RECOVERY_STOP set due to failure of a node in ls_nodes). When another
37 37 * function thinks it could have completed the waited-on task, they should wake
38 38 * up ls_wait_general to get an immediate response rather than waiting for the
39   - * timer to detect the result. A timer wakes us up periodically while waiting
40   - * to see if we should abort due to a node failure. This should only be called
41   - * by the dlm_recoverd thread.
  39 + * timeout. This uses a timeout so it can check periodically if the wait
  40 + * should abort due to node failure (which doesn't cause a wake_up).
  41 + * This should only be called by the dlm_recoverd thread.
42 42 */
43 43  
44   -static void dlm_wait_timer_fn(unsigned long data)
45   -{
46   - struct dlm_ls *ls = (struct dlm_ls *) data;
47   - mod_timer(&ls->ls_timer, jiffies + (dlm_config.ci_recover_timer * HZ));
48   - wake_up(&ls->ls_wait_general);
49   -}
50   -
51 44 int dlm_wait_function(struct dlm_ls *ls, int (*testfn) (struct dlm_ls *ls))
52 45 {
53 46 int error = 0;
  47 + int rv;
54 48  
55   - init_timer(&ls->ls_timer);
56   - ls->ls_timer.function = dlm_wait_timer_fn;
57   - ls->ls_timer.data = (long) ls;
58   - ls->ls_timer.expires = jiffies + (dlm_config.ci_recover_timer * HZ);
59   - add_timer(&ls->ls_timer);
60   -
61   - wait_event(ls->ls_wait_general, testfn(ls) || dlm_recovery_stopped(ls));
62   - del_timer_sync(&ls->ls_timer);
  49 + while (1) {
  50 + rv = wait_event_timeout(ls->ls_wait_general,
  51 + testfn(ls) || dlm_recovery_stopped(ls),
  52 + dlm_config.ci_recover_timer * HZ);
  53 + if (rv)
  54 + break;
  55 + }
63 56  
64 57 if (dlm_recovery_stopped(ls)) {
65 58 log_debug(ls, "dlm_wait_function aborted");