]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: fix inaccurate mon-num counting of 'ceph features' command
authorxie xingguo <xie.xingguo@zte.com.cn>
Mon, 7 Aug 2017 11:41:35 +0000 (19:41 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Tue, 8 Aug 2017 07:54:09 +0000 (15:54 +0800)
Monitors need to talk to each other, which causes the inaccurate
mon-num counting logic of 'ceph features' command.
E.g.:
(1) By specifying 2 monitors, you get 4 from 'ceph features':
    "mon": {
        "group": {
            "features": 2305244844532236283,
            "release": "luminous",
            "num": 4
        }
    },
(2) By specifying 3 monitors, you get 9 from 'ceph features':
   "mon": {
        "group": {
            "features": 2305244844532236283,
            "release": "luminous",
            "num": 9
        }
    },

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/mon/Monitor.cc
src/mon/mon_types.h

index dabfc998ba72b3380d8e1e475c7c7aba602ac93d..32f7a865eb63180b3daffc3bbf7ca9479c09e1ab 100644 (file)
@@ -796,6 +796,8 @@ int Monitor::init()
   mgr_messenger->add_dispatcher_tail(this);  // for auth ms_* calls
 
   bootstrap();
+  // add features of myself into feature_map
+  session_map.feature_map.add_mon(con_self->get_features());
   return 0;
 }
 
index a23238b7d0b9c53c7f991e6d02d205e828329788..9101776795a0943dbdab91d6f481e9efcf38ae77 100644 (file)
@@ -56,10 +56,20 @@ struct FeatureMap {
   std::map<uint32_t,std::map<uint64_t,uint64_t>> m;
 
   void add(uint32_t type, uint64_t features) {
+    if (type == CEPH_ENTITY_TYPE_MON) {
+      return;
+    }
     m[type][features]++;
   }
 
+  void add_mon(uint64_t features) {
+    m[CEPH_ENTITY_TYPE_MON][features]++;
+  }
+
   void rm(uint32_t type, uint64_t features) {
+    if (type == CEPH_ENTITY_TYPE_MON) {
+      return;
+    }
     auto p = m.find(type);
     assert(p != m.end());
     auto q = p->second.find(features);