From 5b22901fe65f005f720621e8c7f71d1b08e504de Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 25 Nov 2014 21:03:18 +0000 Subject: [PATCH 1/8] lib: Use tdb_parse_record in gencache_set Signed-off-by: Volker Lendecke Reviewed-by: Andreas Schneider Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Wed Nov 26 14:50:38 CET 2014 on sn-devel-104 (cherry picked from commit ec0c9ad0994d35e22ecc50e552d14582c51622b1) BUG: https://bugzilla.samba.org/show_bug.cgi?id=11032 --- source3/lib/gencache.c | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-) diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index 3e67d9e..2e9c496 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -240,6 +240,17 @@ static bool gencache_have_val(const char *keystr, const DATA_BLOB *data, return state.gotit; } +static int last_stabilize_parser(TDB_DATA key, TDB_DATA data, + void *private_data) +{ + time_t *last_stabilize = private_data; + + if ((data.dsize != 0) && (data.dptr[data.dsize-1] == '\0')) { + *last_stabilize = atoi((char *)data.dptr); + } + return 0; +} + /** * Set an entry in the cache file. If there's no such * one, then add it. @@ -256,7 +267,6 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, time_t timeout) { int ret; - TDB_DATA databuf; char* val; time_t last_stabilize; static int writecount; @@ -326,12 +336,10 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, */ last_stabilize = 0; - databuf = tdb_fetch_compat(cache_notrans, last_stabilize_key()); - if ((databuf.dptr != NULL) - && (databuf.dptr[databuf.dsize-1] == '\0')) { - last_stabilize = atoi((char *)databuf.dptr); - SAFE_FREE(databuf.dptr); - } + + tdb_parse_record(cache_notrans, last_stabilize_key(), + last_stabilize_parser, &last_stabilize); + if ((last_stabilize + lp_parm_int(-1, "gencache", "stabilize_interval", 300)) < time(NULL)) { -- 1.7.1 From 58ee254cee5b0378be7d505237ef2f15595251e4 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 26 Jun 2014 16:37:17 +0200 Subject: [PATCH 2/8] s3:gencache: fix logic in stabilization when deleting a record from stable cache Set state->written = true in the delete case if and only if the record has really been deleted. This does currently not seem to lead to an unneeded write to the DB, since failure to delete the record will cause the traverse and hence the transaction to cancel. But I think this is clearer. Signed-off-by: Michael Adam Reviewed-by: Christof Schmitt (cherry picked from commit 202ee81e869f4b51e1f904ef6ac3fb0030edfede) BUG: https://bugzilla.samba.org/show_bug.cgi?id=11032 --- source3/lib/gencache.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index 2e9c496..9f87c1f 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -707,10 +707,10 @@ static int stabilize_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val, } if ((timeout < time(NULL)) || (val.dsize == 0)) { res = tdb_delete(cache, key); - if ((res != 0) && (tdb_error(cache) == TDB_ERR_NOEXIST)) { - res = 0; - } else { + if (res == 0) { state->written = true; + } else if (tdb_error(cache) == TDB_ERR_NOEXIST) { + res = 0; } } else { res = tdb_store(cache, key, val, 0); -- 1.7.1 From f05daf49f49f58cc193dc293108e2f598d3a4eeb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 26 Jun 2014 16:56:41 +0200 Subject: [PATCH 3/8] s3:gencache: simply stabilize() a bit more: remove error from state state.error is set to true if and only if the traverse callback returns error (-1), and hence only if the traverse fails. Hence the the error state is redundant. Signed-off-by: Michael Adam Reviewed-by: Christof Schmitt (cherry picked from commit d240cf7894f076a2ed2b6bc434f20a93cfbb1ca4) BUG: https://bugzilla.samba.org/show_bug.cgi?id=11032 --- source3/lib/gencache.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-) diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index 9f87c1f..ed2b0be 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -603,7 +603,6 @@ fail: struct stabilize_state { bool written; - bool error; }; static int stabilize_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val, void *priv); @@ -649,11 +648,10 @@ bool gencache_stabilize(void) return false; } - state.error = false; state.written = false; res = tdb_traverse(cache_notrans, stabilize_fn, &state); - if ((res < 0) || state.error) { + if (res < 0) { tdb_transaction_cancel(cache_notrans); tdb_transaction_cancel(cache); return false; @@ -722,14 +720,12 @@ static int stabilize_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val, if (res != 0) { DEBUG(10, ("Transfer to gencache.tdb failed: %s\n", tdb_errorstr_compat(cache))); - state->error = true; return -1; } if (tdb_delete(cache_notrans, key) != 0) { DEBUG(10, ("tdb_delete from gencache_notrans.tdb failed: " "%s\n", tdb_errorstr_compat(cache_notrans))); - state->error = true; return -1; } return 0; -- 1.7.1 From 6aea023ce12da5326574e523d0d02d9f2f6290d5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 2 Jul 2014 07:44:04 +0200 Subject: [PATCH 4/8] s3:gencache: don't use transaction non non-persistent gencache_notrans.tdb gencache_notrans.tdb is a non-persistent cache layer above the persistent gencache.tdb. Despite its name, and despite the nature of non-persistent tdbs, the current stabilization code uses a transaction on gencache_notrans.tdb like this: transaction_start(cache) transaction_start(cache_notrans) traverse(cache_notrans, stabilize_fn) transaction_commit(cache) transaction_commit(cache_notrans) where stabilze_fn does this on a record: 1. store it to or delete it from cache (depending on the timeout) 2. delete it from the cache_notrans This patch changes gencache_notrans.tdb to avoid transactions by using an all-record lock like this: tdb_allrecord_lock(cache_notrans) transaction_start(cache) traverse(cache_notrans, stabilize_fn_mod) transaction_commit(cache) traverse(cache_notrans, wipe_fn) tdb_wipe_all(cache_notrans) tdb_allrecord_unlock(cache_notrans) with stabilize_fn_mod doing only: 1. store the record to or delete it from cache (depending on the timeout) and wipe_fn deleting the records from the gencache_notrans db. This is a step towards making non-persistent-db specific features like mutex locking usable for gencache_notrans.tdb. Signed-off-by: Michael Adam Reviewed-by: Christof Schmitt (cherry picked from commit 35fd2ca4984b3a1a8bbcb5c1c9e0d724e3c63d80) BUG: https://bugzilla.samba.org/show_bug.cgi?id=11032 --- source3/lib/gencache.c | 52 ++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 44 insertions(+), 8 deletions(-) diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index ed2b0be..73bf7d5 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -607,6 +607,9 @@ struct stabilize_state { static int stabilize_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val, void *priv); +static int wipe_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val, + void *priv); + /** * Stabilize gencache * @@ -639,10 +642,11 @@ bool gencache_stabilize(void) "%s\n", tdb_errorstr_compat(cache))); return false; } - res = tdb_transaction_start(cache_notrans); + + res = tdb_lockall(cache_notrans); if (res != 0) { tdb_transaction_cancel(cache); - DEBUG(10, ("Could not start transaction on " + DEBUG(10, ("Could not get allrecord lock on " "gencache_notrans.tdb: %s\n", tdb_errorstr_compat(cache_notrans))); return false; @@ -652,13 +656,13 @@ bool gencache_stabilize(void) res = tdb_traverse(cache_notrans, stabilize_fn, &state); if (res < 0) { - tdb_transaction_cancel(cache_notrans); + tdb_unlockall(cache_notrans); tdb_transaction_cancel(cache); return false; } if (!state.written) { - tdb_transaction_cancel(cache_notrans); + tdb_unlockall(cache_notrans); tdb_transaction_cancel(cache); return true; } @@ -667,13 +671,21 @@ bool gencache_stabilize(void) if (res != 0) { DEBUG(10, ("tdb_transaction_commit on gencache.tdb failed: " "%s\n", tdb_errorstr_compat(cache))); - tdb_transaction_cancel(cache_notrans); + tdb_unlockall(cache_notrans); return false; } - res = tdb_transaction_commit(cache_notrans); + res = tdb_traverse(cache_notrans, wipe_fn, NULL); if (res != 0) { - DEBUG(10, ("tdb_transaction_commit on gencache.tdb failed: " + DEBUG(10, ("tdb_traverse with wipe_fn on gencache_notrans.tdb " + "failed: %s\n", tdb_errorstr_compat(cache_notrans))); + tdb_unlockall(cache_notrans); + return false; + } + + res = tdb_unlockall(cache_notrans); + if (res != 0) { + DEBUG(10, ("tdb_unlockall on gencache.tdb failed: " "%s\n", tdb_errorstr_compat(cache))); return false; } @@ -723,14 +735,38 @@ static int stabilize_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val, return -1; } - if (tdb_delete(cache_notrans, key) != 0) { + return 0; +} + +static int wipe_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val, + void *priv) +{ + int res; + bool ok; + time_t timeout; + + res = tdb_data_cmp(key, last_stabilize_key()); + if (res == 0) { + return 0; + } + + ok = gencache_pull_timeout((char *)val.dptr, &timeout, NULL); + if (!ok) { + DEBUG(10, ("Ignoring invalid entry\n")); + return 0; + } + + res = tdb_delete(tdb, key); + if (res != 0) { DEBUG(10, ("tdb_delete from gencache_notrans.tdb failed: " "%s\n", tdb_errorstr_compat(cache_notrans))); return -1; } + return 0; } + /** * Get existing entry from the cache file. * -- 1.7.1 From f6ba6f630d0d6baa8306d44cc5b337cb9a5d0b6d Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Mon, 17 Nov 2014 14:30:49 -0700 Subject: [PATCH 5/8] gencache: Convert gencache_notrans to use tdb_wrap This allows using on the mutex check in tdb_wrap. Signed-off-by: Christof Schmitt Reviewed-by: Volker Lendecke (cherry picked from commit 139bd9589ac759b4e7a6ae9aa465320c5fa85d18) BUG: https://bugzilla.samba.org/show_bug.cgi?id=11032 --- source3/lib/gencache.c | 53 +++++++++++++++++++++++++---------------------- 1 files changed, 28 insertions(+), 25 deletions(-) diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index 73bf7d5..fc5f748 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -25,6 +25,7 @@ #include "system/filesys.h" #include "system/glob.h" #include "util_tdb.h" +#include "tdb_wrap/tdb_wrap.h" #include "../lib/util/memcache.h" #undef DBGC_CLASS @@ -37,7 +38,7 @@ #define BLOB_TYPE_LEN 9 static struct tdb_context *cache; -static struct tdb_context *cache_notrans; +static struct tdb_wrap *cache_notrans; static int cache_notrans_seqnum; /** @@ -111,12 +112,12 @@ static bool gencache_init(void) DEBUG(5, ("Opening cache file at %s\n", cache_fname)); - cache_notrans = tdb_open_log(cache_fname, 0, - TDB_CLEAR_IF_FIRST| - TDB_INCOMPATIBLE_HASH| - TDB_SEQNUM| - TDB_NOSYNC, - open_flags, 0644); + cache_notrans = tdb_wrap_open(NULL, cache_fname, 0, + TDB_CLEAR_IF_FIRST| + TDB_INCOMPATIBLE_HASH| + TDB_SEQNUM| + TDB_NOSYNC, + open_flags, 0644); if (cache_notrans == NULL) { DEBUG(5, ("Opening %s failed: %s\n", cache_fname, strerror(errno))); @@ -309,7 +310,7 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, timeout > time(NULL) ? "ahead" : "in the past")); ret = tdb_store_bystring( - cache_notrans, keystr, + cache_notrans->tdb, keystr, make_tdb_data((uint8_t *)val, talloc_array_length(val)), 0); TALLOC_FREE(val); @@ -337,7 +338,7 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, last_stabilize = 0; - tdb_parse_record(cache_notrans, last_stabilize_key(), + tdb_parse_record(cache_notrans->tdb, last_stabilize_key(), last_stabilize_parser, &last_stabilize); if ((last_stabilize @@ -486,7 +487,7 @@ bool gencache_parse(const char *keystr, * Make sure that nobody has changed the gencache behind our * back. */ - int current_seqnum = tdb_get_seqnum(cache_notrans); + int current_seqnum = tdb_get_seqnum(cache_notrans->tdb); if (current_seqnum == cache_notrans_seqnum) { /* * Ok, our memcache is still current, use it without @@ -504,7 +505,8 @@ bool gencache_parse(const char *keystr, state.is_memcache = false; - ret = tdb_parse_record(cache_notrans, key, gencache_parse_fn, &state); + ret = tdb_parse_record(cache_notrans->tdb, key, + gencache_parse_fn, &state); if (ret == 0) { return true; } @@ -643,26 +645,26 @@ bool gencache_stabilize(void) return false; } - res = tdb_lockall(cache_notrans); + res = tdb_lockall(cache_notrans->tdb); if (res != 0) { tdb_transaction_cancel(cache); DEBUG(10, ("Could not get allrecord lock on " "gencache_notrans.tdb: %s\n", - tdb_errorstr_compat(cache_notrans))); + tdb_errorstr_compat(cache_notrans->tdb))); return false; } state.written = false; - res = tdb_traverse(cache_notrans, stabilize_fn, &state); + res = tdb_traverse(cache_notrans->tdb, stabilize_fn, &state); if (res < 0) { - tdb_unlockall(cache_notrans); + tdb_unlockall(cache_notrans->tdb); tdb_transaction_cancel(cache); return false; } if (!state.written) { - tdb_unlockall(cache_notrans); + tdb_unlockall(cache_notrans->tdb); tdb_transaction_cancel(cache); return true; } @@ -671,19 +673,20 @@ bool gencache_stabilize(void) if (res != 0) { DEBUG(10, ("tdb_transaction_commit on gencache.tdb failed: " "%s\n", tdb_errorstr_compat(cache))); - tdb_unlockall(cache_notrans); + tdb_unlockall(cache_notrans->tdb); return false; } - res = tdb_traverse(cache_notrans, wipe_fn, NULL); + res = tdb_traverse(cache_notrans->tdb, wipe_fn, NULL); if (res != 0) { DEBUG(10, ("tdb_traverse with wipe_fn on gencache_notrans.tdb " - "failed: %s\n", tdb_errorstr_compat(cache_notrans))); - tdb_unlockall(cache_notrans); + "failed: %s\n", + tdb_errorstr_compat(cache_notrans->tdb))); + tdb_unlockall(cache_notrans->tdb); return false; } - res = tdb_unlockall(cache_notrans); + res = tdb_unlockall(cache_notrans->tdb); if (res != 0) { DEBUG(10, ("tdb_unlockall on gencache.tdb failed: " "%s\n", tdb_errorstr_compat(cache))); @@ -692,7 +695,7 @@ bool gencache_stabilize(void) now = talloc_asprintf(talloc_tos(), "%d", (int)time(NULL)); if (now != NULL) { - tdb_store(cache_notrans, last_stabilize_key(), + tdb_store(cache_notrans->tdb, last_stabilize_key(), string_term_tdb_data(now), 0); TALLOC_FREE(now); } @@ -759,7 +762,7 @@ static int wipe_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val, res = tdb_delete(tdb, key); if (res != 0) { DEBUG(10, ("tdb_delete from gencache_notrans.tdb failed: " - "%s\n", tdb_errorstr_compat(cache_notrans))); + "%s\n", tdb_errorstr_compat(cache_notrans->tdb))); return -1; } @@ -850,7 +853,7 @@ static int gencache_iterate_blobs_fn(struct tdb_context *tdb, TDB_DATA key, if (tdb_data_cmp(key, last_stabilize_key()) == 0) { return 0; } - if (state->in_persistent && tdb_exists(cache_notrans, key)) { + if (state->in_persistent && tdb_exists(cache_notrans->tdb, key)) { return 0; } @@ -905,7 +908,7 @@ void gencache_iterate_blobs(void (*fn)(const char *key, DATA_BLOB value, state.private_data = private_data; state.in_persistent = false; - tdb_traverse(cache_notrans, gencache_iterate_blobs_fn, &state); + tdb_traverse(cache_notrans->tdb, gencache_iterate_blobs_fn, &state); state.in_persistent = true; tdb_traverse(cache, gencache_iterate_blobs_fn, &state); -- 1.7.1 From 00d26d1097d31e7f7cfe2109b1c96eb472b31f7d Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Mon, 17 Nov 2014 15:44:47 -0700 Subject: [PATCH 6/8] gencache: Convert gencache.tdb to tdb_wrap This change is not strictly necessary, but for consistency both gencache tdbs are now opened through tdb_wrap. Signed-off-by: Christof Schmitt Reviewed-by: Volker Lendecke (cherry picked from commit f80bbba2870a80ed421a1a222e430df86028e7c7) BUG: https://bugzilla.samba.org/show_bug.cgi?id=11032 --- source3/lib/gencache.c | 58 ++++++++++++++++++++++++----------------------- 1 files changed, 30 insertions(+), 28 deletions(-) diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index fc5f748..71f77f4 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -37,7 +37,7 @@ #define BLOB_TYPE "DATA_BLOB" #define BLOB_TYPE_LEN 9 -static struct tdb_context *cache; +static struct tdb_wrap *cache; static struct tdb_wrap *cache_notrans; static int cache_notrans_seqnum; @@ -69,12 +69,14 @@ static bool gencache_init(void) DEBUG(5, ("Opening cache file at %s\n", cache_fname)); - cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT|TDB_INCOMPATIBLE_HASH, open_flags, 0644); + cache = tdb_wrap_open(NULL, cache_fname, 0, + TDB_DEFAULT|TDB_INCOMPATIBLE_HASH, + open_flags, 0644); if (cache) { int ret; - ret = tdb_check(cache, NULL, NULL); + ret = tdb_check(cache->tdb, NULL, NULL); if (ret != 0) { - tdb_close(cache); + TALLOC_FREE(cache); /* * Retry with CLEAR_IF_FIRST. @@ -86,18 +88,19 @@ static bool gencache_init(void) * CLEAR_IF_FIRST databases, so lets use it here to * clean up a broken database. */ - cache = tdb_open_log(cache_fname, 0, - TDB_DEFAULT| - TDB_INCOMPATIBLE_HASH| - TDB_CLEAR_IF_FIRST, - open_flags, 0644); + cache = tdb_wrap_open(NULL, cache_fname, 0, + TDB_DEFAULT| + TDB_INCOMPATIBLE_HASH| + TDB_CLEAR_IF_FIRST, + open_flags, 0644); } } if (!cache && (errno == EACCES)) { open_flags = O_RDONLY; - cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT|TDB_INCOMPATIBLE_HASH, open_flags, - 0644); + cache = tdb_wrap_open(NULL, cache_fname, 0, + TDB_DEFAULT|TDB_INCOMPATIBLE_HASH, + open_flags, 0644); if (cache) { DEBUG(5, ("gencache_init: Opening cache file %s read-only.\n", cache_fname)); } @@ -121,8 +124,7 @@ static bool gencache_init(void) if (cache_notrans == NULL) { DEBUG(5, ("Opening %s failed: %s\n", cache_fname, strerror(errno))); - tdb_close(cache); - cache = NULL; + TALLOC_FREE(cache); return false; } @@ -510,7 +512,7 @@ bool gencache_parse(const char *keystr, if (ret == 0) { return true; } - ret = tdb_parse_record(cache, key, gencache_parse_fn, &state); + ret = tdb_parse_record(cache->tdb, key, gencache_parse_fn, &state); return (ret == 0); } @@ -629,9 +631,9 @@ bool gencache_stabilize(void) return false; } - res = tdb_transaction_start_nonblock(cache); + res = tdb_transaction_start_nonblock(cache->tdb); if (res != 0) { - if (tdb_error(cache) == TDB_ERR_NOLOCK) + if (tdb_error(cache->tdb) == TDB_ERR_NOLOCK) { /* * Someone else already does the stabilize, @@ -641,13 +643,13 @@ bool gencache_stabilize(void) } DEBUG(10, ("Could not start transaction on gencache.tdb: " - "%s\n", tdb_errorstr_compat(cache))); + "%s\n", tdb_errorstr_compat(cache->tdb))); return false; } res = tdb_lockall(cache_notrans->tdb); if (res != 0) { - tdb_transaction_cancel(cache); + tdb_transaction_cancel(cache->tdb); DEBUG(10, ("Could not get allrecord lock on " "gencache_notrans.tdb: %s\n", tdb_errorstr_compat(cache_notrans->tdb))); @@ -659,20 +661,20 @@ bool gencache_stabilize(void) res = tdb_traverse(cache_notrans->tdb, stabilize_fn, &state); if (res < 0) { tdb_unlockall(cache_notrans->tdb); - tdb_transaction_cancel(cache); + tdb_transaction_cancel(cache->tdb); return false; } if (!state.written) { tdb_unlockall(cache_notrans->tdb); - tdb_transaction_cancel(cache); + tdb_transaction_cancel(cache->tdb); return true; } - res = tdb_transaction_commit(cache); + res = tdb_transaction_commit(cache->tdb); if (res != 0) { DEBUG(10, ("tdb_transaction_commit on gencache.tdb failed: " - "%s\n", tdb_errorstr_compat(cache))); + "%s\n", tdb_errorstr_compat(cache->tdb))); tdb_unlockall(cache_notrans->tdb); return false; } @@ -689,7 +691,7 @@ bool gencache_stabilize(void) res = tdb_unlockall(cache_notrans->tdb); if (res != 0) { DEBUG(10, ("tdb_unlockall on gencache.tdb failed: " - "%s\n", tdb_errorstr_compat(cache))); + "%s\n", tdb_errorstr_compat(cache->tdb))); return false; } @@ -719,14 +721,14 @@ static int stabilize_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val, return 0; } if ((timeout < time(NULL)) || (val.dsize == 0)) { - res = tdb_delete(cache, key); + res = tdb_delete(cache->tdb, key); if (res == 0) { state->written = true; - } else if (tdb_error(cache) == TDB_ERR_NOEXIST) { + } else if (tdb_error(cache->tdb) == TDB_ERR_NOEXIST) { res = 0; } } else { - res = tdb_store(cache, key, val, 0); + res = tdb_store(cache->tdb, key, val, 0); if (res == 0) { state->written = true; } @@ -734,7 +736,7 @@ static int stabilize_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA val, if (res != 0) { DEBUG(10, ("Transfer to gencache.tdb failed: %s\n", - tdb_errorstr_compat(cache))); + tdb_errorstr_compat(cache->tdb))); return -1; } @@ -911,7 +913,7 @@ void gencache_iterate_blobs(void (*fn)(const char *key, DATA_BLOB value, tdb_traverse(cache_notrans->tdb, gencache_iterate_blobs_fn, &state); state.in_persistent = true; - tdb_traverse(cache, gencache_iterate_blobs_fn, &state); + tdb_traverse(cache->tdb, gencache_iterate_blobs_fn, &state); } /** -- 1.7.1 From e0a4b661c95eab96b5c8e65442b8a59f2b000d99 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Mon, 17 Nov 2014 14:59:34 -0700 Subject: [PATCH 7/8] gencache: Request mutexes for gencache_notrans.tdb The check in tdb_wrap ensures that mutexes are only used on systems that properly support them. Signed-off-by: Christof Schmitt Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Wed Nov 26 19:04:11 CET 2014 on sn-devel-104 (cherry picked from commit 068f9e26486fbcd36c109df9ada50c9384ba52c5) BUG: https://bugzilla.samba.org/show_bug.cgi?id=11032 --- source3/lib/gencache.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index 71f77f4..ec96f5a 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -119,7 +119,8 @@ static bool gencache_init(void) TDB_CLEAR_IF_FIRST| TDB_INCOMPATIBLE_HASH| TDB_SEQNUM| - TDB_NOSYNC, + TDB_NOSYNC| + TDB_MUTEX_LOCKING, open_flags, 0644); if (cache_notrans == NULL) { DEBUG(5, ("Opening %s failed: %s\n", cache_fname, -- 1.7.1 From abb7ca7005e9cd813cc84c3a59a70fa9bfb7dfc2 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Thu, 15 Jan 2015 14:31:19 -0700 Subject: [PATCH 8/8] samba3.py: Correctly initialize cache directory for passdb test Running 'make test TESTS=tests.samba3' succeeds, but the log shows that it tried to open the gencache tdb in the wrong directory: Unable to create directory /usr/local/samba/var/cache for file gencache.tdb. Error was No such file or directory Fix this by correctly initializing the cache directory. Signed-off-by: Christof Schmitt Reviewed-By: Jelmer Vernooij Autobuild-User(master): Christof Schmitt Autobuild-Date(master): Fri Jan 16 02:36:39 CET 2015 on sn-devel-104 (cherry picked from commit c31f54112e21b2e76398a402e864a2b6b6c74e6c) BUG: https://bugzilla.samba.org/show_bug.cgi?id=11032 --- python/samba/tests/samba3.py | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/python/samba/tests/samba3.py b/python/samba/tests/samba3.py index 51d76dd..6eb7154 100644 --- a/python/samba/tests/samba3.py +++ b/python/samba/tests/samba3.py @@ -72,6 +72,7 @@ class PassdbTestCase(TestCaseInTempDir): self.lp.set("private dir", datadir) self.lp.set("state directory", datadir) self.lp.set("lock directory", datadir) + self.lp.set("cache directory", datadir) passdb.set_secrets_dir(datadir) self.pdb = passdb.PDB("tdbsam") -- 1.7.1