]) # LIBCFS_ENABLE_CRC32C_ACCEL
#
+# Kernel version 3.11 introduced ktime_get_ts64
+#
+AC_DEFUN([LIBCFS_KTIME_GET_TS64],[
+LB_CHECK_COMPILE([does function 'ktime_get_ts64' exist],
+ktime_get_ts64, [
+ #include <linux/ktime.h>
+],[
+ struct timespec64 *ts = NULL;
+
+ ktime_get_ts64(ts);
+],[
+ AC_DEFINE(HAVE_KTIME_GET_TS64, 1,
+ ['ktime_get_ts64' is available])
+])
+]) # LIBCFS_KTIME_GET_TS64
+
+#
+
+#
# FC19 3.12 kernel struct shrinker change
#
AC_DEFUN([LIBCFS_SHRINKER_COUNT],[
]) # LIBCFS_KTIME_GET_REAL_TS64
#
+# Kernel version 3.17 introduced ktime_get_real_seconds
+#
+AC_DEFUN([LIBCFS_KTIME_GET_REAL_SECONDS],[
+LB_CHECK_COMPILE([does function 'ktime_get_real_seconds' exist],
+ktime_get_real_seconds, [
+ #include <linux/ktime.h>
+],[
+ time64_t now;
+
+ now = ktime_get_real_seconds();
+],[
+ AC_DEFINE(HAVE_KTIME_GET_REAL_SECONDS, 1,
+ ['ktime_get_real_seconds' is available])
+])
+]) # LIBCFS_KTIME_GET_REAL_SECONDS
+
+#
+# Kernel version 3.19 introduced ktime_get_seconds
+#
+AC_DEFUN([LIBCFS_KTIME_GET_SECONDS],[
+LB_CHECK_COMPILE([does function 'ktime_get_seconds' exist],
+ktime_get_seconds, [
+ #include <linux/ktime.h>
+],[
+ time64_t now;
+
+ now = ktime_get_seconds();
+],[
+ AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1,
+ ['ktime_get_seconds' is available])
+])
+]) # LIBCFS_KTIME_GET_SECONDS
+
+#
# Kernel version 4.2 changed topology_thread_cpumask
# to topology_sibling_cpumask
#
LIBCFS_ENABLE_CRC32_ACCEL
# 3.10
LIBCFS_ENABLE_CRC32C_ACCEL
+# 3.11
+LIBCFS_KTIME_GET_TS64
# 3.12
LIBCFS_SHRINKER_COUNT
# 3.17
LIBCFS_HLIST_ADD_AFTER
LIBCFS_TIMESPEC64
LIBCFS_KTIME_GET_REAL_TS64
+LIBCFS_KTIME_GET_REAL_SECONDS
+# 3.19
+LIBCFS_KTIME_GET_SECONDS
# 4.2
LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
LIBCFS_FPU_API
#endif /* HAVE_TIMESPEC64 */
+#ifndef HAVE_KTIME_GET_TS64
+void ktime_get_ts64(struct timespec64 *ts);
+#endif /* HAVE_KTIME_GET_TS */
+
#ifndef HAVE_KTIME_GET_REAL_TS64
void ktime_get_real_ts64(struct timespec64 *ts);
#endif /* HAVE_KTIME_GET_REAL_TS */
+#ifndef HAVE_KTIME_GET_REAL_SECONDS
+time64_t ktime_get_real_seconds(void);
+#endif /* HAVE_KTIME_GET_REAL_SECONDS */
+
+#ifndef HAVE_KTIME_GET_SECONDS
+time64_t ktime_get_seconds(void);
+#endif /* HAVE_KTIME_GET_SECONDS */
+
static inline int cfs_time_before(cfs_time_t t1, cfs_time_t t2)
{
return time_before(t1, t2);
*/
void libcfs_debug_dumplog_internal(void *arg)
{
- static time_t last_dump_time;
- time_t current_time;
+ static time64_t last_dump_time;
+ time64_t current_time;
void *journal_info;
journal_info = current->journal_info;
current->journal_info = NULL;
-
- current_time = cfs_time_current_sec();
+ current_time = ktime_get_real_seconds();
if (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0 &&
current_time > last_dump_time) {
last_dump_time = current_time;
snprintf(debug_file_name, sizeof(debug_file_name) - 1,
- "%s.%ld.%ld", libcfs_debug_file_path_arr,
- current_time, (uintptr_t)arg);
+ "%s.%lld.%ld", libcfs_debug_file_path_arr,
+ (s64)current_time, (uintptr_t)arg);
printk(KERN_ALERT "LustreError: dumping log to %s\n",
debug_file_name);
cfs_tracefile_dump_all_pages(debug_file_name);
}
EXPORT_SYMBOL(cfs_timer_deadline);
+#ifndef HAVE_KTIME_GET_TS64
+void ktime_get_ts64(struct timespec64 *ts)
+{
+ struct timespec now;
+
+ ktime_get_ts(&now);
+ *ts = timespec_to_timespec64(now);
+}
+EXPORT_SYMBOL(ktime_get_ts64);
+#endif /* HAVE_KTIME_GET_TS64 */
+
#ifndef HAVE_KTIME_GET_REAL_TS64
void ktime_get_real_ts64(struct timespec64 *ts)
{
- *ts = timespec_to_timespec64(CURRENT_TIME);
+ struct timespec now;
+
+ getnstimeofday(&now);
+ *ts = timespec_to_timespec64(now);
}
EXPORT_SYMBOL(ktime_get_real_ts64);
#endif /* HAVE_KTIME_GET_REAL_TS64 */
+#ifndef HAVE_KTIME_GET_REAL_SECONDS
+/*
+ * Get the seconds portion of CLOCK_REALTIME (wall clock).
+ * This is the clock that can be altered by NTP and is
+ * independent of a reboot.
+ */
+time64_t ktime_get_real_seconds(void)
+{
+ return (time64_t)get_seconds();
+}
+EXPORT_SYMBOL(ktime_get_real_seconds);
+#endif /* HAVE_KTIME_GET_REAL_SECONDS */
+
+#ifndef HAVE_KTIME_GET_SECONDS
+/*
+ * Get the seconds portion of CLOCK_MONOTONIC
+ * This clock is immutable and is reset across
+ * reboots. For older platforms this is a
+ * wrapper around get_seconds which is valid
+ * until 2038. By that time this will be gone
+ * one would hope.
+ */
+time64_t ktime_get_seconds(void)
+{
+ struct timespec64 now;
+
+ ktime_get_ts64(&now);
+ return now.tv_sec;
+}
+EXPORT_SYMBOL(ktime_get_seconds);
+#endif /* HAVE_KTIME_GET_SECONDS */
+
sigset_t
cfs_block_allsigs(void)
{
lnd_t *ni_lnd; /* procedural interface */
struct lnet_tx_queue **ni_tx_queues; /* percpt TX queues */
int **ni_refs; /* percpt reference count */
- long ni_last_alive; /* when I was last alive */
+ time64_t ni_last_alive; /* when I was last alive */
lnet_ni_status_t *ni_status; /* my health status */
/* per NI LND tunables */
struct lnet_ioctl_config_lnd_tunables *ni_lnd_tunables;
* The second that peers are pulled out from \a kib_reconn_wait
* for reconnection.
*/
- unsigned int kib_reconn_sec;
+ time64_t kib_reconn_sec;
/* connection daemon sleeps here */
wait_queue_head_t kib_connd_waitq;
spinlock_t kib_connd_lock; /* serialise */
}
while (reconn < KIB_RECONN_BREAK) {
- if (kiblnd_data.kib_reconn_sec != get_seconds()) {
- kiblnd_data.kib_reconn_sec = get_seconds();
+ if (kiblnd_data.kib_reconn_sec !=
+ ktime_get_real_seconds()) {
+ kiblnd_data.kib_reconn_sec = ktime_get_real_seconds();
list_splice_init(&kiblnd_data.kib_reconn_wait,
&kiblnd_data.kib_reconn_list);
}
}
conn->ksnc_peer = peer; /* conn takes my ref on peer */
- peer->ksnp_last_alive = cfs_time_current();
+ peer->ksnp_last_alive = ktime_get_real_seconds();
peer->ksnp_send_keepalive = 0;
peer->ksnp_error = 0;
sched->kss_nconns++;
conn->ksnc_scheduler = sched;
- conn->ksnc_tx_last_post = cfs_time_current();
+ conn->ksnc_tx_last_post = ktime_get_real_seconds();
/* Set the deadline for the outgoing HELLO to drain */
conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued;
conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
&conn->ksnc_ipaddr, conn->ksnc_port,
conn->ksnc_rx_nob_wanted, conn->ksnc_rx_nob_left,
- cfs_duration_sec(cfs_time_sub(cfs_time_current(),
+ cfs_duration_sec(cfs_time_sub(ktime_get_real_seconds(),
last_rcv)));
lnet_finalize (conn->ksnc_peer->ksnp_ni,
conn->ksnc_cookie, -EIO);
}
void
-ksocknal_query (lnet_ni_t *ni, lnet_nid_t nid, cfs_time_t *when)
+ksocknal_query(lnet_ni_t *ni, lnet_nid_t nid, cfs_time_t *when)
{
- int connect = 1;
- cfs_time_t last_alive = 0;
- cfs_time_t now = cfs_time_current();
- ksock_peer_t *peer = NULL;
- rwlock_t *glock = &ksocknal_data.ksnd_global_lock;
- lnet_process_id_t id = {
+ int connect = 1;
+ time64_t last_alive = 0;
+ time64_t now = ktime_get_real_seconds();
+ ksock_peer_t *peer = NULL;
+ rwlock_t *glock = &ksocknal_data.ksnd_global_lock;
+ lnet_process_id_t id = {
.nid = nid,
.pid = LNET_PID_LUSTRE,
};
ksocknal_data.ksnd_connd_starting = 0;
ksocknal_data.ksnd_connd_failed_stamp = 0;
- ksocknal_data.ksnd_connd_starting_stamp = cfs_time_current_sec();
+ ksocknal_data.ksnd_connd_starting_stamp = ktime_get_real_seconds();
/* must have at least 2 connds to remain responsive to accepts while
* connecting */
if (*ksocknal_tunables.ksnd_nconnds < SOCKNAL_CONND_RESV + 1)
/* # connds connecting */
int ksnd_connd_connecting;
/** time stamp of the last failed connecting attempt */
- long ksnd_connd_failed_stamp;
+ time64_t ksnd_connd_failed_stamp;
/** # starting connd */
unsigned ksnd_connd_starting;
/** time stamp of the last starting connd */
- long ksnd_connd_starting_stamp;
+ time64_t ksnd_connd_starting_stamp;
/** # running connd */
unsigned ksnd_connd_running;
/* serialise */
* running out of resource.
*/
static int
-ksocknal_connd_check_start(long sec, long *timeout)
+ksocknal_connd_check_start(time64_t sec, long *timeout)
{
char name[16];
int rc;
/* we tried ... */
LASSERT(ksocknal_data.ksnd_connd_starting > 0);
ksocknal_data.ksnd_connd_starting--;
- ksocknal_data.ksnd_connd_failed_stamp = cfs_time_current_sec();
+ ksocknal_data.ksnd_connd_failed_stamp = ktime_get_real_seconds();
return 1;
}
* again to recheck these conditions.
*/
static int
-ksocknal_connd_check_stop(long sec, long *timeout)
+ksocknal_connd_check_stop(time64_t sec, long *timeout)
{
int val;
while (!ksocknal_data.ksnd_shuttingdown) {
ksock_route_t *route = NULL;
- long sec = cfs_time_current_sec();
+ time64_t sec = ktime_get_real_seconds();
long timeout = MAX_SCHEDULE_TIMEOUT;
int dropped_lock = 0;
&peer_info->pr_lnd_u.pr_peer_credits.cr_peer_tx_qnob);
}
- case IOC_LIBCFS_NOTIFY_ROUTER:
+ case IOC_LIBCFS_NOTIFY_ROUTER: {
+ unsigned long jiffies_passed;
+
+ jiffies_passed = ktime_get_real_seconds() - data->ioc_u64[0];
+ jiffies_passed = cfs_time_seconds(jiffies_passed);
+
return lnet_notify(NULL, data->ioc_nid, data->ioc_flags,
- cfs_time_current() -
- cfs_time_seconds(cfs_time_current_sec() -
- (time_t)data->ioc_u64[0]));
+ jiffies - jiffies_passed);
+ }
case IOC_LIBCFS_LNET_DIST:
rc = LNetDist(data->ioc_nid, &data->ioc_nid, &data->ioc_u32[1]);
else
ni->ni_net_ns = NULL;
- ni->ni_last_alive = cfs_time_current_sec();
+ ni->ni_last_alive = ktime_get_real_seconds();
list_add_tail(&ni->ni_list, nilist);
return ni;
failed:
}
if (the_lnet.ln_routing &&
- ni->ni_last_alive != cfs_time_current_sec()) {
+ ni->ni_last_alive != ktime_get_real_seconds()) {
/* NB: so far here is the only place to set NI status to "up */
lnet_ni_lock(ni);
- ni->ni_last_alive = cfs_time_current_sec();
+ ni->ni_last_alive = ktime_get_real_seconds();
if (ni->ni_status != NULL &&
ni->ni_status->ns_status == LNET_NI_STATUS_DOWN)
ni->ni_status->ns_status = LNET_NI_STATUS_UP;
lnet_update_ni_status_locked(void)
{
lnet_ni_t *ni;
- long now;
+ time64_t now;
int timeout;
LASSERT(the_lnet.ln_routing);
timeout = router_ping_timeout +
MAX(live_router_check_interval, dead_router_check_interval);
- now = cfs_time_current_sec();
+ now = ktime_get_real_seconds();
list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) {
if (ni->ni_lnd->lnd_type == LOLND)
continue;
if (ni != NULL) {
struct lnet_tx_queue *tq;
char *stat;
- long now = cfs_time_current_sec();
+ time64_t now = ktime_get_real_seconds();
int last_alive = -1;
int i;
int j;
mutex_lock(&console_session.ses_mutex);
- console_session.ses_laststamp = cfs_time_current_sec();
+ console_session.ses_laststamp = ktime_get_real_seconds();
if (console_session.ses_shutdown) {
rc = -ESHUTDOWN;
return;
}
- if (!console_session.ses_expired &&
- cfs_time_current_sec() - console_session.ses_laststamp >
- (time_t)console_session.ses_timeout)
- console_session.ses_expired = 1;
+ if (!console_session.ses_expired &&
+ ktime_get_real_seconds() - console_session.ses_laststamp >
+ (time64_t)console_session.ses_timeout)
+ console_session.ses_expired = 1;
trans = console_session.ses_ping;
CDEBUG(D_NET, "Ping %d nodes in session\n", count);
- ptimer->stt_expires = (cfs_time_t)(cfs_time_current_sec() + LST_PING_INTERVAL);
- stt_add_timer(ptimer);
+ ptimer->stt_expires = ktime_get_real_seconds() + LST_PING_INTERVAL;
+ stt_add_timer(ptimer);
mutex_unlock(&console_session.ses_mutex);
}
return rc;
}
- ptimer = &console_session.ses_ping_timer;
- ptimer->stt_expires = (cfs_time_t)(cfs_time_current_sec() + LST_PING_INTERVAL);
+ ptimer = &console_session.ses_ping_timer;
+ ptimer->stt_expires = ktime_get_real_seconds() + LST_PING_INTERVAL;
- stt_add_timer(ptimer);
+ stt_add_timer(ptimer);
return 0;
}
console_session.ses_expired = 0;
console_session.ses_feats_updated = 0;
console_session.ses_features = LST_FEATS_MASK;
- console_session.ses_laststamp = cfs_time_current_sec();
+ console_session.ses_laststamp = ktime_get_real_seconds();
mutex_init(&console_session.ses_mutex);
int ses_key; /* local session key */
int ses_state; /* state of session */
int ses_timeout; /* timeout in seconds */
- time_t ses_laststamp; /* last operation stamp (seconds) */
+ time64_t ses_laststamp; /* last operation stamp (seconds) */
/** tests features of the session */
unsigned ses_features;
/** features are synced with remote test nodes */
sn->sn_timer_active = 1;
timer->stt_expires = cfs_time_add(sn->sn_timeout,
- cfs_time_current_sec());
+ ktime_get_real_seconds());
stt_add_timer(timer);
return;
}
}
if (rc != 0) {
- scd->scd_buf_err_stamp = cfs_time_current_sec();
+ scd->scd_buf_err_stamp = ktime_get_real_seconds();
scd->scd_buf_err = rc;
LASSERT(scd->scd_buf_posting > 0);
timer->stt_data = rpc;
timer->stt_func = srpc_client_rpc_expired;
timer->stt_expires = cfs_time_add(rpc->crpc_timeout,
- cfs_time_current_sec());
+ ktime_get_real_seconds());
stt_add_timer(timer);
return;
}
}
if (scd->scd_buf_err_stamp != 0 &&
- scd->scd_buf_err_stamp < cfs_time_current_sec()) {
+ scd->scd_buf_err_stamp < ktime_get_real_seconds()) {
/* re-enable adding buffer */
scd->scd_buf_err_stamp = 0;
scd->scd_buf_err = 0;
/* 1 second pause to avoid timestamp reuse */
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(cfs_time_seconds(1));
- srpc_data.rpc_matchbits = ((__u64) cfs_time_current_sec()) << 48;
+ srpc_data.rpc_matchbits = ((__u64) ktime_get_real_seconds()) << 48;
- srpc_data.rpc_state = SRPC_STATE_NONE;
+ srpc_data.rpc_state = SRPC_STATE_NONE;
rc = LNetNIInit(LNET_PID_LUSTRE);
if (rc < 0) {
/** error code for scd_buf_wi */
int scd_buf_err;
/** timestamp for scd_buf_err */
- unsigned long scd_buf_err_stamp;
+ time64_t scd_buf_err_stamp;
/** total # request buffers */
int scd_buf_total;
/** # posted request buffers */
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()));
+ LASSERT(cfs_time_after(timer->stt_expires, ktime_get_real_seconds()));
/* a simple insertion sort */
list_for_each_prev(pos, STTIMER_SLOT(timer->stt_expires)) {
/* called with stt_data.stt_lock held */
static int
-stt_expire_list(struct list_head *slot, cfs_time_t now)
+stt_expire_list(struct list_head *slot, time64_t now)
{
int expired = 0;
stt_timer_t *timer;
}
static int
-stt_check_timers (cfs_time_t *last)
+stt_check_timers(cfs_time_t *last)
{
- int expired = 0;
- cfs_time_t now;
+ int expired = 0;
+ time64_t now;
cfs_time_t this_slot;
- now = cfs_time_current_sec();
+ now = ktime_get_real_seconds();
this_slot = now & STTIMER_SLOTTIMEMASK;
spin_lock(&stt_data.stt_lock);
int i;
stt_data.stt_shuttingdown = 0;
- stt_data.stt_prev_slot = cfs_time_current_sec() & STTIMER_SLOTTIMEMASK;
+ stt_data.stt_prev_slot = ktime_get_real_seconds() & STTIMER_SLOTTIMEMASK;
spin_lock_init(&stt_data.stt_lock);
for (i = 0; i < STTIMER_NSLOTS; i++)
typedef struct {
struct list_head stt_list;
- cfs_time_t stt_expires;
- void (*stt_func) (void *);
+ time64_t stt_expires;
+ void (*stt_func)(void *);
void *stt_data;
} stt_timer_t;