From db2508840d55842ebaf0c0d7a2fa3c855498e75f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 18 Jun 2012 22:30:29 +0930 Subject: ntdb: create initial database to be multiple of NTDB_PGSIZE. As copied from tdb1, there is logic in the transaction code to handle a non-PGSIZE multiple db, but in fact this only happens for a completely unused database: as soon as we add anything to it, it is expanded to a NTDB_PGSIZE multiple. If we create the database with a free record which pads it out to NTDB_PGSIZE, we can remove this last-page-is-different logic. Of course, the fake ntdbs we create in our tests now also need to be multiples of NTDB_PGSIZE, so we change some numbers there too. Signed-off-by: Rusty Russell --- lib/ntdb/test/run-capabilities.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/ntdb/test/run-capabilities.c') diff --git a/lib/ntdb/test/run-capabilities.c b/lib/ntdb/test/run-capabilities.c index c2c6aa15db..52c4fac0e6 100644 --- a/lib/ntdb/test/run-capabilities.c +++ b/lib/ntdb/test/run-capabilities.c @@ -29,7 +29,7 @@ static void create_ntdb(const char *name, va_list ap; struct ntdb_layout *layout; struct ntdb_context *ntdb; - int fd; + int fd, clen; key = ntdb_mkdata("Hello", 5); data = ntdb_mkdata("world", 5); @@ -38,10 +38,11 @@ static void create_ntdb(const char *name, layout = new_ntdb_layout(); ntdb_layout_add_freetable(layout); ntdb_layout_add_used(layout, key, data, 6); - ntdb_layout_add_free(layout, 80, 0); + clen = len_of(breaks_check, breaks_write, breaks_open); + ntdb_layout_add_free(layout, 56480 - clen, 0); ntdb_layout_add_capability(layout, cap, - breaks_write, breaks_check, breaks_open, - len_of(breaks_check, breaks_write, breaks_open)); + breaks_write, breaks_check, breaks_open, + clen); va_start(ap, breaks_open); while ((cap = va_arg(ap, int)) != 0) { @@ -51,12 +52,11 @@ static void create_ntdb(const char *name, key.dsize--; ntdb_layout_add_used(layout, key, data, 11 - key.dsize); - ntdb_layout_add_free(layout, 80, 0); + clen = len_of(breaks_check, breaks_write, breaks_open); + ntdb_layout_add_free(layout, 65456 - clen, 0); ntdb_layout_add_capability(layout, cap, breaks_write, breaks_check, - breaks_open, - len_of(breaks_check, breaks_write, - breaks_open)); + breaks_open, clen); } va_end(ap); -- cgit