Whamcloud - gitweb
LU-1346 libcfs: cleanup libcfs primitive (linux-prim.h)
[fs/lustre-release.git] / libcfs / libcfs / watchdog.c
index 2c6d67e..93802ac 100644 (file)
 
 struct lc_watchdog {
        spinlock_t  lcw_lock;     /* check or change lcw_list */
-        int             lcw_refcount; /* must hold lcw_pending_timers_lock */
-        cfs_timer_t     lcw_timer;    /* kernel timer */
-        cfs_list_t      lcw_list;     /* chain on pending list */
-        cfs_time_t      lcw_last_touched; /* last touched stamp */
-        cfs_task_t     *lcw_task;     /* owner task */
-        void          (*lcw_callback)(pid_t, void *);
-        void           *lcw_data;
-
-        pid_t           lcw_pid;
-
-        enum {
-                LC_WATCHDOG_DISABLED,
-                LC_WATCHDOG_ENABLED,
-                LC_WATCHDOG_EXPIRED
-        } lcw_state;
+       int             lcw_refcount; /* must hold lcw_pending_timers_lock */
+       struct timer_list     lcw_timer;    /* kernel timer */
+       cfs_list_t      lcw_list;     /* chain on pending list */
+       cfs_time_t      lcw_last_touched; /* last touched stamp */
+       struct task_struct     *lcw_task;     /* owner task */
+       void          (*lcw_callback)(pid_t, void *);
+       void           *lcw_data;
+
+       pid_t           lcw_pid;
+
+       enum {
+               LC_WATCHDOG_DISABLED,
+               LC_WATCHDOG_ENABLED,
+               LC_WATCHDOG_EXPIRED
+       } lcw_state;
 };
 
 #ifdef WITH_WATCHDOG
@@ -70,7 +70,7 @@ struct lc_watchdog {
  */
 static struct completion lcw_start_completion;
 static struct completion  lcw_stop_completion;
-static cfs_waitq_t lcw_event_waitq;
+static wait_queue_head_t lcw_event_waitq;
 
 /*
  * Set this and wake lcw_event_waitq to stop the dispatcher.
@@ -135,7 +135,7 @@ static void lcw_cb(ulong_ptr_t data)
        spin_lock_bh(&lcw_pending_timers_lock);
        lcw->lcw_refcount++; /* +1 for pending list */
        cfs_list_add(&lcw->lcw_list, &lcw_pending_timers);
-       cfs_waitq_signal(&lcw_event_waitq);
+       wake_up(&lcw_event_waitq);
 
        spin_unlock_bh(&lcw_pending_timers_lock);
        spin_unlock_bh(&lcw->lcw_lock);
@@ -296,14 +296,14 @@ static int lcw_dispatch_main(void *data)
 
 static void lcw_dispatch_start(void)
 {
-       cfs_task_t *task;
+       struct task_struct *task;
 
        ENTRY;
        LASSERT(lcw_refcount == 1);
 
        init_completion(&lcw_stop_completion);
        init_completion(&lcw_start_completion);
-        cfs_waitq_init(&lcw_event_waitq);
+       init_waitqueue_head(&lcw_event_waitq);
 
        CDEBUG(D_INFO, "starting dispatch thread\n");
        task = kthread_run(lcw_dispatch_main, NULL, "lc_watchdogd");
@@ -327,7 +327,7 @@ static void lcw_dispatch_stop(void)
        CDEBUG(D_INFO, "trying to stop watchdog dispatcher.\n");
 
        set_bit(LCW_FLAG_STOP, &lcw_flags);
-       cfs_waitq_signal(&lcw_event_waitq);
+       wake_up(&lcw_event_waitq);
 
        wait_for_completion(&lcw_stop_completion);
 
@@ -350,12 +350,12 @@ struct lc_watchdog *lc_watchdog_add(int timeout,
         }
 
        spin_lock_init(&lcw->lcw_lock);
-        lcw->lcw_refcount = 1; /* refcount for owner */
-        lcw->lcw_task     = cfs_current();
-        lcw->lcw_pid      = cfs_curproc_pid();
-        lcw->lcw_callback = (callback != NULL) ? callback : lc_watchdog_dumplog;
-        lcw->lcw_data     = data;
-        lcw->lcw_state    = LC_WATCHDOG_DISABLED;
+       lcw->lcw_refcount = 1; /* refcount for owner */
+       lcw->lcw_task     = current;
+       lcw->lcw_pid      = current_pid();
+       lcw->lcw_callback = (callback != NULL) ? callback : lc_watchdog_dumplog;
+       lcw->lcw_data     = data;
+       lcw->lcw_state    = LC_WATCHDOG_DISABLED;
 
         CFS_INIT_LIST_HEAD(&lcw->lcw_list);
         cfs_timer_init(&lcw->lcw_timer, lcw_cb, lcw);