From: Sage Weil Date: Tue, 6 Oct 2015 19:25:02 +0000 (-0400) Subject: mon: only ack subscriptions (and renew) if client or mon is old X-Git-Tag: v10.0.1~26^2~28 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=26496b907758f0f4ac5b33bbc74795ab65227693;p=ceph.git mon: only ack subscriptions (and renew) if client or mon is old Old client expect an ack so they can schedule renewal; send it for them only. Old mons expect renewals. Signed-off-by: Sage Weil --- diff --git a/src/include/ceph_features.h b/src/include/ceph_features.h index 96f53f1172b2..791008a3821d 100755 --- a/src/include/ceph_features.h +++ b/src/include/ceph_features.h @@ -70,6 +70,7 @@ #define CEPH_FEATURE_OSD_HITSET_GMT (1ULL<<54) #define CEPH_FEATURE_HAMMER_0_94_4 (1ULL<<55) #define CEPH_FEATURE_NEW_OSDOP_ENCODING (1ULL<<56) /* New, v7 encoding */ +#define CEPH_FEATURE_MON_STATEFUL_SUB (1ULL<<57) /* stateful mon subscription */ #define CEPH_FEATURE_RESERVED2 (1ULL<<61) /* slow down, we are almost out... */ #define CEPH_FEATURE_RESERVED (1ULL<<62) /* DO NOT USE THIS ... last bit! */ @@ -162,6 +163,7 @@ static inline unsigned long long ceph_sanitize_features(unsigned long long f) { CEPH_FEATURE_OSD_PROXY_WRITE_FEATURES | \ CEPH_FEATURE_OSD_HITSET_GMT | \ CEPH_FEATURE_HAMMER_0_94_4 | \ + CEPH_FEATURE_MON_STATEFUL_SUB | \ 0ULL) #define CEPH_FEATURES_SUPPORTED_DEFAULT CEPH_FEATURES_ALL diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index 18db5a706f4a..ede6eebae59c 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -709,12 +709,14 @@ void MonClient::tick() } else if (!cur_mon.empty()) { // just renew as needed utime_t now = ceph_clock_now(cct); - ldout(cct, 10) << "renew subs? (now: " << now - << "; renew after: " << sub_renew_after << ") -- " - << (now > sub_renew_after ? "yes" : "no") - << dendl; - if (now > sub_renew_after) - _renew_subs(); + if (!cur_con->has_feature(CEPH_FEATURE_MON_STATEFUL_SUB)) { + ldout(cct, 10) << "renew subs? (now: " << now + << "; renew after: " << sub_renew_after << ") -- " + << (now > sub_renew_after ? "yes" : "no") + << dendl; + if (now > sub_renew_after) + _renew_subs(); + } cur_con->send_keepalive(); @@ -722,7 +724,7 @@ void MonClient::tick() if (cct->_conf->mon_client_ping_timeout > 0 && cur_con->has_feature(CEPH_FEATURE_MSGR_KEEPALIVE2)) { utime_t lk = cur_con->get_last_keepalive_ack(); - utime_t interval = ceph_clock_now(cct) - lk; + utime_t interval = now - lk; if (interval > cct->_conf->mon_client_ping_timeout) { ldout(cct, 1) << "no keepalive since " << lk << " (" << interval << " seconds), reconnecting" << dendl; @@ -772,6 +774,8 @@ void MonClient::_renew_subs() void MonClient::handle_subscribe_ack(MMonSubscribeAck *m) { if (sub_renew_sent != utime_t()) { + // NOTE: this is only needed for legacy (infernalis or older) + // mons; see tick(). sub_renew_after = sub_renew_sent; sub_renew_after += m->interval / 2.0; ldout(cct, 10) << "handle_subscribe_ack sent " << sub_renew_sent << " renew after " << sub_renew_after << dendl; diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 4bbf314beb3c..941625cfe682 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -4159,10 +4159,14 @@ void Monitor::handle_subscribe(MonOpRequestRef op) } } - // ??? - - if (reply) - m->get_connection()->send_message(new MMonSubscribeAck(monmap->get_fsid(), (int)g_conf->mon_subscribe_interval)); + if (reply) { + // we only need to reply if the client is old enough to think it + // has to send renewals. + ConnectionRef con = m->get_connection(); + if (!con->has_feature(CEPH_FEATURE_MON_STATEFUL_SUB)) + m->get_connection()->send_message(new MMonSubscribeAck( + monmap->get_fsid(), (int)g_conf->mon_subscribe_interval)); + } }