summaryrefslogtreecommitdiffstats
path: root/lib/tdb
Commit message (Collapse)AuthorAgeFilesLines
* tdb/tools: Allow tdbtool to r/o open mutexed tdbsVolker Lendecke2014-05-221-1/+45
| | | | | | | Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb/tools: add -m option to tdbtortureVolker Lendecke2014-05-221-4/+25
| | | | | | | | This allows tdbtorture to run with mutexes. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb/test: add marklock deadlock testVolker Lendecke2014-05-222-0/+279
| | | | | | | | | Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb/test: add mutex related testsVolker Lendecke2014-05-228-1/+1004
| | | | | | | | | Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: add TDB_MUTEX_LOCKING supportVolker Lendecke2014-05-2234-21/+1601
| | | | | | | | | | | | | | | | | | | | | | | | This adds optional support for locking based on shared robust mutexes. The caller can use the TDB_MUTEX_LOCKING flag together with TDB_CLEAR_IF_FIRST after verifying with tdb_runtime_check_for_robust_mutexes() that it's supported by the current system. The caller should be aware that using TDB_MUTEX_LOCKING implies some limitations, e.g. it's not possible to have multiple read chainlocks on a given hash chain from multiple processes. Note: that this doesn't make tdb thread safe! Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: introduce tdb->hdr_ofsVolker Lendecke2014-05-225-39/+146
| | | | | | | | | | | | | | This makes it possible to have some extra headers before the real tdb content starts in the file. This will be used used e.g. to implement locking based on robust mutexes. Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: introduce TDB_SUPPORTED_FEATURE_FLAGSStefan Metzmacher2014-05-224-2/+39
| | | | | | | | | | | | | This will allow to store a feature mask in the tdb header on disk, so that openers can check if they can handle the features other openers are using. Pair-Programmed-With: Volker Lendecke <vl@samba.org> Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: use asprintf() to simplify tdb_summary()Stefan Metzmacher2014-05-221-7/+6
| | | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb/test: add UNMAP command to external-agent.cVolker Lendecke2014-05-222-0/+8
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb/test: add PING command to external-agent.cVolker Lendecke2014-05-222-0/+5
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb/test: add shutdown_agent() helper functionVolker Lendecke2014-05-222-6/+21
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb/test: add a "skip()" macro.Stefan Metzmacher2014-05-221-0/+1
| | | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb/test: correctly use stderr, not stdout, in fail()Stefan Metzmacher2014-05-221-1/+1
| | | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb/tools: explicitly use TDB_NOLOCK in tdbdumpVolker Lendecke2014-05-221-1/+9
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb/tools: add -l option to tdbtoolVolker Lendecke2014-05-222-2/+37
| | | | | | | | This opens the tdb with TDB_NOLOCK. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb/tools: add -l option to tdbbackupVolker Lendecke2014-05-222-5/+25
| | | | | | | | This opens the tdb with TDB_NOLOCK. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: return ENOSYS if the tdb was created with spinlocks.Stefan Metzmacher2014-05-121-0/+1
| | | | | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Mon May 12 21:07:04 CEST 2014 on sn-devel-104
* pytdb: avoid const warnings by using discard_const_p()Stefan Metzmacher2014-05-121-9/+18
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* tdb: consolidate tdb allocation code - re-use dead records at hash top.Michael Adam2014-04-092-43/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | When in tdb_store we re-use a dead record reactivated from the target hash chain itself, we currently leave it in its place in the chain. When we re-use a dead record from a different chain or from the freelist instead, we insert it at the beginning of the target chain. This patch changes the behaviour to always newly store a record at the beginning of the hash chain. This removes a special case and hence simplifies the allocation code. On the other hand side, it introduces two additioal tdb_ofs_write calls for the in-chain-case. Note the subtelty of the patch that by moving the case of the candidate record's chain as new case "i=0" into the for loop, we also reverse the order of the two steps in the for-loop body (non blocking freelist alloc and searching for dead record in a chain) in order to keep the overall order of execution identical. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Wed Apr 9 10:37:08 CEST 2014 on sn-devel-104
* tdb/wscript: maintain a global list of unit testsStefan Metzmacher2014-04-021-45/+32
| | | | | | | This makes sure a new test is also added to 'make test' Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* tdb/test: avoid const warnings by using 'discard_const_p(uint8_t,' instead ↵Stefan Metzmacher2014-04-0218-34/+34
| | | | | | | of '(void *)' Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* tdb/test: remove "\n" in diag() argumentsStefan Metzmacher2014-04-022-2/+2
| | | | | | | diag() already adds "\n". Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* tdb/test: always call fflush() after [f]printf() in tap-interface.hStefan Metzmacher2014-04-021-4/+22
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* tdb/tools: avoid const warnings in tdbdump.cStefan Metzmacher2014-04-021-1/+1
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* tdb: don't alter errno on success of tdb_open_ex()Stefan Metzmacher2014-04-021-0/+2
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* tdb: change version to 1.2.13.Michael Adam2014-03-182-1/+68
| | | | | | | | | | | | | | | | * internal code cleanups * always open internal TDBs with incompatible hash * avoid reallocations in locking code * systematize output format in tdbtool dump * reduce freelist contention when allocating new records - try to find dead records also in other chains - don't do blocking locks on the freelist Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Tue Mar 18 15:42:48 CET 2014 on sn-devel-104
* tdb: Reduce freelist contentionVolker Lendecke2014-03-183-30/+93
| | | | | | | | | | | | | | | | | | | | | | | In a metadata-intensive benchmark we have seen the locking.tdb freelist to be one of the central contention points. This patch removes most of the contention on the freelist. Ages ago we already reduced freelist contention by using the even much older DEAD records: If TDB_VOLATILE is set, don't directly put deleted records on the freelist, but just mark a few of them just as DEAD. The next new record can them re-use that space without consulting the freelist. This patch builds upon the DEAD records: If we need space and the freelist is busy, instead of doing a blocking wait on the freelist, start looking into other chains for DEAD records and steal them from there. This way every hash chain becomes a small freelist. Just wander around the hash chains as long as the freelist is still busy. With this patch and the tdb mutex patch (following hopefully some time soon) you can see a heavily busy clustered smbd run without locking.tdb futex syscalls. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tdb: Make "tdb_purge_dead" internally publicVolker Lendecke2014-03-182-1/+2
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tdb: Make "tdb_find_dead" internally publicVolker Lendecke2014-03-182-3/+6
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tdb: Add "last_ptr" to tdb_find_deadVolker Lendecke2014-03-181-4/+13
| | | | | | | | Will be used soon to unlink a dead record from a chain Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tdb: Move adding tailer space to tdb_find_deadVolker Lendecke2014-03-181-3/+4
| | | | | | | | | This aligns the tdb_find_dead API with the tdb_allocate API and thus makes it a bit easier to understand, at least for me. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tdb: Do a best fit search for dead recordsVolker Lendecke2014-03-181-7/+13
| | | | | | | | | | Hash chains are (or can be made) short enough that a full search for the best-fitting dead record is feasible. The freelist can become much longer, there we don't do the full search but accept records which are too large. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tdb: Don't purge records to a blocked freelistVolker Lendecke2014-03-181-1/+4
| | | | | | | | If the freelist is heavily contended, we should avoid accessing it Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tdb: Fix a tdb corruptionVolker Lendecke2014-03-181-2/+5
| | | | | | | | | | tdb_purge_dead can change the next pointer of "rec" if we purge the record right behind the current record to be deleted. Just overwrite the magic, not the whole record with stale data. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tdb: always open internal databases with incompatible hash.Michael Adam2014-02-151-0/+5
| | | | | | | | | | | This makes them more efficient due to better distribution of keys across hash chains. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Sat Feb 15 08:26:07 CET 2014 on sn-devel-104
* tdb: in tdb_delete_hash, make lock/unlock bracket more obviousMichael Adam2014-02-151-1/+1
| | | | | | | | | | by using the same variable as hash as in the lock. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Sat Feb 15 03:21:07 CET 2014 on sn-devel-104
* tdb: simplify tdb_delete_hash() a bitMichael Adam2014-02-141-12/+5
| | | | | | | | | | | | | | | | | | | | Make the lock/unlock bracket more obvious by extracting locking (and finding) from the special cases to the top of the function. This also lets us take lock and find the record outside the special case branches (use dead records or not). There is a small semantic change implied: In the dead records case, the record to delete is looked up before the current dead records are potentially purged. Hence, if the record to delete is not found, the dead records are also not purge. This does not make a big difference though, because purging is only delayed until directly befor the next record to delete is in fact found. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: tdbtool: dump record magic with fixed number of 8 hex digitsMichael Adam2014-02-141-1/+1
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: tdbtool: dump record hash with fixed number of 8 hex digitsMichael Adam2014-02-141-1/+1
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* samba:python - Py_RETURN_NONE remove compatibility code for releases < 2.4Matthias Dieter Wallnöfer2014-01-091-4/+0
| | | | | | | | | http://www.python.org/doc//current/c-api/none.html Reviewed-By: Jelmer Vernooij <jelmer@samba.org> Autobuild-User(master): Matthias Dieter Wallnöfer <mdw@samba.org> Autobuild-Date(master): Thu Jan 9 16:27:47 CET 2014 on sn-devel-104
* tdb: Avoid reallocs for lockrecsVolker Lendecke2013-12-143-17/+17
| | | | | | | | | | | In normal operations we have at most 3 entries in this array. Don't bother with shrinking. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Sat Dec 14 13:19:47 CET 2013 on sn-devel-104
* lib/tdb: fix compiler warningsChristian Ambach2013-12-122-8/+8
| | | | | | | about a variable shadowing a global declaration Signed-off-by: Christian Ambach <ambi@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb tests: Remove custom code for "tdb2", which has been split out into ntdb.Jelmer Vernooij2013-12-061-43/+22
| | | | | | Signed-off-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* tdb: Fix some typos in comments.Björn Jacke2013-09-122-5/+5
| | | | | | | | | | | | Thanks to Stewart A. Levin for reporting. fixes bug #10136 (Documentation typos). Signed-off-by: Bjoern Jacke <bj@sernet.de> Reviewed-by: Karolin Seeger <kseeger@samba.org> Autobuild-User(master): Karolin Seeger <kseeger@samba.org> Autobuild-Date(master): Thu Sep 12 13:54:41 CEST 2013 on sn-devel-104
* tdb: Fix CID 1034959 Uninitialized scalar variableVolker Lendecke2013-07-221-1/+1
| | | | | | | | | log_ctx.log_private was used uninitialized. Not a real bug here, as tdb_log does not access it, but tdb_open_ex still moves around uninitialized data. So this would show up in valgrind as well. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: Fix CID 1034960 Uninitialized scalar variableVolker Lendecke2013-07-221-1/+1
| | | | | | | | | log_ctx.log_private was used uninitialized. Not a real bug here, as tdb_log does not access it, but tdb_open_ex still moves around uninitialized data. So this would show up in valgrind as well. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* Fix bug 10025 - Lack of Sanity Checking in calls to malloc()/calloc().Bill Parker2013-07-172-0/+13
| | | | | | | | | | | | | In reviewing various files in Samba-4.0.7, I found a number of instances where malloc()/calloc() were called without the checking the return value for a value of NULL, which would indicate failure. (NB. The changes needed to ccan, iniparser, popt and heimdal will be reported upstream, not patched inside Samba). Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Simo Source <idra@samba.org>
* tdb: Fix typos.Ralph Wuerthner2013-06-071-2/+2
| | | | | | | | Reviewed-by: Christian Ambach <ambi@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Fri Jun 7 15:18:47 CEST 2013 on sn-devel-104
* Add "repack" command to tdbtool documentation.Ralph Wuerthner2013-06-071-1/+9
| | | | | | | | | The original commit 'Add "repack" command to tdbtool.' only added the documentation to docs-xml/manpages-3/tdbtool.8.xml and forgot about lib/tdb/manpages/tdbtool.8.xml . Reviewed-by: Christian Ambach <ambi@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: change version to tdb-1.2.12Stefan Metzmacher2013-06-042-1/+68
| | | | | | | | | | | | | | * internal code cleanups * crash fix for pytdb * fix for 4GB overflow detection See http://permalink.gmane.org/gmane.network.samba.internals/42906 for an example of what happens. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Tue Jun 4 16:07:55 CEST 2013 on sn-devel-104