]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: pool set <pool> crush_ruleset must not use rule_exists 1994/head
authorJohn Spray <john.spray@inktank.com>
Tue, 20 May 2014 15:50:18 +0000 (16:50 +0100)
committerLoic Dachary <loic@dachary.org>
Thu, 19 Jun 2014 09:19:05 +0000 (11:19 +0200)
Implement CrushWrapper::ruleset_exists that iterates over the existing
rulesets to find the one matching the ruleset argument.

ceph osd pool set <pool> 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 <john.spray@inktank.com>
Signed-off-by: Loic Dachary <loic@dachary.org>
(cherry picked from commit d02d46e25080d5f7bb8ddd4874d9019a078b816b)

Conflicts:
src/mon/OSDMonitor.cc

qa/workunits/cephtool/test.sh
src/crush/CrushWrapper.h
src/mon/OSDMonitor.cc

index 125ff3d7096664a00aea288d103e689c2d333296..0f77747c7ea36dbace124ff11001fa41ebacf995 100755 (executable)
@@ -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 <<EOF
+rule testrule1 {
+       ruleset $RULESET
+       type replicated
+       min_size 1
+       max_size 10
+       step take default
+       step choose firstn 0 type osd
+       step emit
+}
+EOF
+crushtool --compile $MAP.decompiled -o $MAP.modified
+ceph osd setcrushmap -i $MAP.modified
+ceph osd pool set data crush_ruleset $RULESET
+ceph osd pool set data crush_ruleset 0
+rm $MAP{,.decompiled,.modified}
 
 # tiering
 ceph osd pool create cache 2
index b4bb67bb7429b16b2125e153391a53e291a1ca3e..17f61e2cf562215783b12092780d70417188010c 100644 (file)
@@ -760,6 +760,17 @@ public:
     if (!crush) return -1;
     return crush_find_rule(crush, ruleset, type, size);
   }
+
+  bool ruleset_exists(int ruleset) const {
+    for (size_t i = 0; i < crush->max_rules; ++i) {
+     if (crush->rules[i]->mask.ruleset == ruleset) {
+       return true;
+     }
+    }
+
+    return false;
+  }
+
   void do_rule(int rule, int x, vector<int>& out, int maxout,
               const vector<__u32>& weight) const {
     Mutex::Locker l(mapper_lock);
index 7af35abf4e01cb6accbe248ebc469b51f5cce934..7c4df357c777f58b88827602d951ba4c127e075b 100644 (file)
@@ -2861,7 +2861,7 @@ int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
       ss << "error parsing integer value '" << raw_val << "': " << interr;
       return -EINVAL;
     }
-    if (osdmap.crush->rule_exists(n)) {
+    if (osdmap.crush->ruleset_exists(n)) {
       p.crush_ruleset = n;
       ss << "set pool " << pool << " crush_ruleset to " << n;
     } else {