From: John Spray Date: Tue, 20 May 2014 15:50:18 +0000 (+0100) Subject: mon: pool set crush_ruleset must not use rule_exists X-Git-Tag: v0.80.2~34^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1962%2Fhead;p=ceph.git mon: pool set crush_ruleset must not use rule_exists Implement CrushWrapper::ruleset_exists that iterates over the existing rulesets to find the one matching the ruleset argument. ceph osd pool set crush_ruleset must not use CrushWrapper::rule_exists, which checks for a *rule* existing, whereas the value being set is a *ruleset*. (cherry picked from commit fb504baed98d57dca8ec141bcc3fd021f99d82b0) A test via ceph osd pool set data crush_ruleset verifies the ruleset argument is accepted. http://tracker.ceph.com/issues/8599 fixes: #8599 Backport: firefly, emperor, dumpling Signed-off-by: John Spray Signed-off-by: Loic Dachary --- diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index d5e9cef486f60..80f3f4c2269bb 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -51,6 +51,31 @@ function check_response() fi } +# +# Verify ceph osd pool set data crush_ruleset when +# when ruleset != rule_id http://tracker.ceph.com/issues/8599 +# +MAP=$TMPFILE.map.$$ +ceph osd getcrushmap -o $MAP +[ -s $MAP ] +crushtool --decompile $MAP -o $MAP.decompiled +RULESET=55 +cat >> $MAP.decompiled <max_rules; ++i) { + if (crush->rules[i]->mask.ruleset == ruleset) { + return true; + } + } + + return false; + } + void do_rule(int rule, int x, vector& out, int maxout, const vector<__u32>& weight) const { Mutex::Locker l(mapper_lock); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 1ed3a95ef30de..a4dcc58489da3 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -3411,7 +3411,7 @@ int OSDMonitor::prepare_command_pool_set(map &cmdmap, ss << "error parsing integer value '" << val << "': " << interr; return -EINVAL; } - if (!osdmap.crush->rule_exists(n)) { + if (!osdmap.crush->ruleset_exists(n)) { ss << "crush ruleset " << n << " does not exist"; return -ENOENT; }