Commit d9f79e6b authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman

staging/lustre: use 64-bit time for selftest

The lustre selftest code has multiple time stamps that are kept
as 'time_t' or 'unsigned long' and can therefore overflow on
32-bit systems.

This changes the code to use time64_t instead.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarOleg Drokin <green@linuxhacker.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ec0067d1
......@@ -134,14 +134,14 @@ brw_client_init(sfw_test_instance_t *tsi)
static int
brw_inject_one_error(void)
{
struct timeval tv;
struct timespec64 ts;
if (brw_inject_errors <= 0)
return 0;
do_gettimeofday(&tv);
ktime_get_ts64(&ts);
if ((tv.tv_usec & 1) == 0)
if (((ts.tv_nsec / NSEC_PER_USEC) & 1) == 0)
return 0;
return brw_inject_errors--;
......
......@@ -837,7 +837,7 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_data *data)
mutex_lock(&console_session.ses_mutex);
console_session.ses_laststamp = get_seconds();
console_session.ses_laststamp = ktime_get_real_seconds();
if (console_session.ses_shutdown) {
rc = -ESHUTDOWN;
......
......@@ -1176,7 +1176,7 @@ lstcon_rpc_pinger(void *arg)
srpc_debug_reqst_t *drq;
lstcon_ndlink_t *ndl;
lstcon_node_t *nd;
time_t intv;
int intv;
int count = 0;
int rc;
......@@ -1191,8 +1191,8 @@ lstcon_rpc_pinger(void *arg)
}
if (!console_session.ses_expired &&
get_seconds() - console_session.ses_laststamp >
(time_t)console_session.ses_timeout)
ktime_get_real_seconds() - console_session.ses_laststamp >
(time64_t)console_session.ses_timeout)
console_session.ses_expired = 1;
trans = console_session.ses_ping;
......@@ -1248,9 +1248,8 @@ lstcon_rpc_pinger(void *arg)
if (nd->nd_state != LST_NODE_ACTIVE)
continue;
intv = cfs_duration_sec(cfs_time_sub(cfs_time_current(),
nd->nd_stamp));
if (intv < (time_t)nd->nd_timeout / 2)
intv = (jiffies - nd->nd_stamp) / HZ;
if (intv < nd->nd_timeout / 2)
continue;
rc = lstcon_rpc_init(nd, SRPC_SERVICE_DEBUG,
......@@ -1278,7 +1277,7 @@ lstcon_rpc_pinger(void *arg)
CDEBUG(D_NET, "Ping %d nodes in session\n", count);
ptimer->stt_expires = (unsigned long)(get_seconds() + LST_PING_INTERVAL);
ptimer->stt_expires = ktime_get_real_seconds() + LST_PING_INTERVAL;
stt_add_timer(ptimer);
mutex_unlock(&console_session.ses_mutex);
......@@ -1301,7 +1300,7 @@ lstcon_rpc_pinger_start(void)
}
ptimer = &console_session.ses_ping_timer;
ptimer->stt_expires = (unsigned long)(get_seconds() + LST_PING_INTERVAL);
ptimer->stt_expires = ktime_get_real_seconds() + LST_PING_INTERVAL;
stt_add_timer(ptimer);
......
......@@ -2004,7 +2004,7 @@ lstcon_console_init(void)
console_session.ses_expired = 0;
console_session.ses_feats_updated = 0;
console_session.ses_features = LST_FEATS_MASK;
console_session.ses_laststamp = get_seconds();
console_session.ses_laststamp = ktime_get_real_seconds();
mutex_init(&console_session.ses_mutex);
......
......@@ -142,7 +142,7 @@ typedef struct {
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)
*/
unsigned ses_features; /* tests features of the session
*/
......
......@@ -170,8 +170,7 @@ sfw_add_session_timer(void)
LASSERT(!sn->sn_timer_active);
sn->sn_timer_active = 1;
timer->stt_expires = cfs_time_add(sn->sn_timeout,
get_seconds());
timer->stt_expires = ktime_get_real_seconds() + sn->sn_timeout;
stt_add_timer(timer);
return;
}
......
......@@ -565,7 +565,7 @@ srpc_add_buffer(struct swi_workitem *wi)
}
if (rc != 0) {
scd->scd_buf_err_stamp = get_seconds();
scd->scd_buf_err_stamp = ktime_get_real_seconds();
scd->scd_buf_err = rc;
LASSERT(scd->scd_buf_posting > 0);
......@@ -1100,8 +1100,7 @@ srpc_add_client_rpc_timer(srpc_client_rpc_t *rpc)
INIT_LIST_HEAD(&timer->stt_list);
timer->stt_data = rpc;
timer->stt_func = srpc_client_rpc_expired;
timer->stt_expires = cfs_time_add(rpc->crpc_timeout,
get_seconds());
timer->stt_expires = ktime_get_real_seconds() + rpc->crpc_timeout;
stt_add_timer(timer);
return;
}
......@@ -1488,7 +1487,7 @@ srpc_lnet_ev_handler(lnet_event_t *ev)
}
if (scd->scd_buf_err_stamp != 0 &&
scd->scd_buf_err_stamp < get_seconds()) {
scd->scd_buf_err_stamp < ktime_get_real_seconds()) {
/* re-enable adding buffer */
scd->scd_buf_err_stamp = 0;
scd->scd_buf_err = 0;
......@@ -1593,7 +1592,7 @@ srpc_startup(void)
/* 1 second pause to avoid timestamp reuse */
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(cfs_time_seconds(1));
srpc_data.rpc_matchbits = ((__u64) get_seconds()) << 48;
srpc_data.rpc_matchbits = ((__u64)ktime_get_real_seconds()) << 48;
srpc_data.rpc_state = SRPC_STATE_NONE;
......
......@@ -279,7 +279,7 @@ struct srpc_service_cd {
/** 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 */
......
......@@ -78,13 +78,13 @@ stt_add_timer(stt_timer_t *timer)
LASSERT(!stt_data.stt_shuttingdown);
LASSERT(timer->stt_func != NULL);
LASSERT(list_empty(&timer->stt_list));
LASSERT(cfs_time_after(timer->stt_expires, get_seconds()));
LASSERT(timer->stt_expires > ktime_get_real_seconds());
/* a simple insertion sort */
list_for_each_prev(pos, STTIMER_SLOT(timer->stt_expires)) {
stt_timer_t *old = list_entry(pos, stt_timer_t, stt_list);
if (cfs_time_aftereq(timer->stt_expires, old->stt_expires))
if (timer->stt_expires >= old->stt_expires)
break;
}
list_add(&timer->stt_list, pos);
......@@ -122,7 +122,7 @@ stt_del_timer(stt_timer_t *timer)
/* called with stt_data.stt_lock held */
static int
stt_expire_list(struct list_head *slot, unsigned long now)
stt_expire_list(struct list_head *slot, time64_t now)
{
int expired = 0;
stt_timer_t *timer;
......@@ -130,7 +130,7 @@ stt_expire_list(struct list_head *slot, unsigned long now)
while (!list_empty(slot)) {
timer = list_entry(slot->next, stt_timer_t, stt_list);
if (cfs_time_after(timer->stt_expires, now))
if (timer->stt_expires > now)
break;
list_del_init(&timer->stt_list);
......@@ -149,10 +149,10 @@ static int
stt_check_timers(unsigned long *last)
{
int expired = 0;
unsigned long now;
time64_t now;
unsigned long this_slot;
now = get_seconds();
now = ktime_get_real_seconds();
this_slot = now & STTIMER_SLOTTIMEMASK;
spin_lock(&stt_data.stt_lock);
......@@ -212,7 +212,7 @@ stt_startup(void)
int i;
stt_data.stt_shuttingdown = 0;
stt_data.stt_prev_slot = get_seconds() & 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++)
......
......@@ -40,7 +40,7 @@
typedef struct {
struct list_head stt_list;
unsigned long stt_expires;
time64_t stt_expires;
void (*stt_func) (void *);
void *stt_data;
} stt_timer_t;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment