]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/CrushWrapper: encode with features
authorSage Weil <sage@redhat.com>
Mon, 28 Nov 2016 19:35:53 +0000 (14:35 -0500)
committerSage Weil <sage@redhat.com>
Mon, 28 Nov 2016 19:35:53 +0000 (14:35 -0500)
No behavior change yet; just fixing callers.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit b7c9e055848c8aa951bc48c957cff3ef323ea441)

[Updated write_file to use all feaetures]
[Updated OSDMonitor.cc to use mon->quorum_features instead of the
 mon->get_quorum_con_featuers() helper]
[trivial conflict from removed write_file and read_file]

Conflicts:
src/crush/CrushWrapper.h
src/mgr/PyModules.cc
src/mon/OSDMonitor.cc
src/tools/ceph_monstore_tool.cc

src/crush/CrushTester.cc
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h
src/mon/OSDMonitor.cc
src/osd/OSDMap.cc
src/test/encoding/types.h
src/tools/ceph_monstore_tool.cc
src/tools/crushtool.cc
src/tools/osdmaptool.cc

index 2ebe8c23d87ee3cf385e1eafa32a4f0a3654d0fc..a879171d5842047056f7fedf7ca920fedfe05d8a 100644 (file)
@@ -4,6 +4,7 @@
 #include "include/stringify.h"
 #include "CrushTester.h"
 #include "CrushTreeDumper.h"
+#include "include/ceph_features.h"
 
 #include <algorithm>
 #include <stdlib.h>
@@ -383,7 +384,7 @@ int CrushTester::test_with_crushtool(const char *crushtool_cmd,
   }
 
   bufferlist bl;
-  ::encode(crush, bl);
+  ::encode(crush, bl, CEPH_FEATURES_SUPPORTED_DEFAULT);
   bl.write_fd(crushtool.get_stdin());
   crushtool.close_stdin();
   bl.clear();
index f254ac0336afcdcdba6a8e6916a4da8c85d6f217..4ea39b8cbd2c6daece8ba6f0438db57263c95759 100644 (file)
@@ -1118,7 +1118,7 @@ int CrushWrapper::remove_rule(int ruleno)
   return 0;
 }
 
-void CrushWrapper::encode(bufferlist& bl) const
+void CrushWrapper::encode(bufferlist& bl, uint64_t features) const
 {
   assert(crush);
 
index 7b6f94150ca3badf7ac680f5229d5547b058970b..07c32e13cefd35b34210fb6cbd2a3cbaf3780561 100644 (file)
@@ -22,6 +22,7 @@ extern "C" {
 
 #include "include/err.h"
 #include "include/encoding.h"
+#include "include/ceph_features.h"
 
 
 #include "common/Mutex.h"
@@ -1132,11 +1133,11 @@ public:
   }
   int write_to_file(const char *fn) {
     bufferlist bl;
-    encode(bl);
+    encode(bl, CEPH_FEATURES_SUPPORTED_DEFAULT);
     return bl.write_file(fn);
   }
 
-  void encode(bufferlist &bl) const;
+  void encode(bufferlist &bl, uint64_t features) const;
   void decode(bufferlist::iterator &blp);
   void decode_crush_bucket(crush_bucket** bptr, bufferlist::iterator &blp);
   void dump(Formatter *f) const;
@@ -1156,6 +1157,6 @@ public:
   static bool is_valid_crush_loc(CephContext *cct,
                                 const map<string,string>& loc);
 };
-WRITE_CLASS_ENCODER(CrushWrapper)
+WRITE_CLASS_ENCODER_FEATURES(CrushWrapper)
 
 #endif
index d4408edd2eb8a14aaf242a59f26f061aacfffd5c..6d156176b6cb5e6c3d0c3ec12e965f0ccb917de0 100644 (file)
@@ -97,7 +97,7 @@ void OSDMonitor::_get_pending_crush(CrushWrapper& newcrush)
   if (pending_inc.crush.length())
     bl = pending_inc.crush;
   else
-    osdmap.crush->encode(bl);
+    osdmap.crush->encode(bl, CEPH_FEATURES_SUPPORTED_DEFAULT);
 
   bufferlist::iterator p = bl.begin();
   newcrush.decode(p);
@@ -3269,7 +3269,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
       rdata.append(osdmap_bl);
       ss << "got osdmap epoch " << p->get_epoch();
     } else if (prefix == "osd getcrushmap") {
-      p->crush->encode(rdata);
+      p->crush->encode(rdata, mon->quorum_features);
       ss << "got crush map from osdmap epoch " << p->get_epoch();
     }
     if (p != &osdmap)
@@ -4421,7 +4421,7 @@ int OSDMonitor::crush_rename_bucket(const string& srcname,
     return ret;
 
   pending_inc.crush.clear();
-  newcrush.encode(pending_inc.crush);
+  newcrush.encode(pending_inc.crush, mon->quorum_features);
   *ss << "renamed bucket " << srcname << " into " << dstname;
   return 0;
 }
@@ -4471,7 +4471,7 @@ int OSDMonitor::crush_ruleset_create_erasure(const string &name,
       return err;
     *ruleset = err;
     pending_inc.crush.clear();
-    newcrush.encode(pending_inc.crush);
+    newcrush.encode(pending_inc.crush, mon->quorum_features);
     return 0;
   }
 }
@@ -4546,7 +4546,7 @@ bool OSDMonitor::validate_crush_against_features(const CrushWrapper *newcrush,
                                                  stringstream& ss)
 {
   OSDMap::Incremental new_pending = pending_inc;
-  ::encode(*newcrush, new_pending.crush);
+  ::encode(*newcrush, new_pending.crush, mon->quorum_features);
   OSDMap newmap;
   newmap.deepish_copy_from(osdmap);
   newmap.apply_incremental(new_pending);
@@ -5569,7 +5569,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     }
 
     pending_inc.crush.clear();
-    newcrush.encode(pending_inc.crush);
+    newcrush.encode(pending_inc.crush, mon->quorum_features);
     ss << "added bucket " << name << " type " << typestr
        << " to crush map";
     goto update;
@@ -5648,7 +5648,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     }
 
     pending_inc.crush.clear();
-    newcrush.encode(pending_inc.crush);
+    newcrush.encode(pending_inc.crush, mon->quorum_features);
     ss << action << " item id " << osdid << " name '" << name << "' weight "
       << weight << " at location " << loc << " to crush map";
     getline(ss, rs);
@@ -5693,7 +5693,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       }
       if (err > 0) {
        pending_inc.crush.clear();
-       newcrush.encode(pending_inc.crush);
+       newcrush.encode(pending_inc.crush, mon->quorum_features);
        ss << "create-or-move updating item name '" << name << "' weight " << weight
           << " at location " << loc << " to crush map";
        getline(ss, rs);
@@ -5730,7 +5730,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
        if (err >= 0) {
          ss << "moved item id " << id << " name '" << name << "' to location " << loc << " in crush map";
          pending_inc.crush.clear();
-         newcrush.encode(pending_inc.crush);
+         newcrush.encode(pending_inc.crush, mon->quorum_features);
          getline(ss, rs);
          wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
                                                   get_last_committed() + 1));
@@ -5783,7 +5783,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
          ss << "linked item id " << id << " name '" << name
              << "' to location " << loc << " in crush map";
          pending_inc.crush.clear();
-         newcrush.encode(pending_inc.crush);
+         newcrush.encode(pending_inc.crush, mon->quorum_features);
        } else {
          ss << "cannot link item id " << id << " name '" << name
              << "' to location " << loc;
@@ -5844,7 +5844,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       }
       if (err == 0) {
        pending_inc.crush.clear();
-       newcrush.encode(pending_inc.crush);
+       newcrush.encode(pending_inc.crush, mon->quorum_features);
        ss << "removed item id " << id << " name '" << name << "' from crush map";
        getline(ss, rs);
        wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
@@ -5860,7 +5860,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
 
     newcrush.reweight(g_ceph_context);
     pending_inc.crush.clear();
-    newcrush.encode(pending_inc.crush);
+    newcrush.encode(pending_inc.crush, mon->quorum_features);
     ss << "reweighted crush hierarchy";
     getline(ss, rs);
     wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
@@ -5897,7 +5897,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     if (err < 0)
       goto reply;
     pending_inc.crush.clear();
-    newcrush.encode(pending_inc.crush);
+    newcrush.encode(pending_inc.crush, mon->quorum_features);
     ss << "reweighted item id " << id << " name '" << name << "' to " << w
        << " in crush map";
     getline(ss, rs);
@@ -5935,7 +5935,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     if (err < 0)
       goto reply;
     pending_inc.crush.clear();
-    newcrush.encode(pending_inc.crush);
+    newcrush.encode(pending_inc.crush, mon->quorum_features);
     ss << "reweighted subtree id " << id << " name '" << name << "' to " << w
        << " in crush map";
     getline(ss, rs);
@@ -5975,7 +5975,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     }
 
     pending_inc.crush.clear();
-    newcrush.encode(pending_inc.crush);
+    newcrush.encode(pending_inc.crush, mon->quorum_features);
     ss << "adjusted tunables profile to " << profile;
     getline(ss, rs);
     wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
@@ -6015,7 +6015,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     }
 
     pending_inc.crush.clear();
-    newcrush.encode(pending_inc.crush);
+    newcrush.encode(pending_inc.crush, mon->quorum_features);
     ss << "adjusted tunable " << tunable << " to " << value;
     getline(ss, rs);
     wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
@@ -6056,7 +6056,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       }
 
       pending_inc.crush.clear();
-      newcrush.encode(pending_inc.crush);
+      newcrush.encode(pending_inc.crush, mon->quorum_features);
     }
     getline(ss, rs);
     wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
@@ -6268,7 +6268,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       }
 
       pending_inc.crush.clear();
-      newcrush.encode(pending_inc.crush);
+      newcrush.encode(pending_inc.crush, mon->quorum_features);
     }
     getline(ss, rs);
     wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
index 45dc6d47e4efb52f3563dfdb0bbb18f7af553c6f..d2fb34f7fe2d199cbda6f7f23610e40d91edbc3f 100644 (file)
@@ -1154,8 +1154,8 @@ void OSDMap::dedup(const OSDMap *o, OSDMap *n)
 
   // does crush match?
   bufferlist oc, nc;
-  ::encode(*o->crush, oc);
-  ::encode(*n->crush, nc);
+  ::encode(*o->crush, oc, CEPH_FEATURES_SUPPORTED_DEFAULT);
+  ::encode(*n->crush, nc, CEPH_FEATURES_SUPPORTED_DEFAULT);
   if (oc.contents_equal(nc)) {
     n->crush = o->crush;
   }
@@ -1826,7 +1826,7 @@ void OSDMap::encode_client_old(bufferlist& bl) const
 
   // crush
   bufferlist cbl;
-  crush->encode(cbl);
+  crush->encode(cbl, 0 /* legacy (no) features */);
   ::encode(cbl, bl);
 }
 
@@ -1861,7 +1861,7 @@ void OSDMap::encode_classic(bufferlist& bl, uint64_t features) const
 
   // crush
   bufferlist cbl;
-  crush->encode(cbl);
+  crush->encode(cbl, 0 /* legacy (no) features */);
   ::encode(cbl, bl);
 
   // extended
@@ -1929,7 +1929,7 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const
 
     // crush
     bufferlist cbl;
-    crush->encode(cbl);
+    crush->encode(cbl, features);
     ::encode(cbl, bl);
     ::encode(erasure_code_profiles, bl);
     ENCODE_FINISH(bl); // client-usable data
index 22919bd970f1a324892fe6c0f63a11d9c2ed6a28..7bed2f3f47bf3999868aeb99df433106743bde94 100644 (file)
@@ -43,7 +43,7 @@ TYPE_FEATUREFUL_STRAYDATA(OSDMap)
 TYPE_FEATUREFUL_STRAYDATA(OSDMap::Incremental)
 
 #include "crush/CrushWrapper.h"
-TYPE_NOCOPY(CrushWrapper)
+TYPE_FEATUREFUL_NOCOPY(CrushWrapper)
 
 #include "common/histogram.h"
 TYPE(pow2_hist_t)
index e2aec2ae95b8cf48efd02cb74488b4a8c98d62db..75fb95b6d13e819cf965ec38400c28e535fb3210 100644 (file)
@@ -272,7 +272,7 @@ int update_osdmap(MonitorDBStore& store, version_t ver, bool copy,
     OSDMap::Incremental inc(bl);
     if (inc.crush.length()) {
       inc.crush.clear();
-      crush->encode(inc.crush);
+      crush->encode(inc.crush, CEPH_FEATURES_SUPPORTED_DEFAULT);
     }
     if (inc.fullmap.length()) {
       OSDMap fullmap;
@@ -889,9 +889,11 @@ int main(int argc, char **argv) {
     } else if (map_type == "crushmap") {
       bufferlist tmp;
       r = st.get("osdmap", st.combine_strings("full", v), tmp);
-      OSDMap osdmap;
-      osdmap.decode(tmp);
-      osdmap.crush->encode(bl);
+      if (r >= 0) {
+        OSDMap osdmap;
+        osdmap.decode(tmp);
+        osdmap.crush->encode(bl, CEPH_FEATURES_SUPPORTED_DEFAULT);
+      }
     } else {
       r = st.get(map_type, v, bl);
     }
index b1f5aaabf42b1e71d04979c71e24a62a9ce2e9a2..03ff4dacd37fe1775fff6f3c425b253b92a2a0ee 100644 (file)
@@ -879,7 +879,7 @@ int main(int argc, const char **argv)
       cout << me << " successfully built or modified map.  Use '-o <file>' to write it out." << std::endl;
     } else {
       bufferlist bl;
-      crush.encode(bl);
+      crush.encode(bl, CEPH_FEATURES_SUPPORTED_DEFAULT);
       int r = bl.write_file(outfn.c_str());
       if (r < 0) {
        cerr << me << ": error writing '" << outfn << "': " << cpp_strerror(r) << std::endl;
index 810f82adcc8935126d8d1d32f6ffeb4ecaa56288..c5dfcc6555c942686b03e96066462a79ef02bd68 100644 (file)
@@ -269,7 +269,7 @@ int main(int argc, const char **argv)
 
   if (!export_crush.empty()) {
     bufferlist cbl;
-    osdmap.crush->encode(cbl);
+    osdmap.crush->encode(cbl, CEPH_FEATURES_SUPPORTED_DEFAULT);
     r = cbl.write_file(export_crush.c_str());
     if (r < 0) {
       cerr << me << ": error writing crush map to " << import_crush << std::endl;