[PATCH 4/4] schannel Change to TDB_CLEAR_IF_FIRST to reduce fsync()

Andrew Bartlett abartlet at samba.org
Tue Jun 22 18:37:13 MDT 2010


By making this DB TDB_NOSYNC, and by making that safe with
TDB_CLEAR_IF_FIRST, we greatly reduce the fsync() load on the server.

This particularly helps the source4/ 'make test', which otherwise tries
to disable fsync() in ldb.

Andrew Bartlett
---
 libcli/auth/schannel_state_tdb.c |   33 +--------------------------------
 1 files changed, 1 insertions(+), 32 deletions(-)

diff --git a/libcli/auth/schannel_state_tdb.c b/libcli/auth/schannel_state_tdb.c
index 0e4ab06..0dcc336 100644
--- a/libcli/auth/schannel_state_tdb.c
+++ b/libcli/auth/schannel_state_tdb.c
@@ -42,8 +42,6 @@
 struct tdb_wrap *open_schannel_session_store(TALLOC_CTX *mem_ctx,
 					     const char *private_dir)
 {
-	TDB_DATA vers;
-	uint32_t ver;
 	struct tdb_wrap *tdb_sc = NULL;
 	char *fname = talloc_asprintf(mem_ctx, "%s/schannel_store.tdb", private_dir);
 
@@ -51,7 +49,7 @@ struct tdb_wrap *open_schannel_session_store(TALLOC_CTX *mem_ctx,
 		return NULL;
 	}
 
-	tdb_sc = tdb_wrap_open(mem_ctx, fname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+	tdb_sc = tdb_wrap_open(mem_ctx, fname, 0, TDB_CLEAR_IF_FIRST|TDB_NOSYNC, O_RDWR|O_CREAT, 0600);
 
 	if (!tdb_sc) {
 		DEBUG(0,("open_schannel_session_store: Failed to open %s - %s\n",
@@ -60,35 +58,6 @@ struct tdb_wrap *open_schannel_session_store(TALLOC_CTX *mem_ctx,
 		return NULL;
 	}
 
- again:
-	vers = tdb_fetch_bystring(tdb_sc->tdb, "SCHANNEL_STORE_VERSION");
-	if (vers.dptr == NULL) {
-		/* First opener, no version. */
-		SIVAL(&ver,0,SCHANNEL_STORE_VERSION_CURRENT);
-		vers.dptr = (uint8_t *)&ver;
-		vers.dsize = 4;
-		tdb_store_bystring(tdb_sc->tdb, "SCHANNEL_STORE_VERSION", vers, TDB_REPLACE);
-		vers.dptr = NULL;
-	} else if (vers.dsize == 4) {
-		ver = IVAL(vers.dptr,0);
-		if (ver == SCHANNEL_STORE_VERSION_2) {
-			DEBUG(0,("open_schannel_session_store: wrong version number %d in %s\n",
-				(int)ver, fname ));
-			tdb_wipe_all(tdb_sc->tdb);
-			goto again;
-		}
-		if (ver != SCHANNEL_STORE_VERSION_CURRENT) {
-			DEBUG(0,("open_schannel_session_store: wrong version number %d in %s\n",
-				(int)ver, fname ));
-			TALLOC_FREE(tdb_sc);
-		}
-	} else {
-		TALLOC_FREE(tdb_sc);
-		DEBUG(0,("open_schannel_session_store: wrong version number size %d in %s\n",
-			(int)vers.dsize, fname ));
-	}
-
-	SAFE_FREE(vers.dptr);
 	TALLOC_FREE(fname);
 
 	return tdb_sc;
-- 
1.7.0.1


--=-2A0ML4+U++I4Wmz4q2Yf--



More information about the samba-technical mailing list