From e79e1d28a688fc6d064bac1ad96bbed206bc87fd Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Wed, 22 Jan 2014 18:01:11 -0800 Subject: [PATCH] Monitor: introduce a function that translates quorum features into disk features After an election, we call apply_quorum_to_compatset_features(). It translates from the quorum features into monitor disk state features we care about and adds them to the disk store. This prevents an older daemon from starting up on a store it doesn't understand. While strictly speaking we don't need to add the EC feature until we create an EC pool, all monitors which speak the new OSDMap encoding also support EC pools, and having more than one feature makes the pattern clearer. Signed-off-by: Greg Farnum --- src/mon/Monitor.cc | 23 +++++++++++++++++++++++ src/mon/Monitor.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index b665b83b8bb20..4d39665399683 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -303,6 +303,8 @@ CompatSet Monitor::get_supported_features() CompatSet::FeatureSet ceph_mon_feature_incompat; ceph_mon_feature_incompat.insert(CEPH_MON_FEATURE_INCOMPAT_BASE); ceph_mon_feature_incompat.insert(CEPH_MON_FEATURE_INCOMPAT_SINGLE_PAXOS); + ceph_mon_feature_incompat.insert(CEPH_MON_FEATURE_INCOMPAT_OSD_ERASURE_CODES); + ceph_mon_feature_incompat.insert(CEPH_MON_FEATURE_INCOMPAT_OSDMAP_ENC); return CompatSet(ceph_mon_feature_compat, ceph_mon_feature_ro_compat, ceph_mon_feature_incompat); } @@ -1588,6 +1590,7 @@ void Monitor::lose_election(epoch_t epoch, set &q, int l, uint64_t features void Monitor::finish_election() { + apply_quorum_to_compatset_features(); timecheck_finish(); exited_quorum = utime_t(); finish_contexts(g_ceph_context, waitfor_quorum); @@ -1605,6 +1608,26 @@ void Monitor::finish_election() } } +void Monitor::apply_quorum_to_compatset_features() +{ + CompatSet new_features(features); + if (quorum_features & CEPH_FEATURE_OSD_ERASURE_CODES) { + new_features.incompat.insert(CEPH_MON_FEATURE_INCOMPAT_OSD_ERASURE_CODES); + } + if (quorum_features & CEPH_FEATURE_OSDMAP_ENC) { + new_features.incompat.insert(CEPH_MON_FEATURE_INCOMPAT_OSDMAP_ENC); + } + + if (new_features.compare(features) != 0) { + CompatSet diff = features.unsupported(new_features); + dout(1) << "Enabling new quorum features: " << diff << dendl; + features = new_features; + MonitorDBStore::Transaction t; + write_features(t); + store->apply_transaction(t); + } +} + void Monitor::sync_force(Formatter *f, ostream& ss) { diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index fcdb7ba977e5c..e7af4429564af 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -525,6 +525,7 @@ public: uint64_t get_quorum_features() const { return quorum_features; } + void apply_quorum_to_compatset_features(); private: void _reset(); ///< called from bootstrap, start_, or join_election @@ -889,6 +890,9 @@ public: #define CEPH_MON_FEATURE_INCOMPAT_BASE CompatSet::Feature (1, "initial feature set (~v.18)") #define CEPH_MON_FEATURE_INCOMPAT_GV CompatSet::Feature (2, "global version sequencing (v0.52)") #define CEPH_MON_FEATURE_INCOMPAT_SINGLE_PAXOS CompatSet::Feature (3, "single paxos with k/v store (v0.\?)") +#define CEPH_MON_FEATURE_INCOMPAT_OSD_ERASURE_CODES CompatSet::Feature(4, "support erasure code pools") +#define CEPH_MON_FEATURE_INCOMPAT_OSDMAP_ENC CompatSet::Feature(5, "new-style osdmap encoding") +// make sure you add your feature to Monitor::get_supported_features long parse_pos_long(const char *s, ostream *pss = NULL); -- 2.39.5