Whamcloud - gitweb
LU-6245 libcfs: remove wrappers for timer functions 33/23733/4
authorJames Simmons <uja.ornl@yahoo.com>
Tue, 10 Jan 2017 23:21:33 +0000 (18:21 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 24 Jan 2017 05:21:12 +0000 (05:21 +0000)
Use the linux timer_list api directly instead of going
throught a abstraction layer in libcfs.

Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Change-Id: Ida47b2746e68b7428cbc30b40fbdc8810b7d05f7
Reviewed-on: https://review.whamcloud.com/23733
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/include/libcfs/libcfs_prim.h
libcfs/include/libcfs/linux/linux-time.h
libcfs/libcfs/linux/linux-prim.c
libcfs/libcfs/watchdog.c
lustre/ldlm/ldlm_lib.c
lustre/ldlm/ldlm_lockd.c
lustre/obdclass/obd_config.c
lustre/osp/osp_precreate.c
lustre/ptlrpc/service.c

index e919e43..c592398 100644 (file)
 #include <linux/sched.h>
 
 /*
- * Timer
- */
-typedef  void (cfs_timer_func_t)(uintptr_t);
-
-void cfs_init_timer(struct timer_list *t);
-void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg);
-void cfs_timer_arm(struct timer_list *t, cfs_time_t deadline);
-void cfs_timer_disarm(struct timer_list *t);
-int  cfs_timer_is_armed(struct timer_list *t);
-cfs_time_t cfs_timer_deadline(struct timer_list *t);
-
-/*
  * Memory
  */
 #if BITS_PER_LONG == 32
index 706b79c..e65d2f7 100644 (file)
@@ -97,7 +97,6 @@
 
 typedef unsigned long cfs_time_t;      /* jiffies */
 typedef long cfs_duration_t;
-typedef cycles_t cfs_cycles_t;
 
 #ifndef HAVE_TIMESPEC64
 
index 4d10dcb..1d07692 100644 (file)
 #include <asm/kgdb.h>
 #endif
 
-void cfs_init_timer(struct timer_list *t)
-{
-       init_timer(t);
-}
-EXPORT_SYMBOL(cfs_init_timer);
-
-void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg)
-{
-       init_timer(t);
-       t->function = func;
-       t->data = (unsigned long)arg;
-}
-EXPORT_SYMBOL(cfs_timer_init);
-
-void cfs_timer_arm(struct timer_list *t, cfs_time_t deadline)
-{
-       mod_timer(t, deadline);
-}
-EXPORT_SYMBOL(cfs_timer_arm);
-
-void cfs_timer_disarm(struct timer_list *t)
-{
-       del_timer(t);
-}
-EXPORT_SYMBOL(cfs_timer_disarm);
-
-int  cfs_timer_is_armed(struct timer_list *t)
-{
-       return timer_pending(t);
-}
-EXPORT_SYMBOL(cfs_timer_is_armed);
-
-cfs_time_t cfs_timer_deadline(struct timer_list *t)
-{
-       return t->expires;
-}
-EXPORT_SYMBOL(cfs_timer_deadline);
-
 #ifndef HAVE_KTIME_GET_TS64
 void ktime_get_ts64(struct timespec64 *ts)
 {
index 04e4da7..05c984a 100644 (file)
@@ -364,19 +364,19 @@ struct lc_watchdog *lc_watchdog_add(int timeout,
        lcw->lcw_state    = LC_WATCHDOG_DISABLED;
 
        INIT_LIST_HEAD(&lcw->lcw_list);
-       cfs_timer_init(&lcw->lcw_timer, lcw_cb, lcw);
+       setup_timer(&lcw->lcw_timer, lcw_cb, (unsigned long)lcw);
 
        mutex_lock(&lcw_refcount_mutex);
        if (++lcw_refcount == 1)
                lcw_dispatch_start();
        mutex_unlock(&lcw_refcount_mutex);
 
-        /* Keep this working in case we enable them by default */
-        if (lcw->lcw_state == LC_WATCHDOG_ENABLED) {
-                lcw->lcw_last_touched = cfs_time_current();
-                cfs_timer_arm(&lcw->lcw_timer, cfs_time_seconds(timeout) +
-                              cfs_time_current());
-        }
+       /* Keep this working in case we enable them by default */
+       if (lcw->lcw_state == LC_WATCHDOG_ENABLED) {
+               lcw->lcw_last_touched = cfs_time_current();
+               mod_timer(&lcw->lcw_timer, cfs_time_seconds(timeout) +
+                         cfs_time_current());
+       }
 
         RETURN(lcw);
 }
@@ -426,8 +426,8 @@ void lc_watchdog_touch(struct lc_watchdog *lcw, int timeout)
 
         lcw_update_time(lcw, "resumed");
 
-        cfs_timer_arm(&lcw->lcw_timer, cfs_time_current() +
-                      cfs_time_seconds(timeout));
+       mod_timer(&lcw->lcw_timer, cfs_time_current() +
+                 cfs_time_seconds(timeout));
        lcw->lcw_state = LC_WATCHDOG_ENABLED;
 
         EXIT;
@@ -455,7 +455,7 @@ void lc_watchdog_delete(struct lc_watchdog *lcw)
         ENTRY;
         LASSERT(lcw != NULL);
 
-        cfs_timer_disarm(&lcw->lcw_timer);
+       del_timer(&lcw->lcw_timer);
 
         lcw_update_time(lcw, "stopped");
 
index 1f67bfc..c102edc 100644 (file)
@@ -785,7 +785,7 @@ static int target_handle_reconnect(struct lustre_handle *conn,
        }
 
        now = cfs_time_current();
-       deadline = cfs_timer_deadline(&target->obd_recovery_timer);
+       deadline = target->obd_recovery_timer.expires;
        if (cfs_time_before(now, deadline)) {
                struct target_distribute_txn_data *tdtd =
                                        class_exp2tgt(exp)->lut_tdtd;
@@ -1276,7 +1276,7 @@ no_export:
                        i = atomic_read(&target->obd_lock_replay_clients);
                        k = target->obd_max_recoverable_clients;
                        s = target->obd_stale_clients;
-                       t = cfs_timer_deadline(&target->obd_recovery_timer);
+                       t = target->obd_recovery_timer.expires;
                        t = cfs_time_sub(t, cfs_time_current());
                        t = cfs_duration_sec(t);
                        LCONSOLE_WARN("%s: Denying connection for new client %s"
@@ -1713,7 +1713,7 @@ EXPORT_SYMBOL(target_cleanup_recovery);
 void target_cancel_recovery_timer(struct obd_device *obd)
 {
         CDEBUG(D_HA, "%s: cancel recovery timer\n", obd->obd_name);
-        cfs_timer_disarm(&obd->obd_recovery_timer);
+       del_timer(&obd->obd_recovery_timer);
 }
 
 static void target_start_recovery_timer(struct obd_device *obd)
@@ -1734,8 +1734,8 @@ static void target_start_recovery_timer(struct obd_device *obd)
                return;
        }
 
-       cfs_timer_arm(&obd->obd_recovery_timer,
-                     cfs_time_shift(obd->obd_recovery_timeout));
+       mod_timer(&obd->obd_recovery_timer,
+                 cfs_time_shift(obd->obd_recovery_timeout));
        obd->obd_recovery_start = cfs_time_current_sec();
        spin_unlock(&obd->obd_dev_lock);
 
@@ -1790,8 +1790,8 @@ static void extend_recovery_timer(struct obd_device *obd, int drt, bool extend)
        if (obd->obd_recovery_timeout < to) {
                 obd->obd_recovery_timeout = to;
                end = obd->obd_recovery_start + to;
-               cfs_timer_arm(&obd->obd_recovery_timer,
-                               cfs_time_shift(end - now));
+               mod_timer(&obd->obd_recovery_timer,
+                         cfs_time_shift(end - now));
         }
        spin_unlock(&obd->obd_dev_lock);
 
@@ -2656,8 +2656,9 @@ void target_recovery_init(struct lu_target *lut, svc_handler_t handler)
         obd->obd_recovery_start = 0;
         obd->obd_recovery_end = 0;
 
-        cfs_timer_init(&obd->obd_recovery_timer, target_recovery_expired, obd);
-        target_start_recovery_thread(lut, handler);
+       setup_timer(&obd->obd_recovery_timer, target_recovery_expired,
+                   (unsigned long)obd);
+       target_start_recovery_thread(lut, handler);
 }
 EXPORT_SYMBOL(target_recovery_init);
 
index 94fb81f..92e206c 100644 (file)
@@ -358,7 +358,7 @@ static void waiting_locks_callback(unsigned long unused)
                lock = list_entry(waiting_locks_list.next, struct ldlm_lock,
                                       l_pending_chain);
                 timeout_rounded = (cfs_time_t)round_timeout(lock->l_callback_timeout);
-                cfs_timer_arm(&waiting_locks_timer, timeout_rounded);
+               mod_timer(&waiting_locks_timer, timeout_rounded);
         }
        spin_unlock_bh(&waiting_locks_spinlock);
 }
@@ -393,10 +393,9 @@ static int __ldlm_add_waiting_lock(struct ldlm_lock *lock, int seconds)
 
         timeout_rounded = round_timeout(lock->l_callback_timeout);
 
-        if (cfs_time_before(timeout_rounded,
-                            cfs_timer_deadline(&waiting_locks_timer)) ||
-            !cfs_timer_is_armed(&waiting_locks_timer)) {
-                cfs_timer_arm(&waiting_locks_timer, timeout_rounded);
+       if (cfs_time_before(timeout_rounded, waiting_locks_timer.expires) ||
+           !timer_pending(&waiting_locks_timer)) {
+               mod_timer(&waiting_locks_timer, timeout_rounded);
         }
         /* if the new lock has a shorter timeout than something earlier on
            the list, we'll wait the longer amount of time; no big deal. */
@@ -500,13 +499,13 @@ static int __ldlm_del_waiting_lock(struct ldlm_lock *lock)
                 /* Removing the head of the list, adjust timer. */
                 if (list_next == &waiting_locks_list) {
                         /* No more, just cancel. */
-                        cfs_timer_disarm(&waiting_locks_timer);
+                       del_timer(&waiting_locks_timer);
                 } else {
                         struct ldlm_lock *next;
                        next = list_entry(list_next, struct ldlm_lock,
                                               l_pending_chain);
-                        cfs_timer_arm(&waiting_locks_timer,
-                                      round_timeout(next->l_callback_timeout));
+                       mod_timer(&waiting_locks_timer,
+                                 round_timeout(next->l_callback_timeout));
                 }
         }
        list_del_init(&lock->l_pending_chain);
@@ -3043,7 +3042,7 @@ static int ldlm_setup(void)
 
        INIT_LIST_HEAD(&waiting_locks_list);
        spin_lock_init(&waiting_locks_spinlock);
-       cfs_timer_init(&waiting_locks_timer, waiting_locks_callback, NULL);
+       setup_timer(&waiting_locks_timer, waiting_locks_callback, 0);
 
        task = kthread_run(expired_lock_main, NULL, "ldlm_elt");
        if (IS_ERR(task)) {
index dc89df2..3d43727 100644 (file)
@@ -394,7 +394,7 @@ int class_attach(struct lustre_cfg *lcfg)
        /* XXX belongs in setup not attach  */
        init_rwsem(&obd->obd_observer_link_sem);
        /* recovery data */
-       cfs_init_timer(&obd->obd_recovery_timer);
+       init_timer(&obd->obd_recovery_timer);
        spin_lock_init(&obd->obd_recovery_task_lock);
        init_waitqueue_head(&obd->obd_next_transno_waitq);
        init_waitqueue_head(&obd->obd_evict_inprogress_waitq);
index be02e5a..8570fa6 100644 (file)
@@ -141,7 +141,7 @@ static int osp_statfs_interpret(const struct lu_env *env,
 
        /* schedule next update */
        d->opd_statfs_fresh_till = cfs_time_shift(d->opd_statfs_maxage);
-       cfs_timer_arm(&d->opd_statfs_timer, d->opd_statfs_fresh_till);
+       mod_timer(&d->opd_statfs_timer, d->opd_statfs_fresh_till);
        d->opd_statfs_update_in_progress = 0;
 
        CDEBUG(D_CACHE, "updated statfs %p\n", d);
@@ -202,7 +202,7 @@ static int osp_statfs_update(struct osp_device *d)
        /*
         * no updates till reply
         */
-       cfs_timer_disarm(&d->opd_statfs_timer);
+       del_timer(&d->opd_statfs_timer);
        d->opd_statfs_fresh_till = cfs_time_shift(obd_timeout * 1000);
        d->opd_statfs_update_in_progress = 1;
 
@@ -233,7 +233,7 @@ void osp_statfs_need_now(struct osp_device *d)
                 * is replied
                 */
                d->opd_statfs_fresh_till = cfs_time_shift(-1);
-               cfs_timer_disarm(&d->opd_statfs_timer);
+               del_timer(&d->opd_statfs_timer);
                wake_up(&d->opd_pre_waitq);
        }
 }
@@ -1667,7 +1667,8 @@ int osp_init_precreate(struct osp_device *d)
        CDEBUG(D_OTHER, "current %llu, fresh till %llu\n",
               (unsigned long long)cfs_time_current(),
               (unsigned long long)d->opd_statfs_fresh_till);
-       cfs_timer_init(&d->opd_statfs_timer, osp_statfs_timer_cb, d);
+       setup_timer(&d->opd_statfs_timer, osp_statfs_timer_cb,
+                   (unsigned long)d);
 
        /*
         * start thread handling precreation and statfs updates
@@ -1701,7 +1702,7 @@ void osp_precreate_fini(struct osp_device *d)
 
        ENTRY;
 
-       cfs_timer_disarm(&d->opd_statfs_timer);
+       del_timer(&d->opd_statfs_timer);
 
        if (d->opd_pre == NULL)
                RETURN_EXIT;
index 9259c1e..e42c307 100644 (file)
@@ -646,7 +646,9 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc,
        if (array->paa_reqs_count == NULL)
                goto failed;
 
-       cfs_timer_init(&svcpt->scp_at_timer, ptlrpc_at_timer, svcpt);
+       setup_timer(&svcpt->scp_at_timer, ptlrpc_at_timer,
+                   (unsigned long)svcpt);
+
        /* At SOW, service time should be quick; 10s seems generous. If client
         * timeout is less than this, we'll be sending an early reply. */
        at_init(&svcpt->scp_at_estimate, 10, 0);
@@ -1158,7 +1160,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt)
        __s32 next;
 
        if (array->paa_count == 0) {
-               cfs_timer_disarm(&svcpt->scp_at_timer);
+               del_timer(&svcpt->scp_at_timer);
                return;
        }
 
@@ -1168,7 +1170,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt)
        if (next <= 0) {
                ptlrpc_at_timer((unsigned long)svcpt);
        } else {
-               cfs_timer_arm(&svcpt->scp_at_timer, cfs_time_shift(next));
+               mod_timer(&svcpt->scp_at_timer, cfs_time_shift(next));
                CDEBUG(D_INFO, "armed %s at %+ds\n",
                       svcpt->scp_service->srv_name, next);
        }
@@ -2995,7 +2997,7 @@ ptlrpc_service_del_atimer(struct ptlrpc_service *svc)
        /* early disarm AT timer... */
        ptlrpc_service_for_each_part(svcpt, i, svc) {
                if (svcpt->scp_service != NULL)
-                       cfs_timer_disarm(&svcpt->scp_at_timer);
+                       del_timer(&svcpt->scp_at_timer);
        }
 }
 
@@ -3136,7 +3138,7 @@ ptlrpc_service_free(struct ptlrpc_service *svc)
                        break;
 
                /* In case somebody rearmed this in the meantime */
-               cfs_timer_disarm(&svcpt->scp_at_timer);
+               del_timer(&svcpt->scp_at_timer);
                array = &svcpt->scp_at_array;
 
                if (array->paa_reqs_array != NULL) {