]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/CrushWrapper: encode with features
authorSage Weil <sage@redhat.com>
Wed, 23 Nov 2016 19:09:58 +0000 (14:09 -0500)
committerSage Weil <sage@redhat.com>
Wed, 23 Nov 2016 21:45:22 +0000 (16:45 -0500)
No behavior change yet; just fixing callers.

Signed-off-by: Sage Weil <sage@redhat.com>
src/crush/CrushTester.cc
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h
src/mgr/PyModules.cc
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 532c55ec7b9b20ec804be946a11551f797157476..635b66530f2872f4547e85c9bf80c2352aac8e38 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 c4604193c77c39a4e5127ca4da364c2d7ef9dc06..88fde7110d9324a8c650d15374fa78e274c7c5dd 100644 (file)
@@ -1125,7 +1125,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 ae2cef6147f31de89f015b422e9616935b68d7a4..fa3c008e5536c71c5d3d39dcebc673e4bc3aa3bf 100644 (file)
@@ -1123,7 +1123,7 @@ public:
     return false;
   }
 
-  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;
@@ -1143,6 +1143,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 8599815363c81d99052323c34c55178c72409e36..c2b79655ad36b227e1ec16d783c6808b6580bc7b 100644 (file)
@@ -125,7 +125,7 @@ PyObject *PyModules::get_python(const std::string &what)
   } else if (what == "osdmap_crush_map_text") {
     bufferlist rdata;
     cluster_state.with_osdmap([&rdata](const OSDMap &osd_map){
-      osd_map.crush->encode(rdata);
+       osd_map.crush->encode(rdata, CEPH_FEATURES_SUPPORTED_DEFAULT);
     });
     std::string crush_text = rdata.to_str();
     return PyString_FromString(crush_text.c_str());
index 15c64a62f92f2a7e971ae9bdcfe6e41183e2ed0c..dc54d2b0e9fbd49513e9b69ed69d29b834a05e30 100644 (file)
@@ -100,7 +100,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);
@@ -3331,7 +3331,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->get_quorum_con_features());
       ss << "got crush map from osdmap epoch " << p->get_epoch();
     }
     if (p != &osdmap)
@@ -4523,7 +4523,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->get_quorum_con_features());
   *ss << "renamed bucket " << srcname << " into " << dstname;  
   return 0;
 }
@@ -4600,7 +4600,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->get_quorum_con_features());
     return 0;
   }
 }
@@ -4676,7 +4676,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->get_quorum_con_features());
   OSDMap newmap;
   newmap.deepish_copy_from(osdmap);
   newmap.apply_incremental(new_pending);
@@ -5778,7 +5778,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     }
 
     pending_inc.crush.clear();
-    newcrush.encode(pending_inc.crush);
+    newcrush.encode(pending_inc.crush, mon->get_quorum_con_features());
     ss << "added bucket " << name << " type " << typestr
        << " to crush map";
     goto update;
@@ -5857,7 +5857,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     }
 
     pending_inc.crush.clear();
-    newcrush.encode(pending_inc.crush);
+    newcrush.encode(pending_inc.crush, mon->get_quorum_con_features());
     ss << action << " item id " << osdid << " name '" << name << "' weight "
       << weight << " at location " << loc << " to crush map";
     getline(ss, rs);
@@ -5902,7 +5902,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->get_quorum_con_features());
        ss << "create-or-move updating item name '" << name << "' weight " << weight
           << " at location " << loc << " to crush map";
        getline(ss, rs);
@@ -5939,7 +5939,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->get_quorum_con_features());
          getline(ss, rs);
          wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
                                                   get_last_committed() + 1));
@@ -5993,7 +5993,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->get_quorum_con_features());
        } else {
          ss << "cannot link item id " << id << " name '" << name
              << "' to location " << loc;
@@ -6055,7 +6055,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->get_quorum_con_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,
@@ -6071,7 +6071,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->get_quorum_con_features());
     ss << "reweighted crush hierarchy";
     getline(ss, rs);
     wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
@@ -6108,7 +6108,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->get_quorum_con_features());
     ss << "reweighted item id " << id << " name '" << name << "' to " << w
        << " in crush map";
     getline(ss, rs);
@@ -6146,7 +6146,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->get_quorum_con_features());
     ss << "reweighted subtree id " << id << " name '" << name << "' to " << w
        << " in crush map";
     getline(ss, rs);
@@ -6186,7 +6186,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     }
 
     pending_inc.crush.clear();
-    newcrush.encode(pending_inc.crush);
+    newcrush.encode(pending_inc.crush, mon->get_quorum_con_features());
     ss << "adjusted tunables profile to " << profile;
     getline(ss, rs);
     wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
@@ -6226,7 +6226,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     }
 
     pending_inc.crush.clear();
-    newcrush.encode(pending_inc.crush);
+    newcrush.encode(pending_inc.crush, mon->get_quorum_con_features());
     ss << "adjusted tunable " << tunable << " to " << value;
     getline(ss, rs);
     wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
@@ -6267,7 +6267,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       }
 
       pending_inc.crush.clear();
-      newcrush.encode(pending_inc.crush);
+      newcrush.encode(pending_inc.crush, mon->get_quorum_con_features());
     }
     getline(ss, rs);
     wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
@@ -6479,7 +6479,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       }
 
       pending_inc.crush.clear();
-      newcrush.encode(pending_inc.crush);
+      newcrush.encode(pending_inc.crush, mon->get_quorum_con_features());
     }
     getline(ss, rs);
     wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
index cd39f8feaf8038bd7d4dbee83693ce8e61f17b6e..0d88572b575b00fc90964ddc3c5692ecf2e6e5bd 100644 (file)
@@ -1160,8 +1160,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;
   }
@@ -1832,7 +1832,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);
 }
 
@@ -1867,7 +1867,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
@@ -1935,7 +1935,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 c56ce71313e09ce8dcfc8887f852ac9f5fa3c925..972878b224558098ca15e6366b416aa6d9f5d4d6 100644 (file)
@@ -45,7 +45,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 5198ebf5d358aaf4d591059511ee38caa70d35ae..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;
@@ -892,7 +892,7 @@ int main(int argc, char **argv) {
       if (r >= 0) {
         OSDMap osdmap;
         osdmap.decode(tmp);
-        osdmap.crush->encode(bl);
+        osdmap.crush->encode(bl, CEPH_FEATURES_SUPPORTED_DEFAULT);
       }
     } else {
       r = st.get(map_type, v, bl);
index 7b199cb584f20e0a35f96301364ae077e06b8eed..ff8f9227b6f0fee67de3be688ca8b3fd96c6e267 100644 (file)
@@ -887,7 +887,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 21858558da7656375d98a51faf32717429d992fd..44f83a78fcf4f10989fefbc383f64acc3f039af7 100644 (file)
@@ -277,7 +277,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;