From: Arnd Bergmann Date: Wed, 11 Jan 2017 01:50:19 +0000 (-0500) Subject: LU-4423 ptlrpc: use 64-bit times for ptlrpc_sec X-Git-Tag: 2.9.52~7 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=6df68292ed6bbcd75811fda0f468dc65bf454256 LU-4423 ptlrpc: use 64-bit times for ptlrpc_sec Here we use an unsigned long to store the timeout for gc, which is probably safe until 2106, but this patch converts it to use ktime_get_real_seconds() and time64_t for consistency. Linux-commit: 8cc980713ec9e6847896891c54562ad815c33424 Change-Id: I9c66ac818239debe676b78fbee5764cd5b69028c Signed-off-by: Arnd Bergmann Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/24710 Tested-by: Jenkins Reviewed-by: Andreas Dilger Reviewed-by: Sebastien Buisson Tested-by: Maloo Reviewed-by: Dmitry Eremin --- diff --git a/lustre/include/lustre_sec.h b/lustre/include/lustre_sec.h index a6cf264..1aaab85 100644 --- a/lustre/include/lustre_sec.h +++ b/lustre/include/lustre_sec.h @@ -873,8 +873,8 @@ struct ptlrpc_sec { * garbage collection */ struct list_head ps_gc_list; - cfs_time_t ps_gc_interval; /* in seconds */ - cfs_time_t ps_gc_next; /* in seconds */ + time64_t ps_gc_interval; /* in seconds */ + time64_t ps_gc_next; /* in seconds */ }; static inline int flvr_is_rootonly(__u32 flavor) diff --git a/lustre/ptlrpc/gss/gss_pipefs.c b/lustre/ptlrpc/gss/gss_pipefs.c index af18762..016d455 100644 --- a/lustre/ptlrpc/gss/gss_pipefs.c +++ b/lustre/ptlrpc/gss/gss_pipefs.c @@ -338,8 +338,8 @@ void gss_ctx_cache_gc_pf(struct gss_sec_pipefs *gsec_pf, ctx_check_death_locked_pf(ctx, freelist); } - sec->ps_gc_next = cfs_time_current_sec() + sec->ps_gc_interval; - EXIT; + sec->ps_gc_next = ktime_get_real_seconds() + sec->ps_gc_interval; + EXIT; } static @@ -440,12 +440,12 @@ struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_pf(struct ptlrpc_sec *sec, retry: spin_lock(&sec->ps_lock); - /* gc_next == 0 means never do gc */ - if (remove_dead && sec->ps_gc_next && - cfs_time_after(cfs_time_current_sec(), sec->ps_gc_next)) { - gss_ctx_cache_gc_pf(gsec_pf, &freelist); - gc = 1; - } + /* gc_next == 0 means never do gc */ + if (remove_dead && sec->ps_gc_next && + (ktime_get_real_seconds() > sec->ps_gc_next)) { + gss_ctx_cache_gc_pf(gsec_pf, &freelist); + gc = 1; + } cfs_hlist_for_each_entry_safe(ctx, pos, next, hash_head, cc_cache) { if (gc == 0 && @@ -950,7 +950,7 @@ void gss_pipe_destroy_msg(struct rpc_pipe_msg *msg) { struct gss_upcall_msg *gmsg; struct gss_upcall_msg_data *gumd; - static cfs_time_t ratelimit = 0; + static time64_t ratelimit; ENTRY; LASSERT(list_empty(&msg->list)); @@ -973,9 +973,9 @@ void gss_pipe_destroy_msg(struct rpc_pipe_msg *msg) atomic_inc(&gmsg->gum_refcount); gss_unhash_msg(gmsg); if (msg->errno == -ETIMEDOUT || msg->errno == -EPIPE) { - cfs_time_t now = cfs_time_current_sec(); + time64_t now = ktime_get_real_seconds(); - if (cfs_time_after(now, ratelimit)) { + if (now > ratelimit) { CWARN("upcall timed out, is lgssd running?\n"); ratelimit = now + 15; } diff --git a/lustre/ptlrpc/sec_gc.c b/lustre/ptlrpc/sec_gc.c index c03eb0e..f8ec60b 100644 --- a/lustre/ptlrpc/sec_gc.c +++ b/lustre/ptlrpc/sec_gc.c @@ -66,7 +66,7 @@ void sptlrpc_gc_add_sec(struct ptlrpc_sec *sec) LASSERT(sec->ps_gc_interval > 0); LASSERT(list_empty(&sec->ps_gc_list)); - sec->ps_gc_next = cfs_time_current_sec() + sec->ps_gc_interval; + sec->ps_gc_next = ktime_get_real_seconds() + sec->ps_gc_interval; spin_lock(&sec_gc_list_lock); list_add_tail(&sec->ps_gc_list, &sec_gc_list); @@ -149,11 +149,11 @@ static void sec_do_gc(struct ptlrpc_sec *sec) CDEBUG(D_SEC, "check on sec %p(%s)\n", sec, sec->ps_policy->sp_name); - if (cfs_time_after(sec->ps_gc_next, cfs_time_current_sec())) + if (sec->ps_gc_next > ktime_get_real_seconds()) return; sec->ps_policy->sp_cops->gc_ctx(sec); - sec->ps_gc_next = cfs_time_current_sec() + sec->ps_gc_interval; + sec->ps_gc_next = ktime_get_real_seconds() + sec->ps_gc_interval; } static int sec_gc_main(void *arg) diff --git a/lustre/ptlrpc/sec_lproc.c b/lustre/ptlrpc/sec_lproc.c index 05a239b..96acb18 100644 --- a/lustre/ptlrpc/sec_lproc.c +++ b/lustre/ptlrpc/sec_lproc.c @@ -101,10 +101,10 @@ static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v) seq_printf(seq, "refcount: %d\n", atomic_read(&sec->ps_refcount)); seq_printf(seq, "nctx: %d\n", atomic_read(&sec->ps_nctx)); - seq_printf(seq, "gc internal %ld\n", sec->ps_gc_interval); - seq_printf(seq, "gc next %ld\n", + seq_printf(seq, "gc internal %lld\n", sec->ps_gc_interval); + seq_printf(seq, "gc next %lld\n", sec->ps_gc_interval ? - sec->ps_gc_next - cfs_time_current_sec() : 0); + (s64)(sec->ps_gc_next - ktime_get_real_seconds()) : 0ll); sptlrpc_sec_put(sec); out: