From c34008532362c3afadff6287bc8746c141a221a3 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 (cherry picked from commit d02d46e25080d5f7bb8ddd4874d9019a078b816b) Conflicts: src/mon/OSDMonitor.cc --- 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 b832f53126d..719e267971c 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -46,6 +46,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 2431fa84d12..48d9e6c2d7d 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -3669,7 +3669,7 @@ done: ss << "set pool " << pool << " pgp_num to " << n; } } else if (var == "crush_ruleset") { - if (osdmap.crush->rule_exists(n)) { + if (osdmap.crush->ruleset_exists(n)) { pending_inc.new_pools[pool].crush_ruleset = n; ss << "set pool " << pool << " crush_ruleset to " << n; } else { -- 2.47.3