X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;ds=sidebyside;f=ccan%2Ftdb2%2Ftransaction.c;h=a27c027365eec3fc7be001d9693bde42ec6f0b45;hb=a8b30ad4dcea31c68ca809d2a6e6e4c7c6c30398;hp=e6eb1c0b5c413670b49be51d99f579e5fdad3be0;hpb=5c4a21ab03a428373e7659b9606facf85dcbe17b;p=ccan diff --git a/ccan/tdb2/transaction.c b/ccan/tdb2/transaction.c index e6eb1c0b..a27c0273 100644 --- a/ccan/tdb2/transaction.c +++ b/ccan/tdb2/transaction.c @@ -701,10 +701,11 @@ static enum TDB_ERROR tdb_recovery_allocate(struct tdb_context *tdb, /* the tdb_free() call might have increased the recovery size */ *recovery_size = tdb_recovery_size(tdb); - /* round up to a multiple of page size */ + /* round up to a multiple of page size. Overallocate, since each + * such allocation forces us to expand the file. */ *recovery_max_size - = (((sizeof(rec) + *recovery_size) + PAGESIZE-1) - & ~(PAGESIZE-1)) + = (((sizeof(rec) + *recovery_size + *recovery_size / 2) + + PAGESIZE-1) & ~(PAGESIZE-1)) - sizeof(rec); *recovery_offset = tdb->file->map_size; recovery_head = *recovery_offset;