]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: pool set <pool> crush_ruleset must not use rule_exists 1962/head
authorJohn Spray <john.spray@inktank.com>
Tue, 20 May 2014 15:50:18 +0000 (16:50 +0100)
committerLoic Dachary <loic@dachary.org>
Sat, 14 Jun 2014 10:56:59 +0000 (12:56 +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>
qa/workunits/cephtool/test.sh
src/crush/CrushWrapper.h
src/mon/OSDMonitor.cc

index d5e9cef486f6099dfc28dd52e6296c18a95d40f7..80f3f4c2269bbaf7e5ca3f67a3bb6a2c2f87a9cf 100755 (executable)
@@ -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 <<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 3b2e6e6979ac3cc00201fd5b71984c5d2cfbf1d7..011366265a159da8dfacb03c948e3267c7061f71 100644 (file)
@@ -863,6 +863,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 1ed3a95ef30de4827f5128b838768a9b8bbca293..a4dcc58489da35c61a24de9e8564225dde3c6290 100644 (file)
@@ -3411,7 +3411,7 @@ int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &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;
     }