From d02d46e25080d5f7bb8ddd4874d9019a078b816b Mon Sep 17 00:00:00 2001 From: John Spray Date: Tue, 20 May 2014 16:50:18 +0100 Subject: [PATCH] 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 --- qa/workunits/cephtool/test.sh | 25 +++++++++++++++++++++++++ src/crush/CrushWrapper.h | 11 +++++++++++ src/mon/OSDMonitor.cc | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) 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; } -- 2.39.5