X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=libcfs%2Flibcfs%2Fwatchdog.c;h=a39479420fe66e0730ff1cd570aadff268a8efe3;hb=a0a847fee6e30542bffb4e6860499b68cf515998;hp=cc6ae59e0c38c5b11e618ea4bd65c8b300722b57;hpb=bf9fab67b7a6cb475209e2c8e3a79a1b4601a26e;p=fs%2Flustre-release.git diff --git a/libcfs/libcfs/watchdog.c b/libcfs/libcfs/watchdog.c index cc6ae59..a394794 100644 --- a/libcfs/libcfs/watchdog.c +++ b/libcfs/libcfs/watchdog.c @@ -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. @@ -86,16 +84,15 @@ static unsigned long lcw_flags = 0; * 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 * dispatcher. */ /* BH lock! */ -static cfs_spinlock_t lcw_pending_timers_lock = CFS_SPIN_LOCK_UNLOCKED; -static cfs_list_t lcw_pending_timers = \ - CFS_LIST_HEAD_INIT(lcw_pending_timers); +static DEFINE_SPINLOCK(lcw_pending_timers_lock); +static cfs_list_t lcw_pending_timers = CFS_LIST_HEAD_INIT(lcw_pending_timers); /* Last time a watchdog expired */ static cfs_time_t lcw_last_watchdog_time; @@ -107,11 +104,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 +117,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 +320,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; @@ -379,10 +373,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 +481,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; }