From 4ee43dbd477140bd4bf6c42d156dc0a736994da2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 6 Apr 2006 22:31:45 +0000 Subject: r14954: Fix #3569 based on William Jojo's work. AIX also has the linear posix locking issue which causes CLEAR_IF_FIRST to cause performance problems. As we know we're in a daemon architecture with long-lived parent we can avoid this in the Samba case. Add a comment explaining this. Jeremy. (This used to be commit 3cd5c3df0d1b98dfa90663973ab13b5d3dbf737e) --- source3/tdb/tdb.c | 18 +++++++++++++++++- source3/tdb/tdb.h | 2 +- source3/tdb/tdbtorture.c | 4 ++-- 3 files changed, 20 insertions(+), 4 deletions(-) (limited to 'source3/tdb') diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c index 4303976087..ad73a1d9aa 100644 --- a/source3/tdb/tdb.c +++ b/source3/tdb/tdb.c @@ -2098,11 +2098,27 @@ fail: } /* reopen all tdb's */ -int tdb_reopen_all(void) +int tdb_reopen_all(int parent_longlived) { TDB_CONTEXT *tdb; for (tdb=tdbs; tdb; tdb = tdb->next) { + /* + * If the parent is longlived (ie. a + * parent daemon architecture), we know + * it will keep it's active lock on a + * tdb opened with CLEAR_IF_FIRST. Thus + * for child processes we don't have to + * add an active lock. This is essential + * to improve performance on systems that + * keep POSIX locks as a non-scalable data + * structure in the kernel. + */ + if (parent_longlived) { + /* Ensure no clear-if-first. */ + tdb->flags &= ~TDB_CLEAR_IF_FIRST; + } + if (tdb_reopen(tdb) != 0) return -1; } diff --git a/source3/tdb/tdb.h b/source3/tdb/tdb.h index d1c976cd56..b5b87ee5a5 100644 --- a/source3/tdb/tdb.h +++ b/source3/tdb/tdb.h @@ -128,7 +128,7 @@ TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags, tdb_hash_func hash_fn); int tdb_reopen(TDB_CONTEXT *tdb); -int tdb_reopen_all(void); +int tdb_reopen_all(int); void tdb_logging_function(TDB_CONTEXT *tdb, tdb_log_func); enum TDB_ERROR tdb_error(TDB_CONTEXT *tdb); const char *tdb_errorstr(TDB_CONTEXT *tdb); diff --git a/source3/tdb/tdbtorture.c b/source3/tdb/tdbtorture.c index d03cc2a610..2d367b91e1 100644 --- a/source3/tdb/tdbtorture.c +++ b/source3/tdb/tdbtorture.c @@ -103,7 +103,7 @@ static void addrec_db(void) #if REOPEN_PROB if (random() % REOPEN_PROB == 0) { - tdb_reopen_all(); + tdb_reopen_all(1); goto next; } #endif @@ -192,7 +192,7 @@ int main(int argc, char *argv[]) for (i=0;i