#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
typedef unsigned long cfs_time_t; /* jiffies */
typedef long cfs_duration_t;
-typedef cycles_t cfs_cycles_t;
#ifndef HAVE_TIMESPEC64
#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)
{
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);
}
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;
ENTRY;
LASSERT(lcw != NULL);
- cfs_timer_disarm(&lcw->lcw_timer);
+ del_timer(&lcw->lcw_timer);
lcw_update_time(lcw, "stopped");
}
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;
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"
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)
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);
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);
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);
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);
}
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. */
/* 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);
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)) {
/* 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);
/* 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);
/*
* 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;
* 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);
}
}
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
ENTRY;
- cfs_timer_disarm(&d->opd_statfs_timer);
+ del_timer(&d->opd_statfs_timer);
if (d->opd_pre == NULL)
RETURN_EXIT;
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);
__s32 next;
if (array->paa_count == 0) {
- cfs_timer_disarm(&svcpt->scp_at_timer);
+ del_timer(&svcpt->scp_at_timer);
return;
}
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);
}
/* 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);
}
}
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) {