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