From: Sage Weil Date: Fri, 13 Feb 2015 16:30:35 +0000 (-0800) Subject: crush: add straw_calc_version tunable X-Git-Tag: v0.80.9~11^2~15 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=cfc718a5a1fec937cf00e6c2b55f66d4390088bb;p=ceph.git crush: add straw_calc_version tunable It doesn't do anything, yet. Signed-off-by: Sage Weil (cherry picked from commit 50e2ceefee6a5dfbecbe54890139b1fa80a313c8) (Modified from original to not create the 'hammer' tunable profile, which we will not backport in its entirety.) --- diff --git a/src/crush/CrushCompiler.cc b/src/crush/CrushCompiler.cc index b52a55ad9d003..33ed1dbfac07f 100644 --- a/src/crush/CrushCompiler.cc +++ b/src/crush/CrushCompiler.cc @@ -191,6 +191,8 @@ int CrushCompiler::decompile(ostream &out) out << "tunable chooseleaf_descend_once " << crush.get_chooseleaf_descend_once() << "\n"; if (crush.get_chooseleaf_vary_r() != 0) out << "tunable chooseleaf_vary_r " << crush.get_chooseleaf_vary_r() << "\n"; + if (crush.get_straw_calc_version() != 0) + out << "tunable straw_calc_version " << crush.get_straw_calc_version() << "\n"; out << "\n# devices\n"; for (int i=0; ichoose_total_tries, bl); ::encode(crush->chooseleaf_descend_once, bl); ::encode(crush->chooseleaf_vary_r, bl); + ::encode(crush->straw_calc_version, bl); } static void decode_32_or_64_string_map(map& m, bufferlist::iterator& blp) @@ -1051,6 +1052,9 @@ void CrushWrapper::decode(bufferlist::iterator& blp) if (!blp.end()) { ::decode(crush->chooseleaf_vary_r, blp); } + if (!blp.end()) { + ::decode(crush->straw_calc_version, blp); + } finalize(); } catch (...) { @@ -1235,6 +1239,7 @@ void CrushWrapper::dump_tunables(Formatter *f) const f->dump_int("choose_total_tries", get_choose_total_tries()); f->dump_int("chooseleaf_descend_once", get_chooseleaf_descend_once()); f->dump_int("chooseleaf_vary_r", get_chooseleaf_vary_r()); + f->dump_int("straw_calc_version", get_straw_calc_version()); // be helpful about it if (has_firefly_tunables()) diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 1024f83e4ec34..4323773369be7 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -106,6 +106,7 @@ public: crush->choose_total_tries = 19; crush->chooseleaf_descend_once = 0; crush->chooseleaf_vary_r = 0; + crush->straw_calc_version = 0; } void set_tunables_bobtail() { crush->choose_local_tries = 0; @@ -113,6 +114,7 @@ public: crush->choose_total_tries = 50; crush->chooseleaf_descend_once = 1; crush->chooseleaf_vary_r = 0; + crush->straw_calc_version = 0; } void set_tunables_firefly() { crush->choose_local_tries = 0; @@ -120,6 +122,7 @@ public: crush->choose_total_tries = 50; crush->chooseleaf_descend_once = 1; crush->chooseleaf_vary_r = 1; + crush->straw_calc_version = 0; } void set_tunables_legacy() { @@ -167,13 +170,21 @@ public: crush->chooseleaf_vary_r = n; } + int get_straw_calc_version() const { + return crush->straw_calc_version; + } + void set_straw_calc_version(int n) { + crush->straw_calc_version = n; + } + bool has_argonaut_tunables() const { return crush->choose_local_tries == 2 && crush->choose_local_fallback_tries == 5 && crush->choose_total_tries == 19 && crush->chooseleaf_descend_once == 0 && - crush->chooseleaf_vary_r == 0; + crush->chooseleaf_vary_r == 0 && + crush->straw_calc_version == 0; } bool has_bobtail_tunables() const { return @@ -181,7 +192,8 @@ public: crush->choose_local_fallback_tries == 0 && crush->choose_total_tries == 50 && crush->chooseleaf_descend_once == 1 && - crush->chooseleaf_vary_r == 0; + crush->chooseleaf_vary_r == 0 && + crush->straw_calc_version == 0; } bool has_firefly_tunables() const { return @@ -189,7 +201,8 @@ public: crush->choose_local_fallback_tries == 0 && crush->choose_total_tries == 50 && crush->chooseleaf_descend_once == 1 && - crush->chooseleaf_vary_r == 1; + crush->chooseleaf_vary_r == 1 && + crush->straw_calc_version == 0; } bool has_optimal_tunables() const { diff --git a/src/crush/builder.c b/src/crush/builder.c index 6bdd2cfe6984d..6328ad448c083 100644 --- a/src/crush/builder.c +++ b/src/crush/builder.c @@ -29,6 +29,7 @@ struct crush_map *crush_create() m->choose_total_tries = 19; m->chooseleaf_descend_once = 0; m->chooseleaf_vary_r = 0; + m->straw_calc_version = 0; return m; } diff --git a/src/crush/crush.h b/src/crush/crush.h index 322d16c39b7b9..712d534f7a35e 100644 --- a/src/crush/crush.h +++ b/src/crush/crush.h @@ -191,6 +191,12 @@ struct crush_map { * mappings line up a bit better with previous mappings. */ __u8 chooseleaf_vary_r; + /* + * version 0 (original) of straw_calc has various flaws. version 1 + * fixes a few of them. + */ + __u8 straw_calc_version; + __u32 *choose_tries; }; diff --git a/src/tools/crushtool.cc b/src/tools/crushtool.cc index 66ca6e3075dfb..ebd676866ea1b 100644 --- a/src/tools/crushtool.cc +++ b/src/tools/crushtool.cc @@ -191,6 +191,7 @@ int main(int argc, const char **argv) int choose_total_tries = -1; int chooseleaf_descend_once = -1; int chooseleaf_vary_r = -1; + int straw_calc_version = -1; CrushWrapper crush; @@ -267,6 +268,9 @@ int main(int argc, const char **argv) } else if (ceph_argparse_withint(args, i, &chooseleaf_vary_r, &err, "--set_chooseleaf_vary_r", (char*)NULL)) { adjust = true; + } else if (ceph_argparse_withint(args, i, &straw_calc_version, &err, + "--set_straw_calc_version", (char*)NULL)) { + adjust = true; } else if (ceph_argparse_flag(args, i, "--reweight", (char*)NULL)) { reweight = true; } else if (ceph_argparse_withint(args, i, &add_item, &err, "--add_item", (char*)NULL)) { @@ -716,6 +720,10 @@ int main(int argc, const char **argv) crush.set_chooseleaf_vary_r(chooseleaf_vary_r); modified = true; } + if (straw_calc_version >= 0) { + crush.set_straw_calc_version(straw_calc_version); + modified = true; + } if (modified) { crush.finalize();