+ /* always make room for at least 100 more records, and at
+ least 25% more space. */
+ if (size * TDB_EXTENSION_FACTOR > tdb->map_size / 4)
+ wanted = size * TDB_EXTENSION_FACTOR;
+ else
+ wanted = tdb->map_size / 4;
+ wanted = adjust_size(0, wanted);
+
/* Only one person can expand file at a time. */
if (tdb_lock_expand(tdb, F_WRLCK) != 0)
return -1;
/* Only one person can expand file at a time. */
if (tdb_lock_expand(tdb, F_WRLCK) != 0)
return -1;
- if (tdb->methods->expand_file(tdb, wanted*TDB_EXTENSION_FACTOR) == -1) {
+ if (tdb->methods->expand_file(tdb, wanted) == -1) {
tdb_unlock_expand(tdb, F_WRLCK);
return -1;
}
tdb_unlock_expand(tdb, F_WRLCK);
return -1;
}
/* We need to drop this lock before adding free record. */
tdb_unlock_expand(tdb, F_WRLCK);
/* We need to drop this lock before adding free record. */
tdb_unlock_expand(tdb, F_WRLCK);
- return add_free_record(tdb, old_size, wanted * TDB_EXTENSION_FACTOR);
+ return add_free_record(tdb, old_size, wanted);
}
/* This won't fail: it will expand the database if it has to. */
}
/* This won't fail: it will expand the database if it has to. */
/* And 8 entries in each group, ie 8 groups per sublevel. */
#define TDB_HASH_GROUP_BITS 3
/* And 8 entries in each group, ie 8 groups per sublevel. */
#define TDB_HASH_GROUP_BITS 3
-/* Extend file by least 32 times larger than needed. */
-#define TDB_EXTENSION_FACTOR 32
+/* Extend file by least 100 times larger than needed. */
+#define TDB_EXTENSION_FACTOR 100
/* We steal bits from the offsets to store hash info. */
#define TDB_OFF_HASH_GROUP_MASK ((1ULL << TDB_HASH_GROUP_BITS) - 1)
/* We steal bits from the offsets to store hash info. */
#define TDB_OFF_HASH_GROUP_MASK ((1ULL << TDB_HASH_GROUP_BITS) - 1)