Whamcloud - gitweb
LU-1630 scrub: adjust expected OI scrub speed for test
[fs/lustre-release.git] / libcfs / libcfs / watchdog.c
index 274c59b..6ce41c3 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -83,10 +81,10 @@ static unsigned long lcw_flags = 0;
 /*
  * Number of outstanding watchdogs.
  * When it hits 1, we start the dispatcher.
- * When it hits 0, we stop the distpatcher.
+ * When it hits 0, we stop the dispatcher.
  */
 static __u32         lcw_refcount = 0;
-static CFS_DECLARE_MUTEX(lcw_refcount_sem);
+static CFS_DEFINE_MUTEX(lcw_refcount_mutex);
 
 /*
  * List of timers that have fired that need their callbacks run by the
@@ -107,11 +105,8 @@ lcw_dump(struct lc_watchdog *lcw)
         ENTRY;
 #if defined(HAVE_TASKLIST_LOCK)
         cfs_read_lock(&tasklist_lock);
-#elif defined(HAVE_TASK_RCU)
-        rcu_read_lock();
 #else
-        CERROR("unable to dump stack because of missing export\n");
-        RETURN_EXIT;
+        rcu_read_lock();
 #endif
        if (lcw->lcw_task == NULL) {
                 LCONSOLE_WARN("Process " LPPID " was not found in the task "
@@ -123,7 +118,7 @@ lcw_dump(struct lc_watchdog *lcw)
 
 #if defined(HAVE_TASKLIST_LOCK)
         cfs_read_unlock(&tasklist_lock);
-#elif defined(HAVE_TASK_RCU)
+#else
         rcu_read_unlock();
 #endif
         EXIT;
@@ -326,7 +321,7 @@ static void lcw_dispatch_start(void)
         cfs_waitq_init(&lcw_event_waitq);
 
         CDEBUG(D_INFO, "starting dispatch thread\n");
-        rc = cfs_kernel_thread(lcw_dispatch_main, NULL, 0);
+        rc = cfs_create_thread(lcw_dispatch_main, NULL, 0);
         if (rc < 0) {
                 CERROR("error spawning watchdog dispatch thread: %d\n", rc);
                 EXIT;
@@ -368,7 +363,7 @@ struct lc_watchdog *lc_watchdog_add(int timeout,
                 RETURN(ERR_PTR(-ENOMEM));
         }
 
-        spin_lock_init(&lcw->lcw_lock);
+        cfs_spin_lock_init(&lcw->lcw_lock);
         lcw->lcw_refcount = 1; /* refcount for owner */
         lcw->lcw_task     = cfs_current();
         lcw->lcw_pid      = cfs_curproc_pid();
@@ -379,10 +374,10 @@ struct lc_watchdog *lc_watchdog_add(int timeout,
         CFS_INIT_LIST_HEAD(&lcw->lcw_list);
         cfs_timer_init(&lcw->lcw_timer, lcw_cb, lcw);
 
-        cfs_down(&lcw_refcount_sem);
+        cfs_mutex_lock(&lcw_refcount_mutex);
         if (++lcw_refcount == 1)
                 lcw_dispatch_start();
-        cfs_up(&lcw_refcount_sem);
+        cfs_mutex_unlock(&lcw_refcount_mutex);
 
         /* Keep this working in case we enable them by default */
         if (lcw->lcw_state == LC_WATCHDOG_ENABLED) {
@@ -487,10 +482,10 @@ void lc_watchdog_delete(struct lc_watchdog *lcw)
         if (dead)
                 LIBCFS_FREE(lcw, sizeof(*lcw));
 
-        cfs_down(&lcw_refcount_sem);
+        cfs_mutex_lock(&lcw_refcount_mutex);
         if (--lcw_refcount == 0)
                 lcw_dispatch_stop();
-        cfs_up(&lcw_refcount_sem);
+        cfs_mutex_unlock(&lcw_refcount_mutex);
 
         EXIT;
 }