summaryrefslogtreecommitdiff
path: root/source3/lib/tdb/common/io.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-01-11 15:08:37 -0800
committerJeremy Allison <jra@samba.org>2008-01-11 15:08:37 -0800
commit2ec41571a3efbea254cc3e132280a194c86a2f89 (patch)
treecc324e5f6cabfb4e017dfe021afd95cdd2738995 /source3/lib/tdb/common/io.c
parent9cd74303478ac15b4357fb7f76d9576fe9a060a1 (diff)
downloadsamba-2ec41571a3efbea254cc3e132280a194c86a2f89.tar.gz
samba-2ec41571a3efbea254cc3e132280a194c86a2f89.tar.bz2
samba-2ec41571a3efbea254cc3e132280a194c86a2f89.zip
Sync tdb with the tdb changes in ctdb. Spoke to tridge about
this. Fixes insidious problem with order n^2 freelist merging. Jeremy. (This used to be commit c6609c042b128e7d63eb64cfdfb0f6b65cb59d76)
Diffstat (limited to 'source3/lib/tdb/common/io.c')
-rw-r--r--source3/lib/tdb/common/io.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/source3/lib/tdb/common/io.c b/source3/lib/tdb/common/io.c
index 8ab0768883..172ab69d8c 100644
--- a/source3/lib/tdb/common/io.c
+++ b/source3/lib/tdb/common/io.c
@@ -101,8 +101,8 @@ static int tdb_write(struct tdb_context *tdb, tdb_off_t off,
off+written);
}
if (written == -1) {
- /* Ensure ecode is set for log fn. */
- tdb->ecode = TDB_ERR_IO;
+ /* Ensure ecode is set for log fn. */
+ tdb->ecode = TDB_ERR_IO;
TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_write failed at %d "
"len=%d (%s)\n", off, len, strerror(errno)));
return TDB_ERRCODE(TDB_ERR_IO, -1);
@@ -111,8 +111,8 @@ static int tdb_write(struct tdb_context *tdb, tdb_off_t off,
"write %d bytes at %d in two attempts\n",
len, off));
errno = ENOSPC;
- return TDB_ERRCODE(TDB_ERR_IO, -1);
- }
+ return TDB_ERRCODE(TDB_ERR_IO, -1);
+ }
}
return 0;
}
@@ -230,7 +230,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;
@@ -294,7 +294,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"));
@@ -304,9 +304,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 10 more records, and round
- the database up to a multiple of the page size */
- size = TDB_ALIGN(tdb->map_size + size*10, 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);