From: Sage Weil Date: Fri, 16 Jan 2015 21:20:05 +0000 (-0800) Subject: crush/CrushWrapper: drop weights from crush dump_tree X-Git-Tag: v0.93~227^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=871c3ec5978e80c011256ccbb5c1e1cf219c3cf7;p=ceph.git crush/CrushWrapper: drop weights from crush dump_tree Signed-off-by: Sage Weil --- diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 954d8b210ea6..8d9d21f0dc0c 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -1491,11 +1491,11 @@ class CrushTreePlainDumper : public CrushTreeDumper::Dumper { public: typedef CrushTreeDumper::Dumper Parent; - CrushTreePlainDumper(const CrushWrapper *crush, const vector<__u32>& w) - : Parent(crush), weights(w) {} + CrushTreePlainDumper(const CrushWrapper *crush) + : Parent(crush) {} void dump(ostream *out) { - *out << "ID\tWEIGHT\tTYPE NAME\tREWEIGHT\n"; + *out << "ID\tWEIGHT\tTYPE NAME\n"; Parent::dump(out); } @@ -1514,15 +1514,10 @@ protected: } else { - assert(qi.id >= 0 && (size_t)qi.id < weights.size()); - *out << "osd." << qi.id << "\t" - << weightf_t((double)weights[qi.id] / (double)0x10000) << "\t"; + *out << "osd." << qi.id; } *out << "\n"; } - -private: - const vector<__u32>& weights; }; @@ -1530,8 +1525,8 @@ class CrushTreeFormattingDumper : public CrushTreeDumper::FormattingDumper { public: typedef CrushTreeDumper::FormattingDumper Parent; - CrushTreeFormattingDumper(const CrushWrapper *crush, const vector<__u32>& w) - : Parent(crush), weights(w) {} + CrushTreeFormattingDumper(const CrushWrapper *crush) + : Parent(crush) {} void dump(Formatter *f) { f->open_array_section("nodes"); @@ -1540,28 +1535,15 @@ public: f->open_array_section("stray"); f->close_section(); } - -protected: - virtual void dump_item_fields(const CrushTreeDumper::Item &qi, Formatter *f) { - CrushTreeFormattingDumper::dump_item_fields(qi, f); - if (!qi.is_bucket()) - { - assert(qi.id >= 0 && (size_t)qi.id < weights.size()); - f->dump_float("reweight", (double)weights[qi.id] / (double)0x10000); - } - } - -private: - const vector<__u32>& weights; }; -void CrushWrapper::dump_tree(const vector<__u32>& w, ostream *out, Formatter *f) const +void CrushWrapper::dump_tree(ostream *out, Formatter *f) const { if (out) - CrushTreePlainDumper(this, w).dump(out); + CrushTreePlainDumper(this).dump(out); if (f) - CrushTreeFormattingDumper(this, w).dump(f); + CrushTreeFormattingDumper(this).dump(f); } void CrushWrapper::generate_test_instances(list& o) diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 5e5330591e5d..ae2fc5bcac14 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -1005,7 +1005,7 @@ public: void dump_rule(int ruleset, Formatter *f) const; void dump_tunables(Formatter *f) const; void list_rules(Formatter *f) const; - void dump_tree(const vector<__u32>& w, ostream *out, Formatter *f) const; + void dump_tree(ostream *out, Formatter *f) const; static void generate_test_instances(list& o); int get_osd_pool_default_crush_replicated_ruleset(CephContext *cct); diff --git a/src/test/crush/crush.cc b/src/test/crush/crush.cc index d22e3f3e594a..924647f51e97 100644 --- a/src/test/crush/crush.cc +++ b/src/test/crush/crush.cc @@ -96,7 +96,7 @@ int get_num_dups(const vector& v) TEST(CRUSH, indep_toosmall) { CrushWrapper *c = build_indep_map(g_ceph_context, 1, 3, 1); vector<__u32> weight(c->get_max_devices(), 0x10000); - c->dump_tree(weight, &cout, NULL); + c->dump_tree(&cout, NULL); for (int x = 0; x < 100; ++x) { vector out; @@ -116,7 +116,7 @@ TEST(CRUSH, indep_toosmall) { TEST(CRUSH, indep_basic) { CrushWrapper *c = build_indep_map(g_ceph_context, 3, 3, 3); vector<__u32> weight(c->get_max_devices(), 0x10000); - c->dump_tree(weight, &cout, NULL); + c->dump_tree(&cout, NULL); for (int x = 0; x < 100; ++x) { vector out; @@ -141,7 +141,7 @@ TEST(CRUSH, indep_out_alt) { int num = 3*3*3; for (int i=0; idump_tree(weight, &cout, NULL); + c->dump_tree(&cout, NULL); // need more retries to get 9/9 hosts for x in 0..99 c->set_choose_total_tries(100); @@ -168,7 +168,7 @@ TEST(CRUSH, indep_out_contig) { int num = 3*3*3; for (int i=0; idump_tree(weight, &cout, NULL); + c->dump_tree(&cout, NULL); c->set_choose_total_tries(100); for (int x = 0; x < 100; ++x) { @@ -191,7 +191,7 @@ TEST(CRUSH, indep_out_progressive) { CrushWrapper *c = build_indep_map(g_ceph_context, 3, 3, 3); c->set_choose_total_tries(100); vector<__u32> tweight(c->get_max_devices(), 0x10000); - c->dump_tree(tweight, &cout, NULL); + c->dump_tree(&cout, NULL); int tchanged = 0; for (int x = 1; x < 5; ++x) {