X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Ftransaction.c;h=f1414391abe42caa7b81504dede1ea3700291c1b;hb=024a5647e6c81735a93d826b56db0db4bf86fab8;hp=e6eb1c0b5c413670b49be51d99f579e5fdad3be0;hpb=5c4a21ab03a428373e7659b9606facf85dcbe17b;p=ccan diff --git a/ccan/tdb2/transaction.c b/ccan/tdb2/transaction.c index e6eb1c0b..f1414391 100644 --- a/ccan/tdb2/transaction.c +++ b/ccan/tdb2/transaction.c @@ -689,7 +689,7 @@ static enum TDB_ERROR tdb_recovery_allocate(struct tdb_context *tdb, tdb->stats.frees++; ecode = add_free_record(tdb, recovery_head, sizeof(rec) + rec.max_len, - TDB_LOCK_WAIT); + TDB_LOCK_WAIT, true); if (ecode != TDB_SUCCESS) { return tdb_logerr(tdb, ecode, TDB_LOG_ERROR, "tdb_recovery_allocate:" @@ -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;