diff options
author | Andrew Tridgell <tridge@samba.org> | 2008-01-05 09:30:09 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2008-01-05 09:30:09 +1100 |
commit | 9ea20f3916d7dd9656e1a660f64db761f6fc32e0 (patch) | |
tree | fb027b5b2f8ba56915b670171a1a37845b326bac /ctdb | |
parent | 8a10bc656162ea2affaddff9b18193408f581b93 (diff) | |
download | samba-9ea20f3916d7dd9656e1a660f64db761f6fc32e0.tar.gz samba-9ea20f3916d7dd9656e1a660f64db761f6fc32e0.tar.xz samba-9ea20f3916d7dd9656e1a660f64db761f6fc32e0.zip |
expand tdb by minimum of 25% at a time
(This used to be ctdb commit 355575878e2b6e85268ca8387f41a19bcd9db651)
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/lib/tdb/common/io.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ctdb/lib/tdb/common/io.c b/ctdb/lib/tdb/common/io.c index 0c70603a59..2f0a9a082e 100644 --- a/ctdb/lib/tdb/common/io.c +++ b/ctdb/lib/tdb/common/io.c @@ -211,7 +211,7 @@ void tdb_mmap(struct tdb_context *tdb) says to use for mmap expansion */ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t addition) { - char buf[1024]; + char buf[8192]; if (tdb->read_only || tdb->traverse_read) { tdb->ecode = TDB_ERR_RDONLY; @@ -251,7 +251,7 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad int tdb_expand(struct tdb_context *tdb, tdb_off_t size) { struct list_struct rec; - tdb_off_t offset; + tdb_off_t offset, new_size; if (tdb_lock(tdb, -1, F_WRLCK) == -1) { TDB_LOG((tdb, TDB_DEBUG_ERROR, "lock failed in tdb_expand\n")); @@ -261,9 +261,11 @@ int tdb_expand(struct tdb_context *tdb, tdb_off_t size) /* must know about any previous expansions by another process */ tdb->methods->tdb_oob(tdb, tdb->map_size + 1, 1); - /* always make room for at least 100 more records, and round - the database up to a multiple of the page size */ - size = TDB_ALIGN(tdb->map_size + size*100, tdb->page_size) - tdb->map_size; + /* always make room for at least 100 more records, and at + least 25% more space. Round the database up to a multiple + of the page size */ + new_size = MAX(tdb->map_size + size*100, tdb->map_size * 1.25); + size = TDB_ALIGN(new_size, tdb->page_size) - tdb->map_size; if (!(tdb->flags & TDB_INTERNAL)) tdb_munmap(tdb); |