]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: add infrastructure around new chooseleaf_vary_r tunable
authorSage Weil <sage@inktank.com>
Tue, 4 Feb 2014 23:31:40 +0000 (15:31 -0800)
committerSage Weil <sage@inktank.com>
Tue, 11 Feb 2014 16:48:14 +0000 (08:48 -0800)
- encoding
- feature bit
- decompile/compile

Signed-off-by: Sage Weil <sage@inktank.com>
src/crush/CrushCompiler.cc
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h
src/include/ceph_features.h
src/osd/OSDMap.cc
src/test/cli/crushtool/help.t
src/tools/crushtool.cc

index a954fecd0be46619742b027a6a6a9cc048132890..49d56f50920feadbaddd0c58a9427b1d22d34487 100644 (file)
@@ -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; i<crush.get_max_devices(); i++) {
@@ -359,6 +361,8 @@ int CrushCompiler::parse_tunable(iter_t const& i)
     crush.set_choose_total_tries(val);
   else if (name == "chooseleaf_descend_once")
     crush.set_chooseleaf_descend_once(val);
+  else if (name == "chooseleaf_vary_r")
+    crush.set_chooseleaf_vary_r(val);
   else {
     err << "tunable " << name << " not recognized" << std::endl;
     return -1;
index ae4ec1c78d205f37a63cbf0d63bd58a8e30c791d..33755a5a47f6f2793d4b6c12803d764cedfd0b49 100644 (file)
@@ -872,6 +872,7 @@ void CrushWrapper::encode(bufferlist& bl, bool lean) const
   ::encode(crush->choose_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<int32_t,string>& 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");
index d0f34f06984ace5b3353d44fe91febec47851198..26f9ef0a72a9552a5f911479bcd95974a71e5969 100644 (file)
@@ -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;
 
 
index fc9b63d6a413489d552c9a00dd0fa579c4420caa..c81c60092a0492c7faa14d79cb216e75333b1422 100644 (file)
@@ -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
index 902717aea531d03cd4ccfc9037415033e3907e86..c7b9fdfaf1173a2a9f4c32db7001517c167804ff 100644 (file)
@@ -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<int64_t,pg_pool_t>::const_iterator p = pools.begin(); p != pools.end(); ++p) {
index 18617a3d8a9b812cc95d4f4db0136ee2a0100211..3b489301c48d6837c499be5a45c60f8abaf12dad 100644 (file)
@@ -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
index 7709a2a58bfa5815e82927f2d39d0326b8c9a9fb..0c6d7ba2634c291020bb07af6e1328a7e5cef4d0 100644 (file)
@@ -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();