From 96ddb3b168297e7d59a2f4b7b357549f2632bcb4 Mon Sep 17 00:00:00 2001 From: Vladimir Saveliev Date: Sun, 5 Jul 2015 12:15:01 +0300 Subject: [PATCH] LU-6805 ptlrpc: use smp unsafe at_init only for initialization at_init() is not smp safe, so it is not supposed to be used anywhere but in at initialization. Add at_reinit() - safe version of at_init(). Xyratex-bug-id: MRP-2726 Signed-off-by: Vladimir Saveliev Change-Id: I90f872bd217d1e8008f8d35bb4606d168c9bf2ad Reviewed-on: http://review.whamcloud.com/15522 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Chris Horn --- lustre/include/lustre_import.h | 22 ++++++++++++++++++++-- lustre/ptlrpc/import.c | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lustre/include/lustre_import.h b/lustre/include/lustre_import.h index 8ae6648..784268c 100644 --- a/lustre/include/lustre_import.h +++ b/lustre/include/lustre_import.h @@ -333,19 +333,37 @@ static inline unsigned int at_timeout2est(unsigned int val) return (max((val << 2) / 5, 5U) - 4); } -static inline void at_reset(struct adaptive_timeout *at, int val) { - spin_lock(&at->at_lock); +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(); +} + +static inline void at_reset(struct adaptive_timeout *at, int val) +{ + spin_lock(&at->at_lock); + at_reset_nolock(at, val); spin_unlock(&at->at_lock); } + static inline void at_init(struct adaptive_timeout *at, int val, int flags) { memset(at, 0, sizeof(*at)); spin_lock_init(&at->at_lock); at->at_flags = flags; at_reset(at, val); } + +static inline void at_reinit(struct adaptive_timeout *at, int val, int flags) +{ + spin_lock(&at->at_lock); + at->at_binstart = 0; + memset(at->at_hist, 0, sizeof(at->at_hist)); + at->at_flags = flags; + at_reset_nolock(at, val); + spin_unlock(&at->at_lock); +} + extern unsigned int at_min; static inline int at_get(struct adaptive_timeout *at) { return (at->at_current > at_min) ? at->at_current : at_min; diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index aa07573..e682e7c 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -1056,7 +1056,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, /* The net statistics after (re-)connect is not valid anymore, * because may reflect other routing, etc. */ - at_init(&imp->imp_at.iat_net_latency, 0, 0); + at_reinit(&imp->imp_at.iat_net_latency, 0, 0); ptlrpc_at_adj_net_latency(request, lustre_msg_get_service_time(request->rq_repmsg)); -- 1.8.3.1