tdb2: fix bucket search
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 17 Nov 2010 10:00:07 +0000 (20:30 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 17 Nov 2010 10:00:07 +0000 (20:30 +1030)
We were previously jumping straight from the first bucket to the end.

ccan/tdb2/free.c

index 48cd9c315ce02f4859ea15b0ec6de97ccde132d5..f5107fadfbd888efae8094b1ff8d3cc4010c3ca8 100644 (file)
@@ -559,7 +559,7 @@ static tdb_off_t get_free(struct tdb_context *tdb,
                b = size_to_bucket(tdb->zhdr.zone_bits, size);
                for (b = find_free_head(tdb, b);
                     b <= BUCKETS_FOR_ZONE(tdb->zhdr.zone_bits);
                b = size_to_bucket(tdb->zhdr.zone_bits, size);
                for (b = find_free_head(tdb, b);
                     b <= BUCKETS_FOR_ZONE(tdb->zhdr.zone_bits);
-                    b += find_free_head(tdb, b + 1)) {
+                    b = find_free_head(tdb, b + 1)) {
                        /* Try getting one from list. */
                        off = lock_and_alloc(tdb, tdb->zone_off,
                                             tdb->zhdr.zone_bits,
                        /* Try getting one from list. */
                        off = lock_and_alloc(tdb, tdb->zone_off,
                                             tdb->zhdr.zone_bits,