]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crush/CrushWrapper: add_simple_ruleset[_at] -> add_simple_rule[_at]
authorSage Weil <sage@redhat.com>
Wed, 14 Jun 2017 19:55:25 +0000 (15:55 -0400)
committerSage Weil <sage@redhat.com>
Mon, 19 Jun 2017 23:09:06 +0000 (19:09 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
12 files changed:
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h
src/erasure-code/isa/ErasureCodeIsa.cc
src/erasure-code/jerasure/ErasureCodeJerasure.cc
src/erasure-code/shec/ErasureCodeShec.cc
src/mon/OSDMonitor.cc
src/osd/OSDMap.cc
src/test/crush/CrushWrapper.cc
src/test/crush/crush.cc
src/test/erasure-code/ErasureCodeExample.h
src/test/osd/TestOSDMap.cc
src/tools/crushtool.cc

index 192a0379157a0f7dc057f415f84180054c6a570f..3a669e959f0235103c32bb2551e8d8bcdace17e5 100644 (file)
@@ -1297,10 +1297,11 @@ void CrushWrapper::reweight(CephContext *cct)
   }
 }
 
-int CrushWrapper::add_simple_ruleset_at(string name, string root_name,
-                                        string failure_domain_name,
-                                        string mode, int rule_type,
-                                        int rno, ostream *err)
+int CrushWrapper::add_simple_rule_at(
+  string name, string root_name,
+  string failure_domain_name,
+  string mode, int rule_type,
+  int rno, ostream *err)
 {
   if (rule_exists(name)) {
     if (err)
@@ -1383,13 +1384,14 @@ int CrushWrapper::add_simple_ruleset_at(string name, string root_name,
   return rno;
 }
 
-int CrushWrapper::add_simple_ruleset(string name, string root_name,
-                                     string failure_domain_name,
-                                     string mode, int rule_type,
-                                     ostream *err)
+int CrushWrapper::add_simple_rule(
+  string name, string root_name,
+  string failure_domain_name,
+  string mode, int rule_type,
+  ostream *err)
 {
-  return add_simple_ruleset_at(name, root_name, failure_domain_name, mode,
-                               rule_type, -1, err);
+  return add_simple_rule_at(name, root_name, failure_domain_name, mode,
+                           rule_type, -1, err);
 }
 
 int CrushWrapper::get_rule_weight_osd_map(unsigned ruleno, map<int,float> *pmap)
index 059362a60d801b8b9d8fd49c16f4aa10e6cae29d..fce35ce79e975846812cc6200c2b831f558bcf15 100644 (file)
@@ -997,14 +997,17 @@ public:
     return set_rule_step(ruleno, step, CRUSH_RULE_EMIT, 0, 0);
   }
 
-  int add_simple_ruleset(string name, string root_name, string failure_domain_type,
-                        string mode, int rule_type, ostream *err = 0);
+  int add_simple_rule(
+    string name, string root_name, string failure_domain_type,
+    string mode, int rule_type, ostream *err = 0);
+
   /**
-   * @param rno ruleset id to use, -1 to pick the lowest available
+   * @param rno rule[set] id to use, -1 to pick the lowest available
    */
-  int add_simple_ruleset_at(string name, string root_name,
-                            string failure_domain_type, string mode,
-                            int rule_type, int rno, ostream *err = 0);
+  int add_simple_rule_at(
+    string name, string root_name,
+    string failure_domain_type, string mode,
+    int rule_type, int rno, ostream *err = 0);
 
   int remove_rule(int ruleno);
 
index 3c8c03eae25029cedec865770a2b44f6f2f4132f..4a6841abd6226e35bc7186afd66e1468c38b20d4 100644 (file)
@@ -51,12 +51,13 @@ ErasureCodeIsa::create_ruleset(const string &name,
                                CrushWrapper &crush,
                                ostream *ss) const
 {
-  int ruleid = crush.add_simple_ruleset(name,
-                                        ruleset_root,
-                                        ruleset_failure_domain,
-                                        "indep",
-                                        pg_pool_t::TYPE_ERASURE,
-                                        ss);
+  int ruleid = crush.add_simple_rule(
+    name,
+    ruleset_root,
+    ruleset_failure_domain,
+    "indep",
+    pg_pool_t::TYPE_ERASURE,
+    ss);
 
   if (ruleid < 0)
     return ruleid;
index 8d73a16421b5a7646fd16c4a20e4b9b695c70071..ca1b09649f7a7c1b1a88a9c300a31c0f996428cd 100644 (file)
@@ -46,8 +46,9 @@ int ErasureCodeJerasure::create_ruleset(const string &name,
                                        CrushWrapper &crush,
                                        ostream *ss) const
 {
-  int ruleid = crush.add_simple_ruleset(name, ruleset_root, ruleset_failure_domain,
-                                       "indep", pg_pool_t::TYPE_ERASURE, ss);
+  int ruleid = crush.add_simple_rule(
+    name, ruleset_root, ruleset_failure_domain,
+    "indep", pg_pool_t::TYPE_ERASURE, ss);
   if (ruleid < 0)
     return ruleid;
   else {
index f8e7a52949fef1a5ea0480398e866cc83d8c684b..c25732c47c566689b3961695096b21c89061d539 100644 (file)
@@ -51,8 +51,9 @@ int ErasureCodeShec::create_ruleset(const string &name,
                                    CrushWrapper &crush,
                                    ostream *ss) const
 {
-  int ruleid = crush.add_simple_ruleset(name, ruleset_root, ruleset_failure_domain,
-                                       "indep", pg_pool_t::TYPE_ERASURE, ss);
+  int ruleid = crush.add_simple_rule(
+    name, ruleset_root, ruleset_failure_domain,
+    "indep", pg_pool_t::TYPE_ERASURE, ss);
   if (ruleid < 0) {
     return ruleid;
   } else {
index 9ae937fc0f57f2da4d0ce5ca35ec8fa742246851..ddfeb2a2933824e94601fc17181314a5edce8a88 100644 (file)
@@ -7733,7 +7733,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       ss << "rule " << name << " already exists";
       err = 0;
     } else {
-      int ruleno = newcrush.add_simple_ruleset(name, root, type, mode,
+      int ruleno = newcrush.add_simple_rule(name, root, type, mode,
                                               pg_pool_t::TYPE_REPLICATED, &ss);
       if (ruleno < 0) {
        err = ruleno;
index 1986040409136ae59e2f04190edffc6593f59f04..2d88f91d4bcc1d9f0ec59732961c202ab21196a2 100644 (file)
@@ -3466,9 +3466,10 @@ int OSDMap::build_simple_crush_rules(
     crush.get_type_name(cct->_conf->osd_crush_chooseleaf_type);
 
   int r;
-  r = crush.add_simple_ruleset_at("replicated_ruleset", root, failure_domain,
-                                  "firstn", pg_pool_t::TYPE_REPLICATED,
-                                  crush_rule, ss);
+  r = crush.add_simple_rule_at(
+    "replicated_ruleset", root, failure_domain,
+    "firstn", pg_pool_t::TYPE_REPLICATED,
+    crush_rule, ss);
   if (r < 0)
     return r;
   // do not add an erasure rule by default or else we will implicitly
index 6fe2955ffda7f3b7ee30cd757805044b486c8695..2d6945d8598acbfc568b28359ba77834c4662fbe 100644 (file)
@@ -896,7 +896,7 @@ TEST(CrushWrapper, dump_rules) {
                                "osd.0", loc));
   }
 
-  // no ruleset by default
+  // no rule by default
   {
     Formatter *f = Formatter::create("json-pretty");
     f->open_array_section("rules");
@@ -909,9 +909,9 @@ TEST(CrushWrapper, dump_rules) {
   }
 
   string name("NAME");
-  int ruleset = c->add_simple_ruleset(name, root_name, failure_domain_type,
-                                     "firstn", pg_pool_t::TYPE_ERASURE);
-  EXPECT_EQ(0, ruleset);
+  int rule = c->add_simple_rule(name, root_name, failure_domain_type,
+                                  "firstn", pg_pool_t::TYPE_ERASURE);
+  EXPECT_EQ(0, rule);
 
   {
     Formatter *f = Formatter::create("xml");
@@ -924,7 +924,7 @@ TEST(CrushWrapper, dump_rules) {
 
   {
     Formatter *f = Formatter::create("xml");
-    c->dump_rule(ruleset, f);
+    c->dump_rule(rule, f);
     stringstream ss;
     f->flush(ss);
     delete f;
@@ -1032,7 +1032,7 @@ TEST(CrushWrapper, choose_args_compat) {
   item = 2;
   c.insert_item(g_ceph_context, item, weight, "osd.2", loc);
 
-  assert(c.add_simple_ruleset("rule1", "r11", "host", "firstn", pg_pool_t::TYPE_ERASURE) >= 0);
+  assert(c.add_simple_rule("rule1", "r11", "host", "firstn", pg_pool_t::TYPE_ERASURE) >= 0);
 
   int id = c.get_item_id("b1");
 
@@ -1102,7 +1102,7 @@ TEST(CrushWrapper, remove_unused_root) {
   loc["root"] = "default";
   c.insert_item(g_ceph_context, item, weight, "osd.2", loc);
 
-  assert(c.add_simple_ruleset("rule1", "r11", "host", "firstn", pg_pool_t::TYPE_ERASURE) >= 0);
+  assert(c.add_simple_rule("rule1", "r11", "host", "firstn", pg_pool_t::TYPE_ERASURE) >= 0);
   ASSERT_TRUE(c.name_exists("default"));
   ASSERT_TRUE(c.name_exists("r11"));
   ASSERT_TRUE(c.name_exists("r12"));
@@ -1346,7 +1346,7 @@ TEST(CrushWrapper, try_remap_rule) {
   {
     cout << "take + choose + emit" << std::endl;
     ostringstream err;
-    int rule = c.add_simple_ruleset("one", "default", "osd", "firstn", 0, &err);
+    int rule = c.add_simple_rule("one", "default", "osd", "firstn", 0, &err);
     ASSERT_EQ(rule, 0);
 
     vector<int> orig = { 0, 3, 9 };
@@ -1382,7 +1382,7 @@ TEST(CrushWrapper, try_remap_rule) {
   {
     cout << "take + chooseleaf + emit" << std::endl;
     ostringstream err;
-    int rule = c.add_simple_ruleset("two", "default", "host", "firstn", 0, &err);
+    int rule = c.add_simple_rule("two", "default", "host", "firstn", 0, &err);
     ASSERT_EQ(rule, 1);
 
     vector<int> orig = { 0, 3, 9 };
index f9d953c8ad16726ad4516b4bb5516ccd9e7e8c1f..6b7d45624c7b83a3055ff42c88c93baddac9b39e 100644 (file)
@@ -52,9 +52,9 @@ std::unique_ptr<CrushWrapper> build_indep_map(CephContext *cct, int num_rack,
   }
   int ret;
   int ruleno = 0;
-  int ruleset = 0;
-  ruleno = ruleset;
-  ret = c->add_rule(4, ruleset, 123, 1, 20, ruleno);
+  int rule = 0;
+  ruleno = rule;
+  ret = c->add_rule(4, rule, 123, 1, 20, ruleno);
   assert(ret == ruleno);
   ret = c->set_rule_step(ruleno, 0, CRUSH_RULE_SET_CHOOSELEAF_TRIES, 10, 0);
   assert(ret == 0);
@@ -271,9 +271,9 @@ TEST(CRUSH, straw_zero) {
   EXPECT_EQ(0, c->set_item_name(root0, root_name0));
 
   string name0("rule0");
-  int ruleset0 = c->add_simple_ruleset(name0, root_name0, "osd",
+  int rule0 = c->add_simple_rule(name0, root_name0, "osd",
                                       "firstn", pg_pool_t::TYPE_REPLICATED);
-  EXPECT_EQ(0, ruleset0);
+  EXPECT_EQ(0, rule0);
 
   string root_name1("root1");
   int root1;
@@ -282,18 +282,18 @@ TEST(CRUSH, straw_zero) {
   EXPECT_EQ(0, c->set_item_name(root1, root_name1));
 
   string name1("rule1");
-  int ruleset1 = c->add_simple_ruleset(name1, root_name1, "osd",
+  int rule1 = c->add_simple_rule(name1, root_name1, "osd",
                                       "firstn", pg_pool_t::TYPE_REPLICATED);
-  EXPECT_EQ(1, ruleset1);
+  EXPECT_EQ(1, rule1);
 
   c->finalize();
 
   vector<unsigned> reweight(n, 0x10000);
   for (int i=0; i<10000; ++i) {
     vector<int> out0, out1;
-    c->do_rule(ruleset0, i, out0, 1, reweight, 0);
+    c->do_rule(rule0, i, out0, 1, reweight, 0);
     ASSERT_EQ(1u, out0.size());
-    c->do_rule(ruleset1, i, out1, 1, reweight, 0);
+    c->do_rule(rule1, i, out1, 1, reweight, 0);
     ASSERT_EQ(1u, out1.size());
     ASSERT_EQ(out0[0], out1[0]);
     //cout << i << "\t" << out0 << "\t" << out1 << std::endl;
@@ -336,9 +336,9 @@ TEST(CRUSH, straw_same) {
   EXPECT_EQ(0, c->set_item_name(root0, root_name0));
 
   string name0("rule0");
-  int ruleset0 = c->add_simple_ruleset(name0, root_name0, "osd",
+  int rule0 = c->add_simple_rule(name0, root_name0, "osd",
                                       "firstn", pg_pool_t::TYPE_REPLICATED);
-  EXPECT_EQ(0, ruleset0);
+  EXPECT_EQ(0, rule0);
 
   for (int i=0; i <n; ++i) {
     items[i] = i;
@@ -352,9 +352,9 @@ TEST(CRUSH, straw_same) {
   EXPECT_EQ(0, c->set_item_name(root1, root_name1));
 
   string name1("rule1");
-  int ruleset1 = c->add_simple_ruleset(name1, root_name1, "osd",
+  int rule1 = c->add_simple_rule(name1, root_name1, "osd",
                                       "firstn", pg_pool_t::TYPE_REPLICATED);
-  EXPECT_EQ(1, ruleset1);
+  EXPECT_EQ(1, rule1);
 
   if (0) {
     crush_bucket_straw *sb0 = reinterpret_cast<crush_bucket_straw*>(c->get_crush_map()->buckets[-1-root0]);
@@ -387,9 +387,9 @@ TEST(CRUSH, straw_same) {
   int max = 100000;
   for (int i=0; i<max; ++i) {
     vector<int> out0, out1;
-    c->do_rule(ruleset0, i, out0, 1, reweight, 0);
+    c->do_rule(rule0, i, out0, 1, reweight, 0);
     ASSERT_EQ(1u, out0.size());
-    c->do_rule(ruleset1, i, out1, 1, reweight, 0);
+    c->do_rule(rule1, i, out1, 1, reweight, 0);
     ASSERT_EQ(1u, out1.size());
     sum0[out0[0]]++;
     sum1[out1[0]]++;
@@ -436,7 +436,7 @@ double calc_straw2_stddev(int *weights, int n, bool verbose)
   c->set_item_name(root0, root_name0);
 
   string name0("rule0");
-  int ruleset0 = c->add_simple_ruleset(name0, root_name0, "osd",
+  int rule0 = c->add_simple_rule(name0, root_name0, "osd",
                                       "firstn", pg_pool_t::TYPE_REPLICATED);
 
   int sum[n];
@@ -455,7 +455,7 @@ double calc_straw2_stddev(int *weights, int n, bool verbose)
   int total = 1000000;
   for (int i=0; i<total; ++i) {
     vector<int> out;
-    c->do_rule(ruleset0, i, out, 1, reweight, 0);
+    c->do_rule(rule0, i, out, 1, reweight, 0);
     sum[out[0]]++;
   }
 
@@ -561,9 +561,9 @@ TEST(CRUSH, straw2_reweight) {
   EXPECT_EQ(0, c->set_item_name(root0, root_name0));
 
   string name0("rule0");
-  int ruleset0 = c->add_simple_ruleset(name0, root_name0, "osd",
+  int rule0 = c->add_simple_rule(name0, root_name0, "osd",
                                       "firstn", pg_pool_t::TYPE_REPLICATED);
-  EXPECT_EQ(0, ruleset0);
+  EXPECT_EQ(0, rule0);
 
   int changed = 1;
   weights[changed] = weights[changed] / 10 * (rand() % 10);
@@ -577,9 +577,9 @@ TEST(CRUSH, straw2_reweight) {
   EXPECT_EQ(0, c->set_item_name(root1, root_name1));
 
   string name1("rule1");
-  int ruleset1 = c->add_simple_ruleset(name1, root_name1, "osd",
+  int rule1 = c->add_simple_rule(name1, root_name1, "osd",
                                       "firstn", pg_pool_t::TYPE_REPLICATED);
-  EXPECT_EQ(1, ruleset1);
+  EXPECT_EQ(1, rule1);
 
   int sum[n];
   double totalweight = 0;
@@ -597,10 +597,10 @@ TEST(CRUSH, straw2_reweight) {
   int total = 1000000;
   for (int i=0; i<total; ++i) {
     vector<int> out0, out1;
-    c->do_rule(ruleset0, i, out0, 1, reweight, 0);
+    c->do_rule(rule0, i, out0, 1, reweight, 0);
     ASSERT_EQ(1u, out0.size());
 
-    c->do_rule(ruleset1, i, out1, 1, reweight, 0);
+    c->do_rule(rule1, i, out1, 1, reweight, 0);
     ASSERT_EQ(1u, out1.size());
 
     sum[out1[0]]++;
index f235c8f13fe4871e4107f30706fb56d68ef2908b..ef8e3e4c24083f4f9f9637510c4594ee6670c65a 100644 (file)
@@ -42,8 +42,8 @@ public:
   int create_ruleset(const string &name,
                             CrushWrapper &crush,
                             ostream *ss) const override {
-    return crush.add_simple_ruleset(name, "default", "host",
-                                   "indep", pg_pool_t::TYPE_ERASURE, ss);
+    return crush.add_simple_rule(name, "default", "host",
+                                "indep", pg_pool_t::TYPE_ERASURE, ss);
   }
   
   int minimum_to_decode(const set<int> &want_to_read,
index dce18f50aa09a231abc3140e7a2c9701bad78f58..c3d615f01fccf372788dd711d6a09aa23f9b2176 100644 (file)
@@ -56,9 +56,10 @@ public:
     osdmap.apply_incremental(pending_inc);
 
     // Create an EC ruleset and a pool using it
-    int r = osdmap.crush->add_simple_ruleset("erasure", "default", "osd",
-                                            "indep", pg_pool_t::TYPE_ERASURE,
-                                            &cerr);
+    int r = osdmap.crush->add_simple_rule(
+      "erasure", "default", "osd",
+      "indep", pg_pool_t::TYPE_ERASURE,
+      &cerr);
 
     OSDMap::Incremental new_pool_inc(osdmap.get_epoch() + 1);
     new_pool_inc.new_pool_max = osdmap.get_pool_max();
index a0dd551d53e5ab54ccaab00d212f7fabd5c45560..b73a1d8c2adc7ece38f31e60b9eb5c5f8be6cff1 100644 (file)
@@ -896,7 +896,7 @@ int main(int argc, const char **argv)
       cerr << "rule " << rule_name << " already exists" << std::endl;
       return EXIT_FAILURE;
     }
-    int r = crush.add_simple_ruleset(rule_name, rule_root, rule_type, rule_mode,
+    int r = crush.add_simple_rule(rule_name, rule_root, rule_type, rule_mode,
       pg_pool_t::TYPE_REPLICATED, &err);
     if (r < 0) {
       cerr << err.str() << std::endl;