[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Mon Dec 19 16:41:01 UTC 2022


The branch, master has been updated
       via  87fddbad78d smbd/locking: make use of the same tdb hash_size and flags for all SMB related tdb's
      from  07617a344e1 s4-auth: fix sam test binary ntstatus include path

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 87fddbad78d9a9f6fe922efb7a87ded01996d6ec
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jun 17 07:36:01 2019 -0700

    smbd/locking: make use of the same tdb hash_size and flags for all SMB related tdb's
    
    It's good to have a consistent set of hash_size/flags for all aspects of
    an open file handle. Currently we're using 4 databases:
    smbXsrv_open_global.tdb, leases.tdb, locking.tdb and brlock.tdb.
    
    While at it also crank up the hashsize if the smbXsrv_tcon and smbXsrv_session
    TDBs. The default TDB hash size is insanely small and disk space is cheap these
    days, by going with the much larger hash size we get O(1) lookup instead of O(n)
    for moderate to large loads with a few thousand objects.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Mon Dec 19 16:40:15 UTC 2022 on sn-devel-184

-----------------------------------------------------------------------

Summary of changes:
 source3/include/local.h           |  8 ++++++--
 source3/locking/brlock.c          |  9 ++-------
 source3/locking/leases_db.c       | 10 ++++------
 source3/locking/share_mode_lock.c |  7 ++-----
 source3/smbd/smbXsrv_open.c       |  7 ++-----
 source3/smbd/smbXsrv_session.c    |  7 ++-----
 source3/smbd/smbXsrv_tcon.c       |  7 ++-----
 7 files changed, 20 insertions(+), 35 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/local.h b/source3/include/local.h
index 297e5572fdb..db53698ec44 100644
--- a/source3/include/local.h
+++ b/source3/include/local.h
@@ -173,8 +173,12 @@
 
 #define MAX_LDAP_REPLICATION_SLEEP_TIME 5000 /* In milliseconds. */
 
-/* tdb hash size for the open database. */
-#define SMB_OPEN_DATABASE_TDB_HASH_SIZE 10007
+/* tdb hash size for the databases having one entry per open file. */
+#define SMBD_VOLATILE_TDB_HASH_SIZE 10007
+
+/* tdb flags for the databases having one entry per open file. */
+#define SMBD_VOLATILE_TDB_FLAGS \
+	(TDB_DEFAULT|TDB_VOLATILE|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH)
 
 /* Characters we disallow in sharenames. */
 #define INVALID_SHARENAME_CHARS "%<>*?|/\\+=;:\","
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index d2e4abf48d7..d065c7fe03e 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -369,12 +369,7 @@ void brl_init(bool read_only)
 		return;
 	}
 
-	tdb_flags =
-		TDB_DEFAULT|
-		TDB_VOLATILE|
-		TDB_CLEAR_IF_FIRST|
-		TDB_INCOMPATIBLE_HASH|
-		TDB_SEQNUM;
+	tdb_flags = SMBD_VOLATILE_TDB_FLAGS | TDB_SEQNUM;
 
 	db_path = lock_path(talloc_tos(), "brlock.tdb");
 	if (db_path == NULL) {
@@ -383,7 +378,7 @@ void brl_init(bool read_only)
 	}
 
 	brlock_db = db_open(NULL, db_path,
-			    SMB_OPEN_DATABASE_TDB_HASH_SIZE, tdb_flags,
+			    SMBD_VOLATILE_TDB_HASH_SIZE, tdb_flags,
 			    read_only?O_RDONLY:(O_RDWR|O_CREAT), 0644,
 			    DBWRAP_LOCK_ORDER_2, DBWRAP_FLAG_NONE);
 	if (!brlock_db) {
diff --git a/source3/locking/leases_db.c b/source3/locking/leases_db.c
index 855d6143ad7..eae58f5fc82 100644
--- a/source3/locking/leases_db.c
+++ b/source3/locking/leases_db.c
@@ -46,12 +46,10 @@ bool leases_db_init(bool read_only)
 		return false;
 	}
 
-	leases_db = db_open(NULL, db_path, 0,
-			    TDB_DEFAULT|
-			    TDB_VOLATILE|
-			    TDB_CLEAR_IF_FIRST|
-			    TDB_SEQNUM|
-			    TDB_INCOMPATIBLE_HASH,
+	leases_db = db_open(NULL, db_path,
+			    SMBD_VOLATILE_TDB_HASH_SIZE,
+			    SMBD_VOLATILE_TDB_FLAGS |
+			    TDB_SEQNUM,
 			    read_only ? O_RDONLY : O_RDWR|O_CREAT, 0644,
 			    DBWRAP_LOCK_ORDER_4, DBWRAP_FLAG_NONE);
 	TALLOC_FREE(db_path);
diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c
index 909bfdfbcce..e123084677d 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -125,11 +125,8 @@ static bool locking_init_internal(bool read_only)
 	}
 
 	backend = db_open(NULL, db_path,
-			  SMB_OPEN_DATABASE_TDB_HASH_SIZE,
-			  TDB_DEFAULT|
-			  TDB_VOLATILE|
-			  TDB_CLEAR_IF_FIRST|
-			  TDB_INCOMPATIBLE_HASH|
+			  SMBD_VOLATILE_TDB_HASH_SIZE,
+			  SMBD_VOLATILE_TDB_FLAGS |
 			  TDB_SEQNUM,
 			  read_only?O_RDONLY:O_RDWR|O_CREAT, 0644,
 			  DBWRAP_LOCK_ORDER_NONE,
diff --git a/source3/smbd/smbXsrv_open.c b/source3/smbd/smbXsrv_open.c
index 91f2f8a83cd..366a35b1e2f 100644
--- a/source3/smbd/smbXsrv_open.c
+++ b/source3/smbd/smbXsrv_open.c
@@ -64,11 +64,8 @@ NTSTATUS smbXsrv_open_global_init(void)
 	}
 
 	db_ctx = db_open(NULL, global_path,
-			 0, /* hash_size */
-			 TDB_DEFAULT |
-			 TDB_CLEAR_IF_FIRST |
-			 TDB_VOLATILE |
-			 TDB_INCOMPATIBLE_HASH,
+			 SMBD_VOLATILE_TDB_HASH_SIZE,
+			 SMBD_VOLATILE_TDB_FLAGS,
 			 O_RDWR | O_CREAT, 0600,
 			 DBWRAP_LOCK_ORDER_1,
 			 DBWRAP_FLAG_NONE);
diff --git a/source3/smbd/smbXsrv_session.c b/source3/smbd/smbXsrv_session.c
index cf09b56803a..57ec395186c 100644
--- a/source3/smbd/smbXsrv_session.c
+++ b/source3/smbd/smbXsrv_session.c
@@ -74,11 +74,8 @@ NTSTATUS smbXsrv_session_global_init(struct messaging_context *msg_ctx)
 	}
 
 	backend = db_open(NULL, global_path,
-			  0, /* hash_size */
-			  TDB_DEFAULT |
-			  TDB_CLEAR_IF_FIRST |
-			  TDB_VOLATILE |
-			  TDB_INCOMPATIBLE_HASH,
+			  SMBD_VOLATILE_TDB_HASH_SIZE,
+			  SMBD_VOLATILE_TDB_FLAGS,
 			  O_RDWR | O_CREAT, 0600,
 			  DBWRAP_LOCK_ORDER_1,
 			  DBWRAP_FLAG_NONE);
diff --git a/source3/smbd/smbXsrv_tcon.c b/source3/smbd/smbXsrv_tcon.c
index 0aa35602b6c..1ee1bbba4f3 100644
--- a/source3/smbd/smbXsrv_tcon.c
+++ b/source3/smbd/smbXsrv_tcon.c
@@ -61,11 +61,8 @@ NTSTATUS smbXsrv_tcon_global_init(void)
 	}
 
 	db_ctx = db_open(NULL, global_path,
-			 0, /* hash_size */
-			 TDB_DEFAULT |
-			 TDB_CLEAR_IF_FIRST |
-			 TDB_VOLATILE |
-			 TDB_INCOMPATIBLE_HASH,
+			 SMBD_VOLATILE_TDB_HASH_SIZE,
+			 SMBD_VOLATILE_TDB_FLAGS,
 			 O_RDWR | O_CREAT, 0600,
 			 DBWRAP_LOCK_ORDER_1,
 			 DBWRAP_FLAG_NONE);


-- 
Samba Shared Repository



More information about the samba-cvs mailing list