]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: move feature read/write into helpers
authorSage Weil <sage@inktank.com>
Wed, 12 Sep 2012 23:06:09 +0000 (16:06 -0700)
committerSage Weil <sage@inktank.com>
Thu, 13 Sep 2012 00:33:01 +0000 (17:33 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/Monitor.cc
src/mon/Monitor.h

index 5928facb07a7e80385c72b46cd4492a0e271c2fd..cf3f29d6d23f6df8e578a1e3cbb863fcf817b592 100644 (file)
@@ -330,6 +330,27 @@ int Monitor::check_features(MonitorStore *store)
 
   return 0;
 }
+
+void Monitor::read_features()
+{
+  bufferlist bl;
+  store->get_bl_ss(bl, COMPAT_SET_LOC, 0);
+  if (bl.length()) {
+    bufferlist::iterator p = bl.begin();
+    ::decode(features, p);
+  } else {
+    features = get_ceph_mon_feature_compat_set();
+  }
+  dout(10) << "features " << features << dendl;
+}
+
+void Monitor::write_features()
+{
+  bufferlist bl;
+  features.encode(bl);
+  store->put_bl_ss(bl, COMPAT_SET_LOC, 0);
+}
+
 int Monitor::init()
 {
   lock.Lock();
@@ -382,17 +403,7 @@ int Monitor::init()
   }
 
   // open compatset
-  {
-    bufferlist bl;
-    store->get_bl_ss(bl, COMPAT_SET_LOC, 0);
-    if (bl.length()) {
-      bufferlist::iterator p = bl.begin();
-      ::decode(features, p);
-    } else {
-      features = get_ceph_mon_feature_compat_set();
-    }
-    dout(10) << "features " << features << dendl;
-  }
+  read_features();
 
   // have we ever joined a quorum?
   has_ever_joined = store->exists_bl_ss("joined");
@@ -2262,10 +2273,8 @@ int Monitor::mkfs(bufferlist& osdmapbl)
   if (r < 0)
     return r;
 
-  bufferlist features;
-  CompatSet mon_features = get_ceph_mon_feature_compat_set();
-  mon_features.encode(features);
-  store->put_bl_ss(features, COMPAT_SET_LOC, 0);
+  features = get_ceph_mon_feature_compat_set();
+  write_features();
 
   // save monmap, osdmap, keyring.
   bufferlist monmapbl;
index 793823d5172208344e48281aeeb286334aa544cc..15ebb673cd5ddbdced8be911002aa1f8384c3505 100644 (file)
@@ -418,6 +418,9 @@ public:
 
   void extract_save_mon_key(KeyRing& keyring);
 
+  void read_features();
+  void write_features();
+
  public:
   Monitor(CephContext *cct_, string nm, MonitorStore *s, Messenger *m, MonMap *map);
   ~Monitor();