cfs_list_splice_tail||list_splice_tail
cfs_list_t||struct list_head
struct timeval||struct timespec64
+get_seconds||ktime_get_real_seconds
cfs_time_current_sec||ktime_get_real_seconds
cfs_time_current_64||ktime_get
cfs_time_add_64||ktime_add
+cfs_time_after|time_after
+cfs_time_aftereq|time_after_eq
+cfs_time_before|time_before
+cfs_time_beforeeq|time_before_eq
cfs_time_before_64||ktime_before
cfs_time_beforeq_64||ktime_compare
+cfs_time_current|jiffies
CFS_PAGE_MASK||PAGE_MASK
CFS_PAGE_SIZE||PAGE_SIZE
PAGE_CACHE_MASK||PAGE_MASK
libcfs_prim.h \
libcfs_private.h \
libcfs_string.h \
- libcfs_time.h \
libcfs_workitem.h \
libcfs_ptask.h
#ifndef __LIBCFS_LIBCFS_H__
#define __LIBCFS_LIBCFS_H__
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include <libcfs/linux/linux-misc.h>
+#include <libcfs/linux/linux-time.h>
+
#include <uapi/linux/lnet/libcfs_ioctl.h>
#include <libcfs/libcfs_debug.h>
#include <libcfs/libcfs_private.h>
#include <libcfs/bitmap.h>
#include <libcfs/libcfs_cpu.h>
#include <libcfs/libcfs_prim.h>
-#include <libcfs/libcfs_time.h>
#include <libcfs/libcfs_string.h>
#include <libcfs/libcfs_workitem.h>
#include <libcfs/libcfs_hash.h>
+++ /dev/null
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/libcfs_time.h
- *
- * Time functions.
- *
- */
-
-#ifndef __LIBCFS_TIME_H__
-#define __LIBCFS_TIME_H__
-
-#include <libcfs/linux/linux-time.h>
-
-/*
- * generic time manipulation functions.
- */
-
-static inline cfs_time_t cfs_time_add(cfs_time_t t, cfs_duration_t d)
-{
- return (cfs_time_t)(t + d);
-}
-
-static inline cfs_duration_t cfs_time_sub(cfs_time_t t1, cfs_time_t t2)
-{
- return (cfs_time_t)(t1 - t2);
-}
-
-static inline int cfs_time_after(cfs_time_t t1, cfs_time_t t2)
-{
- return cfs_time_before(t2, t1);
-}
-
-static inline int cfs_time_aftereq(cfs_time_t t1, cfs_time_t t2)
-{
- return cfs_time_beforeq(t2, t1);
-}
-
-static inline cfs_time_t cfs_time_shift(int seconds)
-{
- return cfs_time_add(cfs_time_current(), cfs_time_seconds(seconds));
-}
-
-#define CFS_TICK 1
-
-#endif
#define __LIBCFS_LINUX_LINUX_TIME_H__
/* Portable time API */
-
-/*
- * Platform provides three opaque data-types:
- *
- * cfs_time_t represents point in time. This is internal kernel
- * time rather than "wall clock". This time bears no
- * relation to gettimeofday().
- *
- * cfs_duration_t represents time interval with resolution of internal
- * platform clock
- *
- * cfs_time_t cfs_time_current(void);
- * cfs_time_t cfs_time_add (cfs_time_t, cfs_duration_t);
- * cfs_duration_t cfs_time_sub (cfs_time_t, cfs_time_t);
- *
- * time_t cfs_duration_sec (cfs_duration_t);
- */
-
#include <linux/hrtimer.h>
#include <linux/module.h>
#include <linux/kernel.h>
/*
* Generic kernel stuff
*/
-
-typedef unsigned long cfs_time_t; /* jiffies */
-typedef long cfs_duration_t;
-
#ifndef HAVE_TIMESPEC64
typedef __s64 time64_t;
}
#endif
-static inline int cfs_time_before(cfs_time_t t1, cfs_time_t t2)
-{
- return time_before(t1, t2);
-}
-
-static inline int cfs_time_beforeq(cfs_time_t t1, cfs_time_t t2)
-{
- return time_before_eq(t1, t2);
-}
-
-static inline cfs_time_t cfs_time_current(void)
-{
- return jiffies;
-}
-
-static inline time_t cfs_time_current_sec(void)
-{
- return get_seconds();
-}
-
-static inline cfs_duration_t cfs_time_seconds(int seconds)
-{
- return ((cfs_duration_t)seconds) * msecs_to_jiffies(MSEC_PER_SEC);
-}
-
-static inline time_t cfs_duration_sec(cfs_duration_t d)
+static inline unsigned long cfs_time_seconds(time64_t seconds)
{
- return d / msecs_to_jiffies(MSEC_PER_SEC);
+ return nsecs_to_jiffies(seconds * NSEC_PER_SEC);
}
#endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */
#include <linux/ctype.h>
#include <linux/kthread.h>
-#include <libcfs/linux/linux-misc.h>
#include <libcfs/libcfs.h>
#include "tracefile.h"
{
unsigned int d = *(unsigned int *)kp->arg;
- return sprintf(buffer, "%u", (unsigned int)cfs_duration_sec(d * 100));
+ return sprintf(buffer, "%lu", jiffies_to_msecs(d * 10) / MSEC_PER_SEC);
}
unsigned int libcfs_console_max_delay;
#include <linux/sched/mm.h>
#endif
#include <linux/uaccess.h>
-#include <libcfs/libcfs.h>
#if defined(CONFIG_KGDB)
#include <asm/kgdb.h>
#endif
+#include <libcfs/linux/linux-time.h>
+
#ifndef HAVE_KTIME_GET_TS64
void ktime_get_ts64(struct timespec64 *ts)
{
#include <libcfs/libcfs.h>
#include <libcfs/libcfs_crypto.h>
-#include <libcfs/linux/linux-misc.h>
#include <lnet/lib-lnet.h>
#include "tracefile.h"
#include <linux/pagemap.h>
#include <linux/uaccess.h>
#include <libcfs/linux/linux-fs.h>
-#include <libcfs/linux/linux-misc.h>
#include <libcfs/libcfs.h>
/* XXX move things up to the top, comment */
return 1;
}
- if (cdls != NULL) {
- if (libcfs_console_ratelimit &&
- cdls->cdls_next != 0 && /* not first time ever */
- !cfs_time_after(cfs_time_current(), cdls->cdls_next)) {
- /* skipping a console message */
- cdls->cdls_count++;
- if (tcd != NULL)
- cfs_trace_put_tcd(tcd);
- return 1;
- }
+ if (cdls != NULL) {
+ if (libcfs_console_ratelimit &&
+ cdls->cdls_next != 0 && /* not first time ever */
+ time_after(jiffies, cdls->cdls_next)) {
+ /* skipping a console message */
+ cdls->cdls_count++;
+ if (tcd != NULL)
+ cfs_trace_put_tcd(tcd);
+ return 1;
+ }
- if (cfs_time_after(cfs_time_current(), cdls->cdls_next +
- libcfs_console_max_delay
- + cfs_time_seconds(10))) {
- /* last timeout was a long time ago */
- cdls->cdls_delay /= libcfs_console_backoff * 4;
- } else {
- cdls->cdls_delay *= libcfs_console_backoff;
- }
+ if (time_after(jiffies, cdls->cdls_next +
+ libcfs_console_max_delay +
+ cfs_time_seconds(10))) {
+ /* last timeout was a long time ago */
+ cdls->cdls_delay /= libcfs_console_backoff * 4;
+ } else {
+ cdls->cdls_delay *= libcfs_console_backoff;
+ }
if (cdls->cdls_delay < libcfs_console_min_delay)
cdls->cdls_delay = libcfs_console_min_delay;
else if (cdls->cdls_delay > libcfs_console_max_delay)
cdls->cdls_delay = libcfs_console_max_delay;
- /* ensure cdls_next is never zero after it's been seen */
- cdls->cdls_next = (cfs_time_current() + cdls->cdls_delay) | 1;
- }
+ /* ensure cdls_next is never zero after it's been seen */
+ cdls->cdls_next = (jiffies + cdls->cdls_delay) | 1;
+ }
if (tcd != NULL) {
cfs_print_to_console(&header, mask, string_buf, needed, file,
# error This include is only for kernel use.
#endif
-#include <libcfs/linux/linux-misc.h>
#include <libcfs/libcfs.h>
#include <lnet/api.h>
#include <lnet/lib-types.h>
#include <gni_pub.h>
#include "gnilnd_version.h"
+static inline time_t cfs_duration_sec(long duration_jiffies)
+{
+ return jiffies_to_msecs(duration_jiffies) / MSEC_PER_SEC;
+}
+
#ifdef CONFIG_SLAB
#define GNILND_MBOX_SIZE KMALLOC_MAX_SIZE
#else
#define DEBUG_SUBSYSTEM S_LND
-#include <libcfs/libcfs_time.h>
+#include <libcfs/libcfs.h>
#include <lnet/lib-lnet.h>
#define IBLND_PEER_HASH_SIZE 101 /* # peer_ni lists */
#include <linux/uaccess.h>
-#include <libcfs/linux/linux-misc.h>
#include <libcfs/libcfs.h>
#include <lnet/lib-lnet.h>
#include <linux/spinlock.h>
#include <linux/seq_file.h>
-#include <libcfs/libcfs_time.h>
-#include <libcfs/linux/linux-misc.h>
+#include <libcfs/libcfs.h>
#include <uapi/linux/lustre/lustre_idl.h>
struct lprocfs_vars {
* There are not used outside of ldlm.
* @{
*/
-int ldlm_pools_recalc(enum ldlm_side client);
+time64_t ldlm_pools_recalc(enum ldlm_side client);
int ldlm_pools_init(void);
void ldlm_pools_fini(void);
int ldlm_pool_shrink(struct ldlm_pool *pl, int nr, gfp_t gfp_mask);
void ldlm_pool_fini(struct ldlm_pool *pl);
int ldlm_pool_setup(struct ldlm_pool *pl, int limit);
-int ldlm_pool_recalc(struct ldlm_pool *pl);
+time64_t ldlm_pool_recalc(struct ldlm_pool *pl);
__u32 ldlm_pool_get_lvf(struct ldlm_pool *pl);
__u64 ldlm_pool_get_slv(struct ldlm_pool *pl);
__u64 ldlm_pool_get_clv(struct ldlm_pool *pl);
#include <linux/sched/mm.h>
#endif
-#include <libcfs/linux/linux-misc.h>
#include <libcfs/libcfs.h>
#include <uapi/linux/lustre/lustre_idl.h>
#include <uapi/linux/lustre/lustre_ver.h>
#define LWI_ON_SIGNAL_NOOP ((void (*)(void *))(-1))
struct l_wait_info {
- cfs_duration_t lwi_timeout;
- cfs_duration_t lwi_interval;
- int lwi_allow_intr;
+ long lwi_timeout;
+ long lwi_interval;
+ int lwi_allow_intr;
int (*lwi_on_timeout)(void *);
void (*lwi_on_signal)(void *);
void *lwi_cb_data;
#define __l_wait_event(wq, condition, info, ret, l_add_wait) \
do { \
wait_queue_entry_t __wait; \
- cfs_duration_t __timeout = info->lwi_timeout; \
- sigset_t __blocked; \
+ long __timeout = info->lwi_timeout; \
+ sigset_t __blocked; \
int __allow_intr = info->lwi_allow_intr; \
\
ret = 0; \
if (__timeout == 0) { \
schedule(); \
} else { \
- cfs_duration_t interval = info->lwi_interval? \
- min_t(cfs_duration_t, \
- info->lwi_interval,__timeout):\
- __timeout; \
- cfs_duration_t remaining = schedule_timeout(interval); \
- __timeout = cfs_time_sub(__timeout, \
- cfs_time_sub(interval, remaining));\
+ long interval = info->lwi_interval ? \
+ min_t(long, info->lwi_interval,\
+ __timeout) : __timeout; \
+ long remaining = schedule_timeout(interval); \
+ \
+ __timeout -= interval - remaining; \
if (__timeout == 0) { \
if (info->lwi_on_timeout == NULL || \
info->lwi_on_timeout(info->lwi_cb_data)) { \
struct list_head scp_rqbd_posted;
/** incoming reqs */
struct list_head scp_req_incoming;
- /** timeout before re-posting reqs, in tick */
- cfs_duration_t scp_rqbd_timeout;
+ /** timeout before re-posting reqs, in jiffies */
+ long scp_rqbd_timeout;
/**
* all threads sleep on this. This wait-queue is signalled when new
* incoming request arrives and when difficult reply has to be handled.
/** early reply timer */
struct timer_list scp_at_timer;
/** debug */
- cfs_time_t scp_at_checktime;
+ ktime_t scp_at_checktime;
/** check early replies */
unsigned scp_at_check;
/** @} */
#define DEBUG_SUBSYSTEM S_LDLM
+#include <linux/jiffies.h>
#include <linux/kthread.h>
#include <libcfs/libcfs.h>
#include <obd.h>
}
now = ktime_get_seconds();
- deadline = cfs_duration_sec(target->obd_recovery_timer.expires);
+ deadline = jiffies_to_msecs(target->obd_recovery_timer.expires) /
+ MSEC_PER_SEC;
if (now < deadline) {
struct target_distribute_txn_data *tdtd;
int size = 0;
i = atomic_read(&target->obd_lock_replay_clients);
k = target->obd_max_recoverable_clients;
s = target->obd_stale_clients;
- t = target->obd_recovery_timer.expires;
- t = cfs_duration_sec(target->obd_recovery_timer.expires);
+ t = jiffies_to_msecs(target->obd_recovery_timer.expires);
+ t /= MSEC_PER_SEC;
t -= ktime_get_seconds();
LCONSOLE_WARN("%s: Denying connection for new client %s"
"(at %s), waiting for %d known clients "
spin_unlock_bh(&export->exp_bl_list_lock);
LDLM_ERROR(lock,
- "lock callback timer expired after "
- "%llds: evicting client at %s ",
- cfs_time_current_sec() -
+ "lock callback timer expired after %llds: evicting client at %s ",
+ ktime_get_real_seconds() -
lock->l_last_activity,
obd_export_nid2str(export));
ldlm_lock_to_ns(lock)->ns_timeouts++;
* Pool recalc wrapper. Will call either client or server pool recalc callback
* depending what pool \a pl is used.
*/
-int ldlm_pool_recalc(struct ldlm_pool *pl)
+time64_t ldlm_pool_recalc(struct ldlm_pool *pl)
{
time64_t recalc_interval_sec;
int count;
#endif /* HAVE_SHRINKER_COUNT */
-int ldlm_pools_recalc(enum ldlm_side client)
+time64_t ldlm_pools_recalc(enum ldlm_side client)
{
unsigned long nr_l = 0, nr_p = 0, l;
struct ldlm_namespace *ns;
struct ldlm_namespace *ns_old = NULL;
int nr, equal = 0;
/* seconds of sleep if no active namespaces */
- int time = client ? LDLM_POOL_CLI_DEF_RECALC_PERIOD :
- LDLM_POOL_SRV_DEF_RECALC_PERIOD;
+ time64_t time = client ? LDLM_POOL_CLI_DEF_RECALC_PERIOD :
+ LDLM_POOL_SRV_DEF_RECALC_PERIOD;
/*
* No need to setup pool limit for client pools.
* After setup is done - recalc the pool.
*/
if (!skip) {
- int ttime = ldlm_pool_recalc(&ns->ns_pool);
+ time64_t ttime = ldlm_pool_recalc(&ns->ns_pool);
if (ttime < time)
time = ttime;
static int ldlm_pools_thread_main(void *arg)
{
struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg;
- int s_time, c_time;
- ENTRY;
+ time64_t s_time, c_time;
+ ENTRY;
thread_set_flags(thread, SVC_RUNNING);
wake_up(&thread->t_ctl_waitq);
return 0;
}
-int ldlm_pool_recalc(struct ldlm_pool *pl)
+time64_t ldlm_pool_recalc(struct ldlm_pool *pl)
{
return 0;
}
return;
}
-int ldlm_pools_recalc(enum ldlm_side client)
+time64_t ldlm_pools_recalc(enum ldlm_side client)
{
return 0;
}
__u64 lqo_penalty; /* current penalty */
__u64 lqo_penalty_per_obj; /* penalty decrease
every obj*/
- time_t lqo_used; /* last used time, seconds */
+ time64_t lqo_used; /* last used time, seconds */
__u32 lqo_ost_count; /* number of osts on this oss */
};
__u64 ltq_penalty_per_obj; /* penalty decrease
every obj*/
__u64 ltq_weight; /* net weighting */
- time_t ltq_used; /* last used time, seconds */
+ time64_t ltq_used; /* last used time, seconds */
bool ltq_usable:1; /* usable for striping */
};
__u32 num_active;
unsigned int i;
int rc, prio_wide;
- time_t now, age;
+ time64_t now, age;
ENTRY;
if (!lod->lod_qos.lq_dirty)
ba_min = (__u64)(-1);
ba_max = 0;
- now = cfs_time_current_sec();
+ now = ktime_get_real_seconds();
/* Calculate OST penalty per object
- * (lod ref taken in lod_qos_prep_create()) */
+ * (lod ref taken in lod_qos_prep_create())
+ */
cfs_foreach_bit(lod->lod_ost_bitmap, i) {
LASSERT(OST_TGT(lod,i));
temp = TGT_BAVAIL(i);
oss->lqo_penalty >>= 1;
/* mark the OSS and OST as recently used */
- ost->ltd_qos.ltq_used = oss->lqo_used = cfs_time_current_sec();
+ ost->ltd_qos.ltq_used = oss->lqo_used = ktime_get_real_seconds();
/* Set max penalties for this OST and OSS */
ost->ltd_qos.ltq_penalty +=
#endif
#include <linux/utsname.h>
-#include <libcfs/linux/linux-misc.h>
+#include <libcfs/libcfs.h>
#include <obd_support.h>
#include <obd_class.h>
#include <lustre_net.h>
reclen = lname->ln_namelen + sizeof(struct link_ea_entry);
if (unlikely(leh->leh_len + reclen > MAX_LINKEA_SIZE)) {
/* Use 32-bits to save the overflow time, although it will
- * shrink the cfs_time_current_sec() returned 64-bits value
+ * shrink the ktime_get_real_seconds() returned 64-bits value
* to 32-bits value, it is still quite large and can be used
- * for about 140 years. That is enough. */
- leh->leh_overflow_time = cfs_time_current_sec();
+ * for about 140 years. That is enough.
+ */
+ leh->leh_overflow_time = ktime_get_real_seconds();
if (unlikely(leh->leh_overflow_time == 0))
leh->leh_overflow_time++;
if (unlikely(leh->leh_reccount == 0))
return 0;
- leh->leh_overflow_time = cfs_time_current_sec();
+ leh->leh_overflow_time = ktime_get_real_seconds();
if (unlikely(leh->leh_overflow_time == 0))
leh->leh_overflow_time++;
ldata->ld_reclen = 0;
*/
#define DEBUG_SUBSYSTEM S_SEC
-#include <libcfs/linux/linux-misc.h>
#include <libcfs/libcfs.h>
#include <uapi/linux/lnet/lnet-types.h>
#include <upcall_cache.h>
return dl - now;
}
-static unsigned int ptlrpc_inflight_timeout(struct obd_import *imp)
+static time64_t ptlrpc_inflight_timeout(struct obd_import *imp)
{
time64_t now = ktime_get_real_seconds();
struct list_head *tmp, *n;
svcpt = (struct ptlrpc_service_part *)castmeharder;
svcpt->scp_at_check = 1;
- svcpt->scp_at_checktime = cfs_time_current();
+ svcpt->scp_at_checktime = ktime_get();
wake_up(&svcpt->scp_waitq);
}
static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt)
{
struct ptlrpc_at_array *array = &svcpt->scp_at_array;
- __s32 next;
+ time64_t next;
if (array->paa_count == 0) {
del_timer(&svcpt->scp_at_timer);
}
/* Set timer for closest deadline */
- next = (__s32)(array->paa_deadline - ktime_get_real_seconds() -
- at_early_margin);
+ next = array->paa_deadline - ktime_get_real_seconds() -
+ at_early_margin;
if (next <= 0) {
ptlrpc_at_timer((unsigned long)svcpt);
} else {
- mod_timer(&svcpt->scp_at_timer, cfs_time_shift(next));
- CDEBUG(D_INFO, "armed %s at %+ds\n",
+ mod_timer(&svcpt->scp_at_timer,
+ jiffies + nsecs_to_jiffies(next * NSEC_PER_SEC));
+ CDEBUG(D_INFO, "armed %s at %+llds\n",
svcpt->scp_service->srv_name, next);
}
}
__u32 index, count;
time64_t deadline;
time64_t now = ktime_get_real_seconds();
- cfs_duration_t delay;
- int first, counter = 0;
- ENTRY;
+ s64 delay;
+ int first, counter = 0;
+ ENTRY;
spin_lock(&svcpt->scp_at_lock);
if (svcpt->scp_at_check == 0) {
spin_unlock(&svcpt->scp_at_lock);
RETURN(0);
}
- delay = cfs_time_sub(cfs_time_current(), svcpt->scp_at_checktime);
+ delay = ktime_ms_delta(ktime_get(), svcpt->scp_at_checktime);
svcpt->scp_at_check = 0;
if (array->paa_count == 0) {
LCONSOLE_WARN("%s: This server is not able to keep up with "
"request traffic (cpu-bound).\n",
svcpt->scp_service->srv_name);
- CWARN("earlyQ=%d reqQ=%d recA=%d, svcEst=%d, delay=%ld(jiff)\n",
+ CWARN("earlyQ=%d reqQ=%d recA=%d, svcEst=%d, delay=%lld\n",
counter, svcpt->scp_nreqs_incoming,
svcpt->scp_nreqs_active,
at_get(&svcpt->scp_at_estimate), delay);