From 27da39ae5dfa18a323f6e544ead598bbb64fc774 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Mon, 8 Apr 2019 10:42:15 +0800 Subject: [PATCH] client: auto reconnect using new entity addrs after blacklisted Signed-off-by: "Yan, Zheng" --- src/client/Client.cc | 12 ++++++++++-- src/client/Client.h | 2 ++ src/common/legacy_config_opts.h | 1 - 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 6db2effdadd..eecc57ebb68 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -6258,6 +6258,15 @@ void Client::tick() } trim_cache(true); + + if (blacklisted && mounted && + last_auto_reconnect + 30 * 60 < now && + cct->_conf.get_val("client_reconnect_stale")) { + messenger->client_reset(); + blacklisted = false; + _kick_stale_sessions(); + last_auto_reconnect = now; + } } void Client::renew_caps() @@ -14069,8 +14078,7 @@ void Client::ms_handle_remote_reset(Connection *con) case MetaSession::STATE_OPEN: { objecter->maybe_request_map(); /* to check if we are blacklisted */ - const auto& conf = cct->_conf; - if (conf->client_reconnect_stale) { + if (cct->_conf.get_val("client_reconnect_stale")) { ldout(cct, 1) << "reset from mds we were open; close mds session for reconnect" << dendl; _closed_mds_session(s); } else { diff --git a/src/client/Client.h b/src/client/Client.h index 2dabfad0035..52eda962b29 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1276,6 +1276,8 @@ private: ceph::unordered_map snap_realms; std::map metadata; + utime_t last_auto_reconnect; + // trace generation ofstream traceout; diff --git a/src/common/legacy_config_opts.h b/src/common/legacy_config_opts.h index bee70445daa..bfbf4f293ff 100644 --- a/src/common/legacy_config_opts.h +++ b/src/common/legacy_config_opts.h @@ -347,7 +347,6 @@ OPTION(client_trace, OPT_STR) OPTION(client_readahead_min, OPT_LONGLONG) // readahead at _least_ this much. OPTION(client_readahead_max_bytes, OPT_LONGLONG) // default unlimited OPTION(client_readahead_max_periods, OPT_LONGLONG) // as multiple of file layout period (object size * num stripes) -OPTION(client_reconnect_stale, OPT_BOOL) // automatically reconnect stale session OPTION(client_snapdir, OPT_STR) OPTION(client_mount_uid, OPT_INT) OPTION(client_mount_gid, OPT_INT) -- 2.39.5