]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: fix force to behave with non-root TAKE
authorSage Weil <sage@newdream.net>
Wed, 7 Dec 2011 17:07:38 +0000 (09:07 -0800)
committerSage Weil <sage@newdream.net>
Mon, 12 Dec 2011 17:18:46 +0000 (09:18 -0800)
If the (first) TAKE in the crush rule is not the root, see if they picked
a point somewhere beneath the appropriate part of the hierachy.  If not,
continue with a normal mapping.

Previously we would simply error out in this case and map nothing.

Signed-off-by: Sage Weil <sage@newdream.net>
src/crush/mapper.c

index 52ece9c5a899d9aef9e2c588c96242e51a488a9e..79a9814ceb6ca048c80658a305640e4e1bcad57c 100644 (file)
@@ -489,7 +489,8 @@ int crush_do_rule(const struct crush_map *map,
        /*
         * determine hierarchical context of force, if any.  note
         * that this may or may not correspond to the specific types
-        * referenced by the crush rule.
+        * referenced by the crush rule.  it will also only affect
+        * the first descent (TAKE).
         */
        if (force >= 0 &&
            force < map->max_devices &&
@@ -511,13 +512,14 @@ int crush_do_rule(const struct crush_map *map,
                switch (rule->steps[step].op) {
                case CRUSH_RULE_TAKE:
                        w[0] = rule->steps[step].arg1;
-                       if (force_pos >= 0) {
-                               if (force_context[force_pos] != w[0]) {
-                                       rc = -1;  /* forced mapping dne */
-                                       goto out;
-                               }
+
+                       /* find position in force_context/hierarchy */
+                       while (force_pos >= 0 && force_context[force_pos] != w[0])
                                force_pos--;
-                       }
+                       /* and move past it */
+                       if (force_pos >= 0)
+                               force_pos--;
+
                        wsize = 1;
                        break;