Whamcloud - gitweb
LU-8116 build: Fix libmount configure message
[fs/lustre-release.git] / lnet / selftest / timer.c
index d2835e9..de20840 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -44,9 +44,9 @@
 
 
 /*
- * Timers are implemented as a sorted queue of expiry times. The queue 
- * is slotted, with each slot holding timers which expire in a 
- * 2**STTIMER_MINPOLL (8) second period. The timers in each slot are 
+ * Timers are implemented as a sorted queue of expiry times. The queue
+ * is slotted, with each slot holding timers which expire in a
+ * 2**STTIMER_MINPOLL (8) second period. The timers in each slot are
  * sorted by increasing expiry time. The number of slots is 2**7 (128),
  * to cover a time period of 1024 seconds into the future before wrapping.
  */
 #define STTIMER_SLOT(t)               (&stt_data.stt_hash[(((t) >> STTIMER_MINPOLL) & \
                                                     (STTIMER_NSLOTS - 1))])
 
-struct st_timer_data {
+static struct st_timer_data {
        spinlock_t              stt_lock;
        /* start time of the slot processed previously */
        cfs_time_t              stt_prev_slot;
        struct list_head        stt_hash[STTIMER_NSLOTS];
        int                     stt_shuttingdown;
-#ifdef __KERNEL__
        wait_queue_head_t       stt_waitq;
        int                     stt_nthreads;
-#endif
 } stt_data;
 
 void
@@ -76,9 +74,7 @@ stt_add_timer(stt_timer_t *timer)
 
        spin_lock(&stt_data.stt_lock);
 
-#ifdef __KERNEL__
        LASSERT(stt_data.stt_nthreads > 0);
-#endif
        LASSERT(!stt_data.stt_shuttingdown);
        LASSERT(timer->stt_func != NULL);
        LASSERT(list_empty(&timer->stt_list));
@@ -112,9 +108,7 @@ stt_del_timer(stt_timer_t *timer)
 
        spin_lock(&stt_data.stt_lock);
 
-#ifdef __KERNEL__
        LASSERT(stt_data.stt_nthreads > 0);
-#endif
        LASSERT(!stt_data.stt_shuttingdown);
 
        if (!list_empty(&timer->stt_list)) {
@@ -127,7 +121,7 @@ stt_del_timer(stt_timer_t *timer)
 }
 
 /* called with stt_data.stt_lock held */
-int
+static int
 stt_expire_list(struct list_head *slot, cfs_time_t now)
 {
        int          expired = 0;
@@ -151,7 +145,7 @@ stt_expire_list(struct list_head *slot, cfs_time_t now)
        return expired;
 }
 
-int
+static int
 stt_check_timers (cfs_time_t *last)
 {
         int        expired = 0;
@@ -173,9 +167,8 @@ stt_check_timers (cfs_time_t *last)
        return expired;
 }
 
-#ifdef __KERNEL__
 
-int
+static int
 stt_timer_main (void *arg)
 {
         int rc = 0;
@@ -196,7 +189,7 @@ stt_timer_main (void *arg)
        return rc;
 }
 
-int
+static int
 stt_start_timer_thread (void)
 {
        struct task_struct *task;
@@ -213,21 +206,6 @@ stt_start_timer_thread (void)
        return 0;
 }
 
-#else /* !__KERNEL__ */
-
-int
-stt_check_events (void)
-{
-        return stt_check_timers(&stt_data.stt_prev_slot);
-}
-
-int
-stt_poll_interval (void)
-{
-        return STTIMER_SLOTTIME;
-}
-
-#endif
 
 int
 stt_startup (void)
@@ -242,13 +220,11 @@ stt_startup (void)
         for (i = 0; i < STTIMER_NSLOTS; i++)
                INIT_LIST_HEAD(&stt_data.stt_hash[i]);
 
-#ifdef __KERNEL__
        stt_data.stt_nthreads = 0;
        init_waitqueue_head(&stt_data.stt_waitq);
        rc = stt_start_timer_thread();
        if (rc != 0)
                CERROR ("Can't spawn timer thread: %d\n", rc);
-#endif
 
         return rc;
 }
@@ -265,12 +241,10 @@ stt_shutdown(void)
 
        stt_data.stt_shuttingdown = 1;
 
-#ifdef __KERNEL__
        wake_up(&stt_data.stt_waitq);
        lst_wait_until(stt_data.stt_nthreads == 0, stt_data.stt_lock,
                       "waiting for %d threads to terminate\n",
                       stt_data.stt_nthreads);
-#endif
 
        spin_unlock(&stt_data.stt_lock);
 }