tdb2: copy tdb1's changed expansion logic.
[ccan] / ccan / tdb2 / transaction.c
index 70e664fc2d60e5fe36bda442607fbdfba04677ff..dd94510c027343d1c6aac0e6ec0d6e3d28ffeaab 100644 (file)
@@ -836,10 +836,13 @@ static tdb_off_t create_recovery_area(struct tdb_context *tdb,
 
        /* round up to a multiple of page size. Overallocate, since each
         * such allocation forces us to expand the file. */
 
        /* round up to a multiple of page size. Overallocate, since each
         * such allocation forces us to expand the file. */
-       rec->max_len
-               = (((sizeof(*rec) + rec_length + rec_length / 2)
-                   + PAGESIZE-1) & ~(PAGESIZE-1))
+       rec->max_len = tdb_expand_adjust(tdb->file->map_size, rec_length);
+
+       /* Round up to a page. */
+       rec->max_len = ((sizeof(*rec) + rec->max_len + PAGESIZE-1)
+                       & ~(PAGESIZE-1))
                - sizeof(*rec);
                - sizeof(*rec);
+
        off = tdb->file->map_size;
 
        /* Restore ->map_size before calling underlying expand_file.
        off = tdb->file->map_size;
 
        /* Restore ->map_size before calling underlying expand_file.