]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: don't BUG_ON within crush_choose
authorAlexandre Oliva <oliva@lsd.ic.unicamp.br>
Mon, 6 Feb 2012 18:32:53 +0000 (10:32 -0800)
committerSage Weil <sage@newdream.net>
Mon, 6 Feb 2012 18:33:08 +0000 (10:33 -0800)
It's very hard to recover from an invalid crushmap if mons fail
assertions while processing the map, and osds crash while advancing
past an already-fixed map.  Skip such broken rules instead of
aborting.

Signed-off-by: Alexandre Oliva <oliva@lsd.ic.unicamp.br>
src/crush/mapper.c

index 1e475b4020e61c3058a399c5eb5d145da907ec35..b3f78cf727bfe39f3ad1936bbbc8b0d9617f3144 100644 (file)
@@ -354,7 +354,11 @@ static int crush_choose(const struct crush_map *map,
                                        item = bucket_perm_choose(in, x, r);
                                else
                                        item = crush_bucket_choose(in, x, r);
-                               BUG_ON(item >= map->max_devices);
+                               if (item >= map->max_devices) {
+                                       dprintk("   bad item %d\n", item);
+                                       skip_rep = 1;
+                                       break;
+                               }
 
                                /* desired type? */
                                if (item < 0)
@@ -365,8 +369,12 @@ static int crush_choose(const struct crush_map *map,
 
                                /* keep going? */
                                if (itemtype != type) {
-                                       BUG_ON(item >= 0 ||
-                                              (-1-item) >= map->max_buckets);
+                                       if (item >= 0 ||
+                                           (-1-item) >= map->max_buckets) {
+                                               dprintk("   bad item type %d\n", type);
+                                               skip_rep = 1;
+                                               break;
+                                       }
                                        in = map->buckets[-1-item];
                                        retry_bucket = 1;
                                        continue;