]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
handle ids greater that max_buckets
authorMichael Rodriguez <michael@newdream.net>
Fri, 7 Mar 2008 23:39:18 +0000 (15:39 -0800)
committerSage Weil <sage@newdream.net>
Thu, 20 Mar 2008 01:19:36 +0000 (18:19 -0700)
src/crush/builder.c

index c1a8e23cd0e6f6b1a75b2eb7acfdcdb5e36df9b9..ca5f809819cda20d52ece0f2a865bb326f90549f 100644 (file)
@@ -120,7 +120,7 @@ int crush_add_bucket(struct crush_map *map,
                id = crush_get_next_bucket_id(map);
        pos = -1 - id;
 
-       if (pos == map->max_buckets) {
+       while (pos > map->max_buckets) {
                /* expand array */
                oldsize = map->max_buckets;
                if (map->max_buckets)
@@ -130,11 +130,13 @@ int crush_add_bucket(struct crush_map *map,
                map->buckets = realloc(map->buckets, map->max_buckets * sizeof(map->buckets[0]));
                memset(map->buckets + oldsize, 0, (map->max_buckets-oldsize) * sizeof(map->buckets[0]));
        }
+
        assert(map->buckets[pos] == 0);
 
-       /* add it */
+       /* add it */
        bucket->id = id;
        map->buckets[pos] = bucket;
+
        return id;
 }