From: Sage Weil Date: Wed, 23 Nov 2016 19:09:58 +0000 (-0500) Subject: crush/CrushWrapper: encode with features X-Git-Tag: v11.1.0~119^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b7c9e055848c8aa951bc48c957cff3ef323ea441;p=ceph.git crush/CrushWrapper: encode with features No behavior change yet; just fixing callers. Signed-off-by: Sage Weil --- diff --git a/src/crush/CrushTester.cc b/src/crush/CrushTester.cc index 532c55ec7b9b..635b66530f28 100644 --- a/src/crush/CrushTester.cc +++ b/src/crush/CrushTester.cc @@ -4,6 +4,7 @@ #include "include/stringify.h" #include "CrushTester.h" #include "CrushTreeDumper.h" +#include "include/ceph_features.h" #include #include @@ -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(); diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index c4604193c77c..88fde7110d93 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -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); diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index ae2cef6147f3..fa3c008e5536 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -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& loc); }; -WRITE_CLASS_ENCODER(CrushWrapper) +WRITE_CLASS_ENCODER_FEATURES(CrushWrapper) #endif diff --git a/src/mgr/PyModules.cc b/src/mgr/PyModules.cc index 8599815363c8..c2b79655ad36 100644 --- a/src/mgr/PyModules.cc +++ b/src/mgr/PyModules.cc @@ -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()); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 15c64a62f92f..dc54d2b0e9fb 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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, diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index cd39f8feaf80..0d88572b575b 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -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 diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index c56ce71313e0..972878b22455 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -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) diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc index 5198ebf5d358..75fb95b6d13e 100644 --- a/src/tools/ceph_monstore_tool.cc +++ b/src/tools/ceph_monstore_tool.cc @@ -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); diff --git a/src/tools/crushtool.cc b/src/tools/crushtool.cc index 7b199cb584f2..ff8f9227b6f0 100644 --- a/src/tools/crushtool.cc +++ b/src/tools/crushtool.cc @@ -887,7 +887,7 @@ int main(int argc, const char **argv) cout << me << " successfully built or modified map. Use '-o ' 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; diff --git a/src/tools/osdmaptool.cc b/src/tools/osdmaptool.cc index 21858558da76..44f83a78fcf4 100644 --- a/src/tools/osdmaptool.cc +++ b/src/tools/osdmaptool.cc @@ -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;