summaryrefslogtreecommitdiffstats
path: root/source3/lib/gencache.c
Commit message (Collapse)AuthorAgeFilesLines
* gencache: don't fail gencache_stabilize if there were records to delete.Michael Adam2015-02-091-1/+1
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* gencache: Request mutexes for gencache_notrans.tdbChristof Schmitt2014-11-261-1/+2
| | | | | | | | | | | The check in tdb_wrap ensures that mutexes are only used on systems that properly support them. Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Wed Nov 26 19:04:11 CET 2014 on sn-devel-104
* gencache: Convert gencache.tdb to tdb_wrapChristof Schmitt2014-11-261-30/+31
| | | | | | | | This change is not strictly necessary, but for consistency both gencache tdbs are now opened through tdb_wrap. Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* gencache: Convert gencache_notrans to use tdb_wrapChristof Schmitt2014-11-261-25/+28
| | | | | | | This allows using on the mutex check in tdb_wrap. Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3:gencache: don't use transaction non non-persistent gencache_notrans.tdbMichael Adam2014-11-261-8/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <obnox@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* s3:gencache: simply stabilize() a bit more: remove error from stateMichael Adam2014-11-261-5/+1
| | | | | | | | | | | 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 <obnox@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* s3:gencache: fix logic in stabilization when deleting a record from stable cacheMichael Adam2014-11-261-3/+3
| | | | | | | | | | | | | 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 <obnox@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* lib: Use tdb_parse_record in gencache_setVolker Lendecke2014-11-261-7/+15
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Wed Nov 26 14:50:38 CET 2014 on sn-devel-104
* gencache: don't leak cache_path onto talloc tosDavid Disseldorp2014-10-061-0/+11
| | | | | | | | Also check for allocation failures. Reported-by: Franz Pförtsch <franz.pfoertsch@brose.com> Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib/util: move memcache.[ch] to the toplevel 'samba-util' libraryStefan Metzmacher2014-07-181-1/+1
| | | | | | | | | | This is generic enough that it could be used in all code. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Fri Jul 18 15:43:33 CEST 2014 on sn-devel-104
* gencache: Add gencache values to memcacheVolker Lendecke2014-03-111-0/+37
| | | | | | | | | | | | gencache_parse calling tdb shows up in profiles when we do a lot of open/close traffic with large ACLs. For every file we convert unix ids to sids, and in the domain member case this goes through gencache. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Mar 11 19:56:47 CET 2014 on sn-devel-104
* gencache: Fix a type-punned warningVolker Lendecke2013-12-161-1/+5
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Mon Dec 16 17:11:13 CET 2013 on sn-devel-104
* gencache: Avoid a duplicate call to string_term_tdb_dataVolker Lendecke2013-09-091-4/+2
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Mon Sep 9 17:02:28 CEST 2013 on sn-devel-104
* lib: Use "mem_ctx" arg in gencache_getVolker Lendecke2013-09-051-10/+14
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Sep 5 20:09:21 CEST 2013 on sn-devel-104
* lib: Add a "mem_ctx" arg to gencache_get (unused so far)Volker Lendecke2013-09-051-1/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* gencache: Fix SAFE_FREE vs data_blob_freeVolker Lendecke2013-09-051-2/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Add "mem_ctx" to gencache_get_data_blobVolker Lendecke2013-09-051-4/+9
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* gencache: Simplify gencache_init a bitVolker Lendecke2013-06-141-13/+16
| | | | | | | Use the implicit cleanup facility CLEAR_IF_FIRST provides Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:lib/gencache: place gencache.tdb into /var/cache/sambaStefan Metzmacher2013-04-031-1/+1
| | | | | | | | | /var/lock/samba is located on tmpfs on newer systems, but we want to keep things like the server affinity cache across reboots. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* gencache: fix an extra newline in a DEBUG message in gencache_set_data_blob()Michael Adam2013-02-191-1/+1
| | | | | | | by using timestring() instead of ctime() Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* gencache: fix an extra newline in a DEBUG message in gencache_iterate_fn()Michael Adam2013-02-191-1/+1
| | | | | | | by using timestring() instead of ctime() Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* gencache: fix an extra newline in a DEBUG message in gencache_iterate_blobs_fn()Michael Adam2013-02-191-1/+1
| | | | | | | by using timestring() instead of ctime() Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* gencache: unify a DEBUG message in gencache_set_data_blob()Michael Adam2013-02-191-2/+3
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* gencache: unify a DEBUG message in gencache_iterate_fn()Michael Adam2013-02-191-1/+1
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* gencache: unify a DEBUG message in gencache_iterate_blobs_fn()Michael Adam2013-02-191-1/+2
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* gencache: unify a DEBUG message in gencache_del()Michael Adam2013-02-191-1/+1
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3: Open gencache_notrans with TDB_NOSYNCVolker Lendecke2012-11-281-1/+4
| | | | | | | | | | | | | | | | | | | We are doing CLEAR_IF_FIRST here, and we are doing the transactions only to protect gencache_stabilize against concurrent writers. tdb's transaction.c says: - if TDB_NOSYNC is passed to flags in tdb_open then transactions are still available, but no fsync/msync calls are made. This means we are still proof against a process dying during transaction commit, but not against machine reboot. For gencache_notrans.tdb this is exactly what we want and avoids some expensive disk syncs. Reviewed by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Nov 28 03:13:56 CET 2012 on sn-devel-104
* s3: Avoid some transaction_commit on gencache.tdbVolker Lendecke2012-11-271-0/+110
| | | | | | | Commits are expensive, and in some scenarios we are overwriting existing values again and again. Reviewed by: Jeremy Allison <jra@samba.org>
* TDB2: make SAMBA use tdb1 again for the moment.Rusty Russell2012-06-191-5/+0
| | | | | | | Otherwise the following surgery will break the SAMBA build and testsuite. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* tdb2: tdb_parse_record() returns negative errors, not -1.Rusty Russell2011-06-201-2/+2
| | | | | | | Fixup callers to tdb_parse_record() to be compatible with tdb2. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* tdb2: #ifdef out TDB_ERR_NOLOCK and TDB_ERR_LOCK_TIMEOUT.Rusty Russell2011-06-201-1/+6
| | | | | | | | These don't exist in tdb2. The former is used in one weird place in tdb1, and the latter not at all. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* tdb_compat: use tdb_errorstr_compat()Rusty Russell2011-06-201-6/+6
| | | | | | | | Since TDB2 functions return the error directly, tdb_errorstr() taken an error code, not the tdb as it does in TDB1. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* tdb_traverse/tdb_traverse_read: check returns for negative, not -1.Rusty Russell2011-06-201-1/+1
| | | | | | | | | | | TDB2 returns a negative error number on failure. This is compatible if we always check for < 0 instead of == -1. Also, there's no tdb_traverse_read in TDB2: we don't try to make traverse reliable any more, so there are no write locks anyway. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* tdb_transaction_cancel: ignore return value.Rusty Russell2011-06-201-11/+5
| | | | | | | | | TDB2 returns void here. tdb_transaction_cancel will *always* return with the transaction cancelled, but it will complain via the log function if a transaction wasn't in progress. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* tdb_transaction_commit: check returns for 0, not -1.Rusty Russell2011-06-201-4/+4
| | | | | | | | TDB2 returns a negative error number on failure. This is compatible if we always check for != 0 instead of == -1. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* tdb_delete: check returns for 0, not -1.Rusty Russell2011-06-201-3/+3
| | | | | | | | TDB2 returns a negative error number on failure. This is compatible if we always check for != 0 instead of == -1. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* tdb_fetch_compat: use instead of tdb_fetch.Rusty Russell2011-06-201-1/+1
| | | | | | | This is a noop for tdb1. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* gencache: don't use CLEAR_IF_FIRST as fallback.Rusty Russell2011-04-191-7/+3
| | | | | | | | | | | | CLEAR_IF_FIRST only works if *all* openers use that flag. So just truncate the file: it's racy, but that's what we're doing anyway. We'd really need a TDB_OPENCHECK_OR_CLEAR flag to do this properly (or in TDB2, a open hook at the right point). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* s3: only include tdb headers where needed.Günther Deschner2011-05-061-0/+1
| | | | Guenther
* More const fixes for compiler warnings from the waf build.Jeremy Allison2011-05-051-1/+1
|
* s3-includes: only include system/filesys.h when needed.Günther Deschner2011-03-301-0/+1
| | | | Guenther
* s3-includes: only include system/glob.h when needed.Günther Deschner2011-03-301-0/+1
| | | | Guenther
* s3:lib/gencache: fix memory leak in error pathStefan Metzmacher2010-12-221-0/+3
| | | | | | | metze Autobuild-User: Stefan Metzmacher <metze@samba.org> Autobuild-Date: Wed Dec 22 15:08:30 CET 2010 on sn-devel-104
* s3: Add gencache_iterate_blobsVolker Lendecke2010-11-281-57/+87
|
* s3: Convert gencache_get_data_blob to gencache_parseVolker Lendecke2010-11-281-59/+38
|
* s3: Add gencache_parseVolker Lendecke2010-11-281-0/+59
|
* Change to using TDB_INCOMPATIBLE_HASH (the jenkins hash) on allJeremy Allison2010-09-271-4/+4
| | | | | | | | | | TDB_CLEAR_IF_FIRST tdb's. For tdb's like gencache where we open without CLEAR_IF_FIRST and then with CLEAR_IF_FIRST if corrupt this is still safe to use as if opening an existing tdb the new hash will be ignored - it's only used on creating a new tdb not opening an old one. Jeremy.
* s3: Use tdb_transaction_start_nonblock in gencache_stabilizeVolker Lendecke2010-03-281-1/+10
| | | | | This avoids the thundering herd problem when 5000 smbds exit simultaneously because the network went down.
* Revert "s3: Optimize gencache for smbd exit"Volker Lendecke2010-03-281-75/+14
| | | | | | This reverts commit 5ca63676dc59e83ffd9560fdcfa26063f267f283. That does not fully fix the problem, adding a tdb_transaction_start_nonblock to fix it.
* s3: Optimize gencache for smbd exitVolker Lendecke2010-03-241-14/+75
| | | | | | | | If thousands of smbds try to gencache_stabilize at the same time because the network died, all of them might be sitting in transaction_start. Don't do the stabilize transaction if nothing has changed in gencache_notrans.tdb. Volker