From: James Simmons Date: Wed, 13 Sep 2017 15:44:56 +0000 (-0400) Subject: LU-9019 ptlrpc: migrate pinger to 64 bit time X-Git-Tag: 2.10.54~11 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=44bdc137c901e91d6eafadf3167cc6dfe08b93f2 LU-9019 ptlrpc: migrate pinger to 64 bit time Replace cfs_time_current_sec() to avoid the overflow issues in 2038 with ktime_get_real_seconds(). Remove cfs_timeout_cap() and CFS_DURATION abstraction. Change imp_next_ping, obd_eviction_timer, and ti_timeout to time64_t. With these changes the pinger will be 64 bit time compliant. Change-Id: I447dfa5d47ce947a5afa7203326b6486b8855912 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/28035 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Fan Yong Reviewed-by: Andreas Dilger --- diff --git a/libcfs/include/libcfs/libcfs_time.h b/libcfs/include/libcfs/libcfs_time.h index 68947c9..6cbaf9c 100644 --- a/libcfs/include/libcfs/libcfs_time.h +++ b/libcfs/include/libcfs/libcfs_time.h @@ -67,15 +67,4 @@ static inline cfs_time_t cfs_time_shift(int seconds) #define CFS_TICK 1 -/* - * return valid time-out based on user supplied one. Currently we only check - * that time-out is not shorted than allowed. - */ -static inline cfs_duration_t cfs_timeout_cap(cfs_duration_t timeout) -{ - if (timeout < CFS_TICK) - timeout = CFS_TICK; - return timeout; -} - #endif diff --git a/libcfs/include/libcfs/linux/linux-time.h b/libcfs/include/libcfs/linux/linux-time.h index 6a391e2..70d079f 100644 --- a/libcfs/include/libcfs/linux/linux-time.h +++ b/libcfs/include/libcfs/linux/linux-time.h @@ -62,27 +62,10 @@ * 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); - * int cfs_impl_time_before (cfs_time_t, cfs_time_t); - * int cfs_impl_time_before_eq(cfs_time_t, cfs_time_t); - * - * cfs_duration_t cfs_duration_build(int64_t); * * time_t cfs_duration_sec (cfs_duration_t); - * void cfs_duration_usec(cfs_duration_t, struct timeval *); - * void cfs_duration_nsec(cfs_duration_t, struct timespec *); - * - * CFS_TIME_FORMAT - * CFS_DURATION_FORMAT - * */ -#define ONE_BILLION ((u_int64_t)1000000000) -#define ONE_MILLION 1000000 - -#ifndef __KERNEL__ -#error This include is only for kernel use. -#endif - #include #include #include @@ -265,9 +248,4 @@ static inline int cfs_time_beforeq_64(__u64 t1, __u64 t2) return (__s64)t2 - (__s64)t1 >= 0; } -/* - * One jiffy - */ -#define CFS_DURATION_T "%ld" - #endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */ diff --git a/lustre/include/lustre_export.h b/lustre/include/lustre_export.h index ac05be7..1de4b00 100644 --- a/lustre/include/lustre_export.h +++ b/lustre/include/lustre_export.h @@ -239,7 +239,7 @@ struct obd_export { /** Last committed transno for this export */ __u64 exp_last_committed; /** When was last request received */ - cfs_time_t exp_last_request_time; + time64_t exp_last_request_time; /** On replay all requests waiting for replay are linked here */ struct list_head exp_req_replay_queue; /** @@ -342,13 +342,6 @@ static inline int exp_connect_multibulk(struct obd_export *exp) return exp_max_brw_size(exp) > ONE_MB_BRW_SIZE; } -static inline int exp_expired(struct obd_export *exp, cfs_duration_t age) -{ - LASSERT(exp->exp_delayed); - return cfs_time_before(cfs_time_add(exp->exp_last_request_time, age), - cfs_time_current_sec()); -} - static inline int exp_connect_cancelset(struct obd_export *exp) { LASSERT(exp != NULL); diff --git a/lustre/include/lustre_import.h b/lustre/include/lustre_import.h index 108cec3..3c605b0 100644 --- a/lustre/include/lustre_import.h +++ b/lustre/include/lustre_import.h @@ -255,7 +255,7 @@ struct obd_import { */ struct lustre_handle imp_remote_handle; /** When to perform next ping. time in jiffies. */ - cfs_time_t imp_next_ping; + time64_t imp_next_ping; /** When we last successfully connected. time in 64bit jiffies */ __u64 imp_last_success_conn; diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index bf85c72..4b5806e 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -2303,7 +2303,8 @@ int ptlrpc_service_health_check(struct ptlrpc_service *); void ptlrpc_server_drop_request(struct ptlrpc_request *req); void ptlrpc_request_change_export(struct ptlrpc_request *req, struct obd_export *export); -void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay); +void ptlrpc_update_export_timer(struct obd_export *exp, + time64_t extra_delay); int ptlrpc_hr_init(void); void ptlrpc_hr_fini(void); @@ -2664,7 +2665,7 @@ struct timeout_item; typedef int (*timeout_cb_t)(struct timeout_item *, void *); int ptlrpc_pinger_add_import(struct obd_import *imp); int ptlrpc_pinger_del_import(struct obd_import *imp); -int ptlrpc_add_timeout_client(int time, enum timeout_event event, +int ptlrpc_add_timeout_client(time64_t time, enum timeout_event event, timeout_cb_t cb, void *data, struct list_head *obd_list); int ptlrpc_del_timeout_client(struct list_head *obd_list, diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 29a3cb9..da748f9 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -117,7 +117,7 @@ struct brw_page { struct timeout_item { enum timeout_event ti_event; - cfs_time_t ti_timeout; + time64_t ti_timeout; timeout_cb_t ti_cb; void *ti_cb_data; struct list_head ti_obd_list; @@ -201,9 +201,9 @@ struct client_obd { * See osc_{reserve|unreserve}_grant for details. */ long cl_reserved_grant; struct list_head cl_cache_waiters; /* waiting for cache/grant */ - cfs_time_t cl_next_shrink_grant; /* jiffies */ + time64_t cl_next_shrink_grant; /* seconds */ struct list_head cl_grant_shrink_list; /* Timeout event list */ - int cl_grant_shrink_interval; /* seconds */ + time64_t cl_grant_shrink_interval; /* seconds */ /* A chunk is an optimal size used by osc_extent to determine * the extent size. A chunk is max(PAGE_SIZE, OST block size) */ @@ -637,7 +637,7 @@ struct obd_device { struct obd_export *obd_lwp_export; /* list of exports in LRU order, for ping evictor, with obd_dev_lock */ struct list_head obd_exports_timed; - time_t obd_eviction_timer; /* for ping evictor */ + time64_t obd_eviction_timer; /* for ping evictor */ int obd_max_recoverable_clients; atomic_t obd_connected_clients; diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index ea5af07..2f368bb 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -1233,11 +1233,11 @@ no_export: GOTO(out, rc); } - CDEBUG(D_HA, "%s: connection from %s@%s %st%llu exp %p cur %ld last %ld\n", - target->obd_name, cluuid.uuid, libcfs_nid2str(req->rq_peer.nid), - target->obd_recovering ? "recovering/" : "", data->ocd_transno, - export, (long)cfs_time_current_sec(), - export ? (long)export->exp_last_request_time : 0); + CDEBUG(D_HA, "%s: connection from %s@%s %st%llu exp %p cur %lld last %lld\n", + target->obd_name, cluuid.uuid, libcfs_nid2str(req->rq_peer.nid), + target->obd_recovering ? "recovering/" : "", data->ocd_transno, + export, ktime_get_real_seconds(), + export ? export->exp_last_request_time : 0); /* If this is the first time a client connects, reset the recovery * timer. Discard lightweight connections which might be local. */ diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index fb3bd9a..a398ee5 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -877,7 +877,7 @@ struct obd_export *class_new_export(struct obd_device *obd, INIT_LIST_HEAD(&export->exp_hp_rpcs); INIT_LIST_HEAD(&export->exp_reg_rpcs); class_handle_hash(&export->exp_handle, &export_handle_ops); - export->exp_last_request_time = cfs_time_current_sec(); + export->exp_last_request_time = ktime_get_real_seconds(); spin_lock_init(&export->exp_lock); spin_lock_init(&export->exp_rpc_lock); INIT_HLIST_NODE(&export->exp_uuid_hash); @@ -1326,7 +1326,7 @@ static void class_disconnect_export_list(struct list_head *list, class_export_get(exp); CDEBUG(D_HA, "%s: disconnecting export at %s (%p), " - "last request at %ld\n", + "last request at %lld\n", exp->exp_obd->obd_name, obd_export_nid2str(exp), exp, exp->exp_last_request_time); /* release one export reference anyway */ diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c index b1aa09b..84ba911 100644 --- a/lustre/osc/lproc_osc.c +++ b/lustre/osc/lproc_osc.c @@ -326,7 +326,7 @@ static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v) if (obd == NULL) return 0; - seq_printf(m, "%d\n", + seq_printf(m, "%lld\n", obd->u.cli.cl_grant_shrink_interval); return 0; } diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 5f259e9..6486a2e 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -721,10 +721,11 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, void osc_update_next_shrink(struct client_obd *cli) { - cli->cl_next_shrink_grant = - cfs_time_shift(cli->cl_grant_shrink_interval); - CDEBUG(D_CACHE, "next time %ld to shrink grant \n", - cli->cl_next_shrink_grant); + cli->cl_next_shrink_grant = ktime_get_seconds() + + cli->cl_grant_shrink_interval; + + CDEBUG(D_CACHE, "next time %lld to shrink grant\n", + cli->cl_next_shrink_grant); } static void __osc_update_grant(struct client_obd *cli, u64 grant) @@ -846,14 +847,13 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) static int osc_should_shrink_grant(struct client_obd *client) { - cfs_time_t time = cfs_time_current(); - cfs_time_t next_shrink = client->cl_next_shrink_grant; + time64_t next_shrink = client->cl_next_shrink_grant; if ((client->cl_import->imp_connect_data.ocd_connect_flags & OBD_CONNECT_GRANT_SHRINK) == 0) return 0; - if (cfs_time_aftereq(time, next_shrink - 5 * CFS_TICK)) { + if (ktime_get_seconds() >= next_shrink - 5) { /* Get the current RPC size directly, instead of going via: * cli_brw_size(obd->u.cli.cl_import->imp_obd->obd_self_export) * Keep comment here so that it can be found by searching. */ diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 4409de6..fdac98f 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -2250,7 +2250,7 @@ static void ptlrpc_interrupted_set(void *data) /** * Get the smallest timeout in the set; this does NOT set a timeout. */ -int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set) +time64_t ptlrpc_set_next_timeout(struct ptlrpc_request_set *set) { struct list_head *tmp; time64_t now = ktime_get_real_seconds(); @@ -2308,8 +2308,9 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) struct list_head *tmp; struct ptlrpc_request *req; struct l_wait_info lwi; - int rc, timeout; - ENTRY; + time64_t timeout; + int rc; + ENTRY; if (set->set_producer) (void)ptlrpc_set_producer(set); @@ -2329,7 +2330,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) /* wait until all complete, interrupted, or an in-flight * req times out */ - CDEBUG(D_RPCTRACE, "set %p going to sleep for %d seconds\n", + CDEBUG(D_RPCTRACE, "set %p going to sleep for %lld seconds\n", set, timeout); if ((timeout == 0 && !signal_pending(current)) || diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 65938cc..d1777b5 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -233,10 +233,10 @@ void ptlrpc_deactivate_import(struct obd_import *imp) } EXPORT_SYMBOL(ptlrpc_deactivate_import); -static unsigned int -ptlrpc_inflight_deadline(struct ptlrpc_request *req, time64_t now) +static time64_t ptlrpc_inflight_deadline(struct ptlrpc_request *req, + time64_t now) { - long dl; + time64_t dl; if (!(((req->rq_phase == RQ_PHASE_RPC) && !req->rq_waiting) || (req->rq_phase == RQ_PHASE_BULK) || @@ -262,7 +262,7 @@ static unsigned int ptlrpc_inflight_timeout(struct obd_import *imp) time64_t now = ktime_get_real_seconds(); struct list_head *tmp, *n; struct ptlrpc_request *req; - unsigned int timeout = 0; + time64_t timeout = 0; spin_lock(&imp->imp_lock); list_for_each_safe(tmp, n, &imp->imp_sending_list) { @@ -284,7 +284,7 @@ void ptlrpc_invalidate_import(struct obd_import *imp) struct list_head *tmp, *n; struct ptlrpc_request *req; struct l_wait_info lwi; - unsigned int timeout; + time64_t timeout; int rc; atomic_inc(&imp->imp_inval_count); @@ -300,9 +300,12 @@ void ptlrpc_invalidate_import(struct obd_import *imp) * unlink. We can't do anything before that because there is really * no guarantee that some rdma transfer is not in progress right now. */ do { + long timeout_jiffies; + /* Calculate max timeout for waiting on rpcs to error * out. Use obd_timeout if calculated value is smaller - * than it. */ + * than it. + */ if (!OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK)) { timeout = ptlrpc_inflight_timeout(imp); timeout += timeout / 3; @@ -314,16 +317,18 @@ void ptlrpc_invalidate_import(struct obd_import *imp) timeout = 1; } - CDEBUG(D_RPCTRACE,"Sleeping %d sec for inflight to error out\n", - timeout); + CDEBUG(D_RPCTRACE, "Sleeping %llds for inflight to error out\n", + timeout); /* Wait for all requests to error out and call completion * callbacks. Cap it at obd_timeout -- these should all - * have been locally cancelled by ptlrpc_abort_inflight. */ - lwi = LWI_TIMEOUT_INTERVAL( - cfs_timeout_cap(cfs_time_seconds(timeout)), - (timeout > 1)?cfs_time_seconds(1):cfs_time_seconds(1)/2, - NULL, NULL); + * have been locally cancelled by ptlrpc_abort_inflight. + */ + timeout_jiffies = max_t(long, cfs_time_seconds(timeout), 1); + lwi = LWI_TIMEOUT_INTERVAL(timeout_jiffies, + (timeout > 1) ? cfs_time_seconds(1) : + cfs_time_seconds(1) / 2, + NULL, NULL); rc = l_wait_event(imp->imp_recovery_waitq, (atomic_read(&imp->imp_inflight) == 0), &lwi); @@ -445,16 +450,16 @@ void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt) int ptlrpc_reconnect_import(struct obd_import *imp) { #ifdef ENABLE_PINGER + long timeout_jiffies = cfs_time_seconds(obd_timeout); struct l_wait_info lwi; - int secs = cfs_time_seconds(obd_timeout); int rc; ptlrpc_pinger_force(imp); CDEBUG(D_HA, "%s: recovery started, waiting %u seconds\n", - obd2cli_tgt(imp->imp_obd), secs); + obd2cli_tgt(imp->imp_obd), obd_timeout); - lwi = LWI_TIMEOUT(secs, NULL, NULL); + lwi = LWI_TIMEOUT(timeout_jiffies, NULL, NULL); rc = l_wait_event(imp->imp_recovery_waitq, !ptlrpc_import_in_recovery(imp), &lwi); CDEBUG(D_HA, "%s: recovery finished s:%s\n", obd2cli_tgt(imp->imp_obd), @@ -1579,23 +1584,27 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) RETURN(rc); } - if (ptlrpc_import_in_recovery(imp)) { - struct l_wait_info lwi; - cfs_duration_t timeout; + if (ptlrpc_import_in_recovery(imp)) { + struct l_wait_info lwi; + long timeout_jiffies; + time64_t timeout; - if (AT_OFF) { - if (imp->imp_server_timeout) - timeout = cfs_time_seconds(obd_timeout / 2); - else - timeout = cfs_time_seconds(obd_timeout); - } else { - int idx = import_at_get_index(imp, - imp->imp_client->cli_request_portal); - timeout = cfs_time_seconds( - at_get(&imp->imp_at.iat_service_estimate[idx])); + if (AT_OFF) { + if (imp->imp_server_timeout) + timeout = obd_timeout >> 1; + else + timeout = obd_timeout; + } else { + u32 req_portal; + int idx; + + req_portal = imp->imp_client->cli_request_portal; + idx = import_at_get_index(imp, req_portal); + timeout = at_get(&imp->imp_at.iat_service_estimate[idx]); } - lwi = LWI_TIMEOUT_INTR(cfs_timeout_cap(timeout), + timeout_jiffies = cfs_time_seconds(timeout); + lwi = LWI_TIMEOUT_INTR(max_t(long, timeout_jiffies, 1), back_to_sleep, LWI_ON_SIGNAL_NOOP, NULL); rc = l_wait_event(imp->imp_recovery_waitq, !ptlrpc_import_in_recovery(imp), &lwi); diff --git a/lustre/ptlrpc/pinger.c b/lustre/ptlrpc/pinger.c index 15fb096..ec6b3ca 100644 --- a/lustre/ptlrpc/pinger.c +++ b/lustre/ptlrpc/pinger.c @@ -114,20 +114,21 @@ static int ptlrpc_ping(struct obd_import *imp) static void ptlrpc_update_next_ping(struct obd_import *imp, int soon) { #ifdef ENABLE_PINGER - int time = soon ? PING_INTERVAL_SHORT : PING_INTERVAL; - if (imp->imp_state == LUSTRE_IMP_DISCON) { - int dtime = max_t(int, CONNECTION_SWITCH_MIN, - AT_OFF ? 0 : - at_get(&imp->imp_at.iat_net_latency)); - time = min(time, dtime); - } - imp->imp_next_ping = cfs_time_shift(time); + time64_t time = soon ? PING_INTERVAL_SHORT : PING_INTERVAL; + + if (imp->imp_state == LUSTRE_IMP_DISCON) { + time64_t dtime = max_t(time64_t, CONNECTION_SWITCH_MIN, + AT_OFF ? 0 : + at_get(&imp->imp_at.iat_net_latency)); + time = min(time, dtime); + } + imp->imp_next_ping = ktime_get_seconds() + time; #endif /* ENABLE_PINGER */ } void ptlrpc_ping_import_soon(struct obd_import *imp) { - imp->imp_next_ping = cfs_time_current(); + imp->imp_next_ping = ktime_get_seconds(); } static inline int imp_is_deactive(struct obd_import *imp) @@ -136,34 +137,33 @@ static inline int imp_is_deactive(struct obd_import *imp) OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_IMP_DEACTIVE)); } -static inline int ptlrpc_next_reconnect(struct obd_import *imp) +static inline time64_t ptlrpc_next_reconnect(struct obd_import *imp) { - if (imp->imp_server_timeout) - return cfs_time_shift(obd_timeout / 2); - else - return cfs_time_shift(obd_timeout); + if (imp->imp_server_timeout) + return ktime_get_seconds() + (obd_timeout >> 1); + else + return ktime_get_seconds() + obd_timeout; } -static cfs_duration_t pinger_check_timeout(cfs_time_t time) +static time64_t pinger_check_timeout(time64_t time) { struct timeout_item *item; - cfs_time_t timeout = PING_INTERVAL; + time64_t timeout = PING_INTERVAL; /* This list is sorted in increasing timeout order */ mutex_lock(&pinger_mutex); list_for_each_entry(item, &timeout_list, ti_chain) { - int ti_timeout = item->ti_timeout; + time64_t ti_timeout = item->ti_timeout; + if (timeout > ti_timeout) timeout = ti_timeout; break; } mutex_unlock(&pinger_mutex); - return cfs_time_sub(cfs_time_add(time, cfs_time_seconds(timeout)), - cfs_time_current()); + return time + timeout - ktime_get_seconds(); } - static bool ir_up; void ptlrpc_pinger_ir_up(void) @@ -181,7 +181,7 @@ void ptlrpc_pinger_ir_down(void) EXPORT_SYMBOL(ptlrpc_pinger_ir_down); static void ptlrpc_pinger_process_import(struct obd_import *imp, - unsigned long this_ping) + time64_t this_ping) { int level; int force; @@ -200,8 +200,7 @@ static void ptlrpc_pinger_process_import(struct obd_import *imp, imp->imp_force_verify = 0; - if (cfs_time_aftereq(imp->imp_next_ping - 5 * CFS_TICK, this_ping) && - !force) { + if (imp->imp_next_ping - 5 >= this_ping && !force) { spin_unlock(&imp->imp_lock); return; } @@ -249,9 +248,9 @@ static int ptlrpc_pinger_main(void *arg) /* And now, loop forever, pinging as needed. */ while (1) { - cfs_time_t this_ping = cfs_time_current(); + time64_t this_ping = ktime_get_seconds(); struct l_wait_info lwi; - cfs_duration_t time_to_next_wake; + time64_t time_to_next_wake; struct timeout_item *item; struct list_head *iter; @@ -264,17 +263,15 @@ static int ptlrpc_pinger_main(void *arg) struct obd_import, imp_pinger_chain); - ptlrpc_pinger_process_import(imp, this_ping); - /* obd_timeout might have changed */ - if (imp->imp_pingable && imp->imp_next_ping && - cfs_time_after(imp->imp_next_ping, - cfs_time_add(this_ping, - cfs_time_seconds(PING_INTERVAL)))) - ptlrpc_update_next_ping(imp, 0); - } + ptlrpc_pinger_process_import(imp, this_ping); + /* obd_timeout might have changed */ + if (imp->imp_pingable && imp->imp_next_ping && + imp->imp_next_ping > this_ping + PING_INTERVAL) + ptlrpc_update_next_ping(imp, 0); + } mutex_unlock(&pinger_mutex); - /* update memory usage info */ - obd_update_maxusage(); + /* update memory usage info */ + obd_update_maxusage(); /* Wait until the next ping time, or until we're stopped. */ time_to_next_wake = pinger_check_timeout(this_ping); @@ -284,13 +281,12 @@ static int ptlrpc_pinger_main(void *arg) next ping time to next_ping + .01 sec, which means we will SKIP the next ping at next_ping, and the ping will get sent 2 timeouts from now! Beware. */ - CDEBUG(D_INFO, "next wakeup in "CFS_DURATION_T" (%ld)\n", - time_to_next_wake, - cfs_time_add(this_ping,cfs_time_seconds(PING_INTERVAL))); + CDEBUG(D_INFO, "next wakeup in %lld (%lld)\n", + time_to_next_wake, this_ping + PING_INTERVAL); if (time_to_next_wake > 0) { - lwi = LWI_TIMEOUT(max_t(cfs_duration_t, - time_to_next_wake, - cfs_time_seconds(1)), + time64_t time_max = max(time_to_next_wake, 1LL); + + lwi = LWI_TIMEOUT(cfs_time_seconds(time_max), NULL, NULL); l_wait_event(thread->t_ctl_waitq, thread_is_stopping(thread) || @@ -444,7 +440,7 @@ EXPORT_SYMBOL(ptlrpc_pinger_del_import); * Register a timeout callback to the pinger list, and the callback will * be called when timeout happens. */ -static struct timeout_item *ptlrpc_new_timeout(int time, +static struct timeout_item *ptlrpc_new_timeout(time64_t time, enum timeout_event event, timeout_cb_t cb, void *data) { @@ -469,7 +465,7 @@ static struct timeout_item *ptlrpc_new_timeout(int time, * Note: the timeout list is an sorted list with increased timeout value. */ static struct timeout_item* -ptlrpc_pinger_register_timeout(int time, enum timeout_event event, +ptlrpc_pinger_register_timeout(time64_t time, enum timeout_event event, timeout_cb_t cb, void *data) { struct timeout_item *item, *tmp; @@ -497,7 +493,7 @@ out: /* Add a client_obd to the timeout event list, when timeout(@time) * happens, the callback(@cb) will be called. */ -int ptlrpc_add_timeout_client(int time, enum timeout_event event, +int ptlrpc_add_timeout_client(time64_t time, enum timeout_event event, timeout_cb_t cb, void *data, struct list_head *obd_list) { @@ -600,12 +596,12 @@ int ping_evictor_wake(struct obd_export *exp) static int ping_evictor_main(void *arg) { - struct obd_device *obd; - struct obd_export *exp; - struct l_wait_info lwi = { 0 }; - time_t expire_time; - ENTRY; + struct obd_device *obd; + struct obd_export *exp; + struct l_wait_info lwi = { 0 }; + time64_t expire_time; + ENTRY; unshare_fs_struct(); CDEBUG(D_HA, "Starting Ping Evictor\n"); @@ -626,9 +622,9 @@ static int ping_evictor_main(void *arg) obd_evict_list); spin_unlock(&pet_lock); - expire_time = cfs_time_current_sec() - PING_EVICT_TIMEOUT; + expire_time = ktime_get_real_seconds() - PING_EVICT_TIMEOUT; - CDEBUG(D_HA, "evicting all exports of obd %s older than %ld\n", + CDEBUG(D_HA, "evicting all exports of obd %s older than %lld\n", obd->obd_name, expire_time); /* Exports can't be deleted out of the list while we hold @@ -644,19 +640,19 @@ static int ping_evictor_main(void *arg) class_export_get(exp); spin_unlock(&obd->obd_dev_lock); LCONSOLE_WARN("%s: haven't heard from client %s" - " (at %s) in %ld seconds. I think" + " (at %s) in %lld seconds. I think" " it's dead, and I am evicting" - " it. exp %p, cur %ld expire %ld" - " last %ld\n", + " it. exp %p, cur %lld expire %lld" + " last %lld\n", obd->obd_name, obd_uuid2str(&exp->exp_client_uuid), obd_export_nid2str(exp), - (long)(cfs_time_current_sec() - - exp->exp_last_request_time), - exp, (long)cfs_time_current_sec(), - (long)expire_time, - (long)exp->exp_last_request_time); - CDEBUG(D_HA, "Last request was at %ld\n", + ktime_get_real_seconds() - + exp->exp_last_request_time, + exp, ktime_get_real_seconds(), + expire_time, + exp->exp_last_request_time); + CDEBUG(D_HA, "Last request was at %lld\n", exp->exp_last_request_time); class_fail_export(exp); class_export_put(exp); diff --git a/lustre/ptlrpc/ptlrpc_internal.h b/lustre/ptlrpc/ptlrpc_internal.h index 9c011cf..bf76ecc 100644 --- a/lustre/ptlrpc/ptlrpc_internal.h +++ b/lustre/ptlrpc/ptlrpc_internal.h @@ -83,7 +83,7 @@ void ptlrpc_init_xid(void); void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc, struct ptlrpc_request *req); int ptlrpc_expired_set(void *data); -int ptlrpc_set_next_timeout(struct ptlrpc_request_set *); +time64_t ptlrpc_set_next_timeout(struct ptlrpc_request_set *); void ptlrpc_resend_req(struct ptlrpc_request *request); void ptlrpc_set_bulk_mbits(struct ptlrpc_request *req); void ptlrpc_assign_next_xid_nolock(struct ptlrpc_request *req); diff --git a/lustre/ptlrpc/ptlrpcd.c b/lustre/ptlrpc/ptlrpcd.c index f305739..7566459 100644 --- a/lustre/ptlrpc/ptlrpcd.c +++ b/lustre/ptlrpc/ptlrpcd.c @@ -476,7 +476,7 @@ static int ptlrpcd(void *arg) */ do { struct l_wait_info lwi; - int timeout; + time64_t timeout; timeout = ptlrpc_set_next_timeout(set); lwi = LWI_TIMEOUT(cfs_time_seconds(timeout ? timeout : 1), diff --git a/lustre/ptlrpc/recover.c b/lustre/ptlrpc/recover.c index c526e9e..0c73431 100644 --- a/lustre/ptlrpc/recover.c +++ b/lustre/ptlrpc/recover.c @@ -352,9 +352,9 @@ int ptlrpc_recover_import(struct obd_import *imp, char *new_uuid, int async) if (!async) { struct l_wait_info lwi; - int secs = cfs_time_seconds(obd_timeout); + long secs = cfs_time_seconds(obd_timeout); - CDEBUG(D_HA, "%s: recovery started, waiting %u seconds\n", + CDEBUG(D_HA, "%s: recovery started, waiting %lu seconds\n", obd2cli_tgt(imp->imp_obd), secs); lwi = LWI_TIMEOUT(secs, NULL, NULL); diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index 46c3e98..6afea7e 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -1049,10 +1049,10 @@ static void ptlrpc_server_finish_active_request( * This function is only called when some export receives a message (i.e., * the network is up.) */ -void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) +void ptlrpc_update_export_timer(struct obd_export *exp, time64_t extra_delay) { - struct obd_export *oldest_exp; - time_t oldest_time, new_time; + struct obd_export *oldest_exp; + time64_t oldest_time, new_time; ENTRY; @@ -1065,7 +1065,7 @@ void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) will make it to the top of the list. */ /* Do not pay attention on 1sec or smaller renewals. */ - new_time = cfs_time_current_sec() + extra_delay; + new_time = ktime_get_real_seconds() + extra_delay; if (exp->exp_last_request_time + 1 /*second */ >= new_time) RETURN_EXIT; @@ -1096,33 +1096,35 @@ void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) return; } - /* Note - racing to start/reset the obd_eviction timer is safe */ - if (exp->exp_obd->obd_eviction_timer == 0) { - /* Check if the oldest entry is expired. */ - if (cfs_time_current_sec() > (oldest_time + PING_EVICT_TIMEOUT + - extra_delay)) { - /* We need a second timer, in case the net was down and - * it just came back. Since the pinger may skip every - * other PING_INTERVAL (see note in ptlrpc_pinger_main), - * we better wait for 3. */ - exp->exp_obd->obd_eviction_timer = - cfs_time_current_sec() + 3 * PING_INTERVAL; - CDEBUG(D_HA, "%s: Think about evicting %s from %ld\n", - exp->exp_obd->obd_name, - obd_export_nid2str(oldest_exp), oldest_time); - } - } else { - if (cfs_time_current_sec() > - (exp->exp_obd->obd_eviction_timer + extra_delay)) { - /* The evictor won't evict anyone who we've heard from - * recently, so we don't have to check before we start - * it. */ - if (!ping_evictor_wake(exp)) - exp->exp_obd->obd_eviction_timer = 0; - } - } + /* Note - racing to start/reset the obd_eviction timer is safe */ + if (exp->exp_obd->obd_eviction_timer == 0) { + /* Check if the oldest entry is expired. */ + if (ktime_get_real_seconds() > + oldest_time + PING_EVICT_TIMEOUT + extra_delay) { + /* We need a second timer, in case the net was down and + * it just came back. Since the pinger may skip every + * other PING_INTERVAL (see note in ptlrpc_pinger_main), + * we better wait for 3. + */ + exp->exp_obd->obd_eviction_timer = + ktime_get_real_seconds() + 3 * PING_INTERVAL; + CDEBUG(D_HA, "%s: Think about evicting %s from %lld\n", + exp->exp_obd->obd_name, + obd_export_nid2str(oldest_exp), oldest_time); + } + } else { + if (ktime_get_real_seconds() > + (exp->exp_obd->obd_eviction_timer + extra_delay)) { + /* The evictor won't evict anyone who we've heard from + * recently, so we don't have to check before we start + * it. + */ + if (!ping_evictor_wake(exp)) + exp->exp_obd->obd_eviction_timer = 0; + } + } - EXIT; + EXIT; } /** @@ -2072,7 +2074,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, if (unlikely(ptlrpc_check_req(request))) goto put_conn; ptlrpc_update_export_timer(request->rq_export, - timediff_usecs >> 19); + timediff_usecs / (USEC_PER_SEC / 2)); } /* Discard requests queued for longer than the deadline.