]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crushtool: Do not allow to compile crushmap with repeat ruleset. 8502/head
authorsongbaisen <song.baisen@zte.com.cn>
Fri, 8 Apr 2016 07:55:55 +0000 (15:55 +0800)
committersongbaisen <song.baisen@zte.com.cn>
Fri, 8 Apr 2016 07:55:55 +0000 (15:55 +0800)
Signed-off-by: song baisen <song.baisen@zte.com.cn>
src/crush/CrushCompiler.cc
src/crush/CrushCompiler.h

index 22e591348992c12c55ae7207240cba0cff0ace11..065443dbfcec6cbb99a1f01956d2b7c05a61008e 100644 (file)
@@ -608,6 +608,10 @@ int CrushCompiler::parse_rule(iter_t const& i)
   }
 
   int ruleset = int_node(i->children[start]);
+  if (ruleset_name.count(ruleset)) {
+    err << "ruleset '" << ruleset << "' already defined in rule '" << ruleset_name[ruleset] <<"'\n"<< std::endl;
+    return -1;
+  }
 
   string tname = string_node(i->children[start+2]);
   int type;
@@ -724,6 +728,7 @@ int CrushCompiler::parse_rule(iter_t const& i)
     }
   }
   assert(step == steps);
+  ruleset_name[ruleset] = rname;
   return 0;
 }
 
index d488735bb9e23c63207f3b235bc00f06d0d357a3..30a9f04c907104c1a111b87979ba8828fc93ce77 100644 (file)
@@ -39,7 +39,7 @@ class CrushCompiler {
   map<int, unsigned> item_weight;
   map<string, int> type_id;
   map<string, int> rule_id;
-
+  map<int, string> ruleset_name;
   string string_node(node_t &node);
   int int_node(node_t &node); 
   float float_node(node_t &node);