From: Sage Weil Date: Tue, 4 Feb 2014 23:31:40 +0000 (-0800) Subject: crush: add infrastructure around new chooseleaf_vary_r tunable X-Git-Tag: v0.78~202^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e20a55d906b1c3e70a1a41aecafcf6fdd7cd014f;p=ceph.git crush: add infrastructure around new chooseleaf_vary_r tunable - encoding - feature bit - decompile/compile Signed-off-by: Sage Weil --- diff --git a/src/crush/CrushCompiler.cc b/src/crush/CrushCompiler.cc index a954fecd0be4..49d56f50920f 100644 --- a/src/crush/CrushCompiler.cc +++ b/src/crush/CrushCompiler.cc @@ -188,6 +188,8 @@ int CrushCompiler::decompile(ostream &out) out << "tunable choose_total_tries " << crush.get_choose_total_tries() << "\n"; if (crush.get_chooseleaf_descend_once() != 0) 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"; out << "\n# devices\n"; for (int i=0; ichoose_local_fallback_tries, bl); ::encode(crush->choose_total_tries, bl); ::encode(crush->chooseleaf_descend_once, bl); + ::encode(crush->chooseleaf_vary_r, bl); } static void decode_32_or_64_string_map(map& m, bufferlist::iterator& blp) @@ -952,6 +953,9 @@ void CrushWrapper::decode(bufferlist::iterator& blp) if (!blp.end()) { ::decode(crush->chooseleaf_descend_once, blp); } + if (!blp.end()) { + ::decode(crush->chooseleaf_vary_r, blp); + } finalize(); } catch (...) { @@ -1137,7 +1141,9 @@ void CrushWrapper::dump_tunables(Formatter *f) const f->dump_int("chooseleaf_descend_once", get_chooseleaf_descend_once()); // be helpful about it - if (has_bobtail_tunables()) + if (has_firefly_tunables()) + f->dump_string("profile", "firefly"); + else if (has_bobtail_tunables()) f->dump_string("profile", "bobtail"); else if (has_argonaut_tunables()) f->dump_string("profile", "argonaut"); diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index d0f34f06984a..26f9ef0a72a9 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -105,19 +105,28 @@ public: crush->choose_local_fallback_tries = 5; crush->choose_total_tries = 19; crush->chooseleaf_descend_once = 0; + crush->chooseleaf_vary_r = 0; } void set_tunables_bobtail() { crush->choose_local_tries = 0; crush->choose_local_fallback_tries = 0; crush->choose_total_tries = 50; crush->chooseleaf_descend_once = 1; + crush->chooseleaf_vary_r = 0; + } + void set_tunables_firefly() { + crush->choose_local_tries = 0; + crush->choose_local_fallback_tries = 0; + crush->choose_total_tries = 50; + crush->chooseleaf_descend_once = 1; + crush->chooseleaf_vary_r = 1; } void set_tunables_legacy() { set_tunables_argonaut(); } void set_tunables_optimal() { - set_tunables_bobtail(); + set_tunables_firefly(); } void set_tunables_default() { set_tunables_bobtail(); @@ -151,23 +160,40 @@ public: crush->chooseleaf_descend_once = !!n; } + int get_chooseleaf_vary_r() const { + return crush->chooseleaf_vary_r; + } + void set_chooseleaf_vary_r(int n) { + crush->chooseleaf_vary_r = 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_descend_once == 0 && + crush->chooseleaf_vary_r == 0; } bool has_bobtail_tunables() const { return crush->choose_local_tries == 0 && crush->choose_local_fallback_tries == 0 && crush->choose_total_tries == 50 && - crush->chooseleaf_descend_once == 1; + crush->chooseleaf_descend_once == 1 && + crush->chooseleaf_vary_r == 0; + } + bool has_firefly_tunables() const { + return + crush->choose_local_tries == 0 && + crush->choose_local_fallback_tries == 0 && + crush->choose_total_tries == 50 && + crush->chooseleaf_descend_once == 1 && + crush->chooseleaf_vary_r == 1; } bool has_optimal_tunables() const { - return has_bobtail_tunables(); + return has_firefly_tunables(); } bool has_legacy_tunables() const { return has_argonaut_tunables(); @@ -183,6 +209,10 @@ public: return crush->chooseleaf_descend_once != 0; } + bool has_nondefault_tunables3() const { + return + crush->chooseleaf_vary_r != 0; + } bool has_v2_rules() const; diff --git a/src/include/ceph_features.h b/src/include/ceph_features.h index fc9b63d6a413..c81c60092a04 100644 --- a/src/include/ceph_features.h +++ b/src/include/ceph_features.h @@ -48,6 +48,7 @@ this bit to determine if peers support NAK messages. */ #define CEPH_FEATURE_OSDMAP_ENC (1ULL<<39) #define CEPH_FEATURE_MDS_INLINE_DATA (1ULL<<40) +#define CEPH_FEATURE_CRUSH_TUNABLES3 (1ULL<<41) /* * The introduction of CEPH_FEATURE_OSD_SNAPMAPPER caused the feature @@ -116,6 +117,7 @@ static inline unsigned long long ceph_sanitize_features(unsigned long long f) { CEPH_FEATURE_OSD_ERASURE_CODES | \ CEPH_FEATURE_OSDMAP_ENC | \ CEPH_FEATURE_MDS_INLINE_DATA | \ + CEPH_FEATURE_CRUSH_TUNABLES3 | \ 0ULL) #define CEPH_FEATURES_SUPPORTED_DEFAULT CEPH_FEATURES_ALL @@ -126,6 +128,7 @@ static inline unsigned long long ceph_sanitize_features(unsigned long long f) { #define CEPH_FEATURES_CRUSH \ (CEPH_FEATURE_CRUSH_TUNABLES | \ CEPH_FEATURE_CRUSH_TUNABLES2 | \ + CEPH_FEATURE_CRUSH_TUNABLES3 | \ CEPH_FEATURE_CRUSH_V2) #endif diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 902717aea531..c7b9fdfaf117 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -932,6 +932,8 @@ uint64_t OSDMap::get_features(uint64_t *pmask) const features |= CEPH_FEATURE_CRUSH_TUNABLES2; if (crush->has_v2_rules()) features |= CEPH_FEATURE_CRUSH_V2; + if (crush->has_nondefault_tunables3()) + features |= CEPH_FEATURE_CRUSH_TUNABLES3; mask |= CEPH_FEATURES_CRUSH; for (map::const_iterator p = pools.begin(); p != pools.end(); ++p) { diff --git a/src/test/cli/crushtool/help.t b/src/test/cli/crushtool/help.t index 18617a3d8a9b..3b489301c48d 100644 --- a/src/test/cli/crushtool/help.t +++ b/src/test/cli/crushtool/help.t @@ -44,6 +44,8 @@ set choose total descent attempts --set-chooseleaf-descend-once <0|1> set chooseleaf to (not) retry the recursive descent + --set-chooseleaf-vary-r <0|1> + set chooseleaf to (not) vary r based on parent --output-name name prepend the data file(s) generated during the testing routine with name diff --git a/src/tools/crushtool.cc b/src/tools/crushtool.cc index 7709a2a58bfa..0c6d7ba2634c 100644 --- a/src/tools/crushtool.cc +++ b/src/tools/crushtool.cc @@ -129,6 +129,8 @@ void usage() cout << " set choose total descent attempts\n"; cout << " --set-chooseleaf-descend-once <0|1>\n"; cout << " set chooseleaf to (not) retry the recursive descent\n"; + cout << " --set-chooseleaf-vary-r <0|1>\n"; + cout << " set chooseleaf to (not) vary r based on parent\n"; cout << " --output-name name\n"; cout << " prepend the data file(s) generated during the\n"; cout << " testing routine with name\n"; @@ -187,6 +189,7 @@ int main(int argc, const char **argv) int choose_local_fallback_tries = -1; int choose_total_tries = -1; int chooseleaf_descend_once = -1; + int chooseleaf_vary_r = -1; CrushWrapper crush; @@ -257,6 +260,9 @@ int main(int argc, const char **argv) } else if (ceph_argparse_withint(args, i, &chooseleaf_descend_once, &err, "--set_chooseleaf_descend_once", (char*)NULL)) { adjust = true; + } else if (ceph_argparse_withint(args, i, &chooseleaf_vary_r, &err, + "--set_chooseleaf_vary_r", (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)) { @@ -702,6 +708,10 @@ int main(int argc, const char **argv) crush.set_chooseleaf_descend_once(chooseleaf_descend_once); modified = true; } + if (chooseleaf_vary_r >= 0) { + crush.set_chooseleaf_vary_r(chooseleaf_vary_r); + modified = true; + } if (modified) { crush.finalize();