From: songbaisen Date: Fri, 8 Apr 2016 07:55:55 +0000 (+0800) Subject: crushtool: Do not allow to compile crushmap with repeat ruleset. X-Git-Tag: v11.0.0~848^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bbee68f9b840a18ac5d78e5d122d86b204b658cf;p=ceph.git crushtool: Do not allow to compile crushmap with repeat ruleset. Signed-off-by: song baisen --- diff --git a/src/crush/CrushCompiler.cc b/src/crush/CrushCompiler.cc index 22e591348992..065443dbfcec 100644 --- a/src/crush/CrushCompiler.cc +++ b/src/crush/CrushCompiler.cc @@ -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; } diff --git a/src/crush/CrushCompiler.h b/src/crush/CrushCompiler.h index d488735bb9e2..30a9f04c9071 100644 --- a/src/crush/CrushCompiler.h +++ b/src/crush/CrushCompiler.h @@ -39,7 +39,7 @@ class CrushCompiler { map item_weight; map type_id; map rule_id; - + map ruleset_name; string string_node(node_t &node); int int_node(node_t &node); float float_node(node_t &node);