Whamcloud - gitweb
LU-1154 clio: rename coo_attr_set to coo_attr_update
[fs/lustre-release.git] / lnet / selftest / timer.c
index aaab0b0..84ce098 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;
-       cfs_list_t              stt_hash[STTIMER_NSLOTS];
+       struct list_head        stt_hash[STTIMER_NSLOTS];
        int                     stt_shuttingdown;
 #ifdef __KERNEL__
        wait_queue_head_t       stt_waitq;
@@ -72,26 +72,26 @@ struct st_timer_data {
 void
 stt_add_timer(stt_timer_t *timer)
 {
-       cfs_list_t *pos;
+       struct list_head *pos;
 
        spin_lock(&stt_data.stt_lock);
 
 #ifdef __KERNEL__
-        LASSERT (stt_data.stt_nthreads > 0);
+       LASSERT(stt_data.stt_nthreads > 0);
 #endif
-        LASSERT (!stt_data.stt_shuttingdown);
-        LASSERT (timer->stt_func != NULL);
-        LASSERT (cfs_list_empty(&timer->stt_list));
-        LASSERT (cfs_time_after(timer->stt_expires, cfs_time_current_sec()));
+       LASSERT(!stt_data.stt_shuttingdown);
+       LASSERT(timer->stt_func != NULL);
+       LASSERT(list_empty(&timer->stt_list));
+       LASSERT(cfs_time_after(timer->stt_expires, cfs_time_current_sec()));
 
-        /* a simple insertion sort */
-        cfs_list_for_each_prev (pos, STTIMER_SLOT(timer->stt_expires)) {
-                stt_timer_t *old = cfs_list_entry(pos, stt_timer_t, stt_list);
+       /* a simple insertion sort */
+       list_for_each_prev(pos, STTIMER_SLOT(timer->stt_expires)) {
+               stt_timer_t *old = list_entry(pos, stt_timer_t, stt_list);
 
-                if (cfs_time_aftereq(timer->stt_expires, old->stt_expires))
-                        break;
-        }
-        cfs_list_add(&timer->stt_list, pos);
+               if (cfs_time_aftereq(timer->stt_expires, old->stt_expires))
+                       break;
+       }
+       list_add(&timer->stt_list, pos);
 
        spin_unlock(&stt_data.stt_lock);
 }
@@ -106,40 +106,40 @@ stt_add_timer(stt_timer_t *timer)
  * another CPU.
  */
 int
-stt_del_timer (stt_timer_t *timer)
+stt_del_timer(stt_timer_t *timer)
 {
        int ret = 0;
 
        spin_lock(&stt_data.stt_lock);
 
 #ifdef __KERNEL__
-        LASSERT (stt_data.stt_nthreads > 0);
+       LASSERT(stt_data.stt_nthreads > 0);
 #endif
-        LASSERT (!stt_data.stt_shuttingdown);
+       LASSERT(!stt_data.stt_shuttingdown);
 
-        if (!cfs_list_empty(&timer->stt_list)) {
-                ret = 1;
-                cfs_list_del_init(&timer->stt_list);
-        }
+       if (!list_empty(&timer->stt_list)) {
+               ret = 1;
+               list_del_init(&timer->stt_list);
+       }
 
        spin_unlock(&stt_data.stt_lock);
        return ret;
 }
 
 /* called with stt_data.stt_lock held */
-int
-stt_expire_list (cfs_list_t *slot, cfs_time_t now)
+static int
+stt_expire_list(struct list_head *slot, cfs_time_t now)
 {
-        int          expired = 0;
-        stt_timer_t *timer;
+       int          expired = 0;
+       stt_timer_t *timer;
 
-        while (!cfs_list_empty(slot)) {
-                timer = cfs_list_entry(slot->next, stt_timer_t, stt_list);
+       while (!list_empty(slot)) {
+               timer = list_entry(slot->next, stt_timer_t, stt_list);
 
-                if (cfs_time_after(timer->stt_expires, now))
-                        break;
+               if (cfs_time_after(timer->stt_expires, now))
+                       break;
 
-                cfs_list_del_init(&timer->stt_list);
+               list_del_init(&timer->stt_list);
                spin_unlock(&stt_data.stt_lock);
 
                expired++;
@@ -151,7 +151,7 @@ stt_expire_list (cfs_list_t *slot, cfs_time_t now)
        return expired;
 }
 
-int
+static int
 stt_check_timers (cfs_time_t *last)
 {
         int        expired = 0;
@@ -175,7 +175,7 @@ stt_check_timers (cfs_time_t *last)
 
 #ifdef __KERNEL__
 
-int
+static int
 stt_timer_main (void *arg)
 {
         int rc = 0;
@@ -196,10 +196,10 @@ stt_timer_main (void *arg)
        return rc;
 }
 
-int
+static int
 stt_start_timer_thread (void)
 {
-       cfs_task_t *task;
+       struct task_struct *task;
 
        LASSERT(!stt_data.stt_shuttingdown);
 
@@ -240,7 +240,7 @@ stt_startup (void)
 
        spin_lock_init(&stt_data.stt_lock);
         for (i = 0; i < STTIMER_NSLOTS; i++)
-                CFS_INIT_LIST_HEAD(&stt_data.stt_hash[i]);
+               INIT_LIST_HEAD(&stt_data.stt_hash[i]);
 
 #ifdef __KERNEL__
        stt_data.stt_nthreads = 0;
@@ -254,16 +254,16 @@ stt_startup (void)
 }
 
 void
-stt_shutdown (void)
+stt_shutdown(void)
 {
-        int i;
+       int i;
 
        spin_lock(&stt_data.stt_lock);
 
-        for (i = 0; i < STTIMER_NSLOTS; i++)
-                LASSERT (cfs_list_empty(&stt_data.stt_hash[i]));
+       for (i = 0; i < STTIMER_NSLOTS; i++)
+               LASSERT(list_empty(&stt_data.stt_hash[i]));
 
-        stt_data.stt_shuttingdown = 1;
+       stt_data.stt_shuttingdown = 1;
 
 #ifdef __KERNEL__
        wake_up(&stt_data.stt_waitq);