]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: only ack subscriptions (and renew) if client or mon is old
authorSage Weil <sage@redhat.com>
Tue, 6 Oct 2015 19:25:02 +0000 (15:25 -0400)
committerSage Weil <sage@redhat.com>
Mon, 23 Nov 2015 13:38:48 +0000 (08:38 -0500)
Old client expect an ack so they can schedule renewal; send it for
them only.

Old mons expect renewals.

Signed-off-by: Sage Weil <sage@redhat.com>
src/include/ceph_features.h
src/mon/MonClient.cc
src/mon/Monitor.cc

index 96f53f1172b226c88185bde28a52bebf91d8afa6..791008a3821d8a94d22cc93245b36693a2306a30 100755 (executable)
@@ -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
index 18db5a706f4a32dc628e118522c85d2f6adb6b66..ede6eebae59c9fa297cb88a34195ed9bd815b88b 100644 (file)
@@ -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;
index 4bbf314beb3cc8d351562d6f180b60b727424f2d..941625cfe68269a7c271bbe5f0bf4f367b6a2e58 100644 (file)
@@ -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));
+  }
 
 }