From: Arnd Bergmann Date: Thu, 20 Oct 2016 01:24:02 +0000 (-0400) Subject: LU-4423 ptlrpc: use 64-bit time for adaptive timeout X-Git-Tag: 2.9.52~69 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=9ee0787384daab9ba76ecaa31e1f2b9b41afdd9a LU-4423 ptlrpc: use 64-bit time for adaptive timeout The adaptive timeout handling stores absolute times in 32-bit time_t quantities, which will overflow in 2038. This changes it to use time64_t. Linux-commit: 0ac0478b65de1e5b8b62f608bdf1d8ba631acc4d Signed-off-by: Arnd Bergmann Change-Id: I50d1090865af8970276d039281fc2ca0b87fa8af Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/23270 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre_import.h b/lustre/include/lustre_import.h index a26f272..51351a4 100644 --- a/lustre/include/lustre_import.h +++ b/lustre/include/lustre_import.h @@ -57,12 +57,12 @@ #define AT_FLG_NOHIST 0x1 /* use last reported value only */ struct adaptive_timeout { - time_t at_binstart; /* bin start time */ + time64_t at_binstart; /* bin start time */ unsigned int at_hist[AT_BINS]; /* timeout history bins */ unsigned int at_flags; unsigned int at_current; /* current timeout value */ unsigned int at_worst_ever; /* worst-ever timeout value */ - time_t at_worst_time; /* worst-ever timeout timestamp */ + time64_t at_worst_time; /* worst-ever timeout timestamp */ spinlock_t at_lock; }; @@ -342,7 +342,7 @@ static inline void at_reset_nolock(struct adaptive_timeout *at, int val) { at->at_current = val; at->at_worst_ever = val; - at->at_worst_time = cfs_time_current_sec(); + at->at_worst_time = ktime_get_real_seconds(); } static inline void at_reset(struct adaptive_timeout *at, int val) diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 594269b..525ff1f 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -1671,12 +1671,12 @@ extern unsigned int at_min, at_max, at_history; int at_measured(struct adaptive_timeout *at, unsigned int val) { unsigned int old = at->at_current; - time_t now = cfs_time_current_sec(); - time_t binlimit = max_t(time_t, at_history / AT_BINS, 1); + time64_t now = ktime_get_real_seconds(); + long binlimit = max_t(long, at_history / AT_BINS, 1); LASSERT(at); CDEBUG(D_OTHER, "add %u to %p time=%lu v=%u (%u %u %u %u)\n", - val, at, now - at->at_binstart, at->at_current, + val, at, (long)(now - at->at_binstart), at->at_current, at->at_hist[0], at->at_hist[1], at->at_hist[2], at->at_hist[3]); if (val == 0) @@ -1700,8 +1700,9 @@ int at_measured(struct adaptive_timeout *at, unsigned int val) } else { int i, shift; unsigned int maxv = val; - /* move bins over */ - shift = (now - at->at_binstart) / binlimit; + + /* move bins over */ + shift = (u32)(now - at->at_binstart) / binlimit; LASSERT(shift > 0); for(i = AT_BINS - 1; i >= 0; i--) { if (i >= shift) { diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c index 3e0a089..4eb84d0 100644 --- a/lustre/ptlrpc/lproc_ptlrpc.c +++ b/lustre/ptlrpc/lproc_ptlrpc.c @@ -1030,7 +1030,7 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) struct ptlrpc_service *svc = m->private; struct ptlrpc_service_part *svcpt; struct dhms ts; - time_t worstt; + time64_t worstt; unsigned int cur; unsigned int worst; int i; @@ -1045,11 +1045,11 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) cur = at_get(&svcpt->scp_at_estimate); worst = svcpt->scp_at_estimate.at_worst_ever; worstt = svcpt->scp_at_estimate.at_worst_time; - s2dhms(&ts, cfs_time_current_sec() - worstt); + s2dhms(&ts, ktime_get_real_seconds() - worstt); - seq_printf(m, "%10s : cur %3u worst %3u (at %ld, " + seq_printf(m, "%10s : cur %3u worst %3u (at %lld, " DHMS_FMT" ago) ", "service", - cur, worst, worstt, DHMS_VARS(&ts)); + cur, worst, (s64)worstt, DHMS_VARS(&ts)); lprocfs_at_hist_helper(m, &svcpt->scp_at_estimate); }