[PATCH] make gencache hash size configurable
Volker Lendecke
vl at samba.org
Fri Mar 3 10:14:34 UTC 2017
Hi!
Review appreciated!
Thanks, Volker
-------------- next part --------------
>From 627bafeb1e7165fbc51f5d2de3232bb528dbd0a5 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 6 Feb 2017 17:10:40 +0100
Subject: [PATCH] lib: Make gencache hash size configurable, default to 10000
For large deployments with many users, we put a lot of idmapping
entries into gencache. Increase the hash size from our default 131.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/gencache.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c
index 2c1704e..1572825 100644
--- a/source3/lib/gencache.c
+++ b/source3/lib/gencache.c
@@ -55,12 +55,15 @@ static bool gencache_init(void)
{
char* cache_fname = NULL;
int open_flags = O_RDWR|O_CREAT;
+ int hash_size;
/* skip file open if it's already opened */
if (cache) {
return true;
}
+ hash_size = lp_parm_int(-1, "gencache", "hash_size", 10000);
+
cache_fname = cache_path("gencache.tdb");
if (cache_fname == NULL) {
return false;
@@ -68,7 +71,7 @@ static bool gencache_init(void)
DEBUG(5, ("Opening cache file at %s\n", cache_fname));
- cache = tdb_wrap_open(NULL, cache_fname, 0,
+ cache = tdb_wrap_open(NULL, cache_fname, hash_size,
TDB_DEFAULT|TDB_INCOMPATIBLE_HASH,
open_flags, 0644);
if (cache) {
@@ -87,7 +90,7 @@ static bool gencache_init(void)
* CLEAR_IF_FIRST databases, so lets use it here to
* clean up a broken database.
*/
- cache = tdb_wrap_open(NULL, cache_fname, 0,
+ cache = tdb_wrap_open(NULL, cache_fname, hash_size,
TDB_DEFAULT|
TDB_INCOMPATIBLE_HASH|
TDB_CLEAR_IF_FIRST,
@@ -97,7 +100,7 @@ static bool gencache_init(void)
if (!cache && (errno == EACCES)) {
open_flags = O_RDONLY;
- cache = tdb_wrap_open(NULL, cache_fname, 0,
+ cache = tdb_wrap_open(NULL, cache_fname, hash_size,
TDB_DEFAULT|TDB_INCOMPATIBLE_HASH,
open_flags, 0644);
if (cache) {
@@ -119,7 +122,7 @@ static bool gencache_init(void)
DEBUG(5, ("Opening cache file at %s\n", cache_fname));
- cache_notrans = tdb_wrap_open(NULL, cache_fname, 0,
+ cache_notrans = tdb_wrap_open(NULL, cache_fname, hash_size,
TDB_CLEAR_IF_FIRST|
TDB_INCOMPATIBLE_HASH|
TDB_NOSYNC|
--
2.1.4
More information about the samba-technical
mailing list