Whamcloud - gitweb
LU-10805 libcfs: timer_setup() API changes
[fs/lustre-release.git] / libcfs / libcfs / watchdog.c
index 401210c..4c437ab 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 #include <libcfs/libcfs.h>
 #include "tracefile.h"
 
+#ifndef WITH_WATCHDOG
+#define WITH_WATCHDOG
+#endif
+
 struct lc_watchdog {
        spinlock_t              lcw_lock;       /* check or change lcw_list */
        int                     lcw_refcount;   /* must hold lcw_pending_timers_lock */
@@ -114,9 +118,9 @@ lcw_dump(struct lc_watchdog *lcw)
         EXIT;
 }
 
-static void lcw_cb(uintptr_t data)
+static void lcw_cb(cfs_timer_cb_arg_t data)
 {
-        struct lc_watchdog *lcw = (struct lc_watchdog *)data;
+       struct lc_watchdog *lcw = cfs_from_timer(lcw, data, lcw_timer);
         ENTRY;
 
         if (lcw->lcw_state != LC_WATCHDOG_ENABLED) {
@@ -160,6 +164,11 @@ static void lcw_dump_stack(struct lc_watchdog *lcw)
 
        timediff = ktime_to_timespec64(ktime_sub(ktime_get(),
                                       lcw->lcw_last_touched));
+
+       /* LU-9235: Don't dump stack if the thread is just touched. */
+       if (timediff.tv_sec == 0)
+               return;
+
        /*
         * Check to see if we should throttle the watchdog timer to avoid
         * too many dumps going to the console thus triggering an NMI.
@@ -326,6 +335,7 @@ static void lcw_dispatch_stop(void)
        wake_up(&lcw_event_waitq);
 
        wait_for_completion(&lcw_stop_completion);
+       clear_bit(LCW_FLAG_STOP, &lcw_flags);
 
        CDEBUG(D_INFO, "watchdog dispatcher has shut down.\n");
 
@@ -354,7 +364,7 @@ struct lc_watchdog *lc_watchdog_add(int timeout,
        lcw->lcw_state    = LC_WATCHDOG_DISABLED;
 
        INIT_LIST_HEAD(&lcw->lcw_list);
-       setup_timer(&lcw->lcw_timer, lcw_cb, (unsigned long)lcw);
+       cfs_timer_setup(&lcw->lcw_timer, lcw_cb, (unsigned long)lcw, 0);
 
        mutex_lock(&lcw_refcount_mutex);
        if (++lcw_refcount == 1)