]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: add straw_calc_version tunable
authorSage Weil <sage@redhat.com>
Fri, 13 Feb 2015 16:30:35 +0000 (08:30 -0800)
committerSage Weil <sage@redhat.com>
Fri, 13 Feb 2015 16:30:35 +0000 (08:30 -0800)
It doesn't do anything, yet.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 50e2ceefee6a5dfbecbe54890139b1fa80a313c8)

(Modified from original to not create the 'hammer' tunable profile, which
we will not backport in its entirety.)

src/crush/CrushCompiler.cc
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h
src/crush/builder.c
src/crush/crush.h
src/tools/crushtool.cc

index b52a55ad9d00389ccdfba8d9d3240ce1311748cf..33ed1dbfac07f5c2b8cc91c8e48b048c0ca0dc39 100644 (file)
@@ -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; i<crush.get_max_devices(); i++) {
@@ -368,6 +370,8 @@ int CrushCompiler::parse_tunable(iter_t const& i)
     crush.set_chooseleaf_descend_once(val);
   else if (name == "chooseleaf_vary_r")
     crush.set_chooseleaf_vary_r(val);
+  else if (name == "straw_calc_version")
+    crush.set_straw_calc_version(val);
   else {
     err << "tunable " << name << " not recognized" << std::endl;
     return -1;
index 1bf046e6b1fcfdc9b84cd7cc2db598f968e7aaaf..754c9eff2f3674b4b8b5feb2890e61947631e428 100644 (file)
@@ -968,6 +968,7 @@ void CrushWrapper::encode(bufferlist& bl, bool lean) const
   ::encode(crush->choose_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<int32_t,string>& 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())
index 1024f83e4ec34e5254b1539f2782b5ac979fd63d..4323773369be77e423baf9360bf8f4aa8738b1e2 100644 (file)
@@ -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 {
index 6bdd2cfe6984dac5e3e1c23b18219d336ab31b58..6328ad448c083d0a4c7adbf70a282fd52b9ecfd1 100644 (file)
@@ -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;
 }
 
index 322d16c39b7b95e93025d07540d44263a6dd1cd0..712d534f7a35e0d141792c89537d8d08a4d2f3d1 100644 (file)
@@ -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;
 };
 
index 66ca6e3075dfb9d924340faf3c50ed8643c3038b..ebd676866ea1b00fb09a7c8b565ea5f068f098e6 100644 (file)
@@ -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();