From 5801dad47e4727a44b6343a3f7f875d7992f29a3 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Tue, 10 Jan 2017 18:21:33 -0500 Subject: [PATCH] LU-6245 libcfs: remove wrappers for timer functions Use the linux timer_list api directly instead of going throught a abstraction layer in libcfs. Signed-off-by: James Simmons Change-Id: Ida47b2746e68b7428cbc30b40fbdc8810b7d05f7 Reviewed-on: https://review.whamcloud.com/23733 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/libcfs_prim.h | 12 ---------- libcfs/include/libcfs/linux/linux-time.h | 1 - libcfs/libcfs/linux/linux-prim.c | 38 -------------------------------- libcfs/libcfs/watchdog.c | 20 ++++++++--------- lustre/ldlm/ldlm_lib.c | 19 ++++++++-------- lustre/ldlm/ldlm_lockd.c | 17 +++++++------- lustre/obdclass/obd_config.c | 2 +- lustre/osp/osp_precreate.c | 11 ++++----- lustre/ptlrpc/service.c | 12 +++++----- 9 files changed, 42 insertions(+), 90 deletions(-) diff --git a/libcfs/include/libcfs/libcfs_prim.h b/libcfs/include/libcfs/libcfs_prim.h index e919e43..c592398 100644 --- a/libcfs/include/libcfs/libcfs_prim.h +++ b/libcfs/include/libcfs/libcfs_prim.h @@ -39,18 +39,6 @@ #include /* - * 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 diff --git a/libcfs/include/libcfs/linux/linux-time.h b/libcfs/include/libcfs/linux/linux-time.h index 706b79c..e65d2f7 100644 --- a/libcfs/include/libcfs/linux/linux-time.h +++ b/libcfs/include/libcfs/linux/linux-time.h @@ -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 diff --git a/libcfs/libcfs/linux/linux-prim.c b/libcfs/libcfs/linux/linux-prim.c index 4d10dcb..1d07692 100644 --- a/libcfs/libcfs/linux/linux-prim.c +++ b/libcfs/libcfs/linux/linux-prim.c @@ -42,44 +42,6 @@ #include #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) { diff --git a/libcfs/libcfs/watchdog.c b/libcfs/libcfs/watchdog.c index 04e4da7..05c984a 100644 --- a/libcfs/libcfs/watchdog.c +++ b/libcfs/libcfs/watchdog.c @@ -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"); diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 1f67bfc..c102edc 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -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); diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 94fb81f..92e206c 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -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)) { diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index dc89df2..3d43727 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -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); diff --git a/lustre/osp/osp_precreate.c b/lustre/osp/osp_precreate.c index be02e5a..8570fa6 100644 --- a/lustre/osp/osp_precreate.c +++ b/lustre/osp/osp_precreate.c @@ -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; diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index 9259c1e..e42c307 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -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) { -- 1.8.3.1