From dda5480d433053feec245a02c1fa419d7a1f4cff Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Mon, 7 Aug 2017 19:41:35 +0800 Subject: [PATCH] mon: fix inaccurate mon-num counting of 'ceph features' command 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 --- src/mon/Monitor.cc | 2 ++ src/mon/mon_types.h | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index dabfc998ba72..32f7a865eb63 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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; } diff --git a/src/mon/mon_types.h b/src/mon/mon_types.h index a23238b7d0b9..9101776795a0 100644 --- a/src/mon/mon_types.h +++ b/src/mon/mon_types.h @@ -56,10 +56,20 @@ struct FeatureMap { std::map> 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); -- 2.47.3