summaryrefslogtreecommitdiffstats
path: root/lib/tdb
Commit message (Collapse)AuthorAgeFilesLines
* tdb: Fix CID 1034842 Resource leakHEADmasterVolker Lendecke2015-03-111-0/+1
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ira Cooper <ira@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Wed Mar 11 00:23:20 CET 2015 on sn-devel-104
* tdb: Fix CID 1034841 Resource leakVolker Lendecke2015-03-101-3/+5
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ira Cooper <ira@samba.org>
* tdb: version 1.3.4Stefan Metzmacher2014-12-192-1/+69
| | | | | | | | | | | | Transactions are supported with TDB_MUTEX_LOCKING. This fixes https://bugzilla.samba.org/show_bug.cgi?id=11004 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Fri Dec 19 11:41:26 CET 2014 on sn-devel-104
* tdb/toos: allow transactions with TDB_MUTEX_LOCKINGStefan Metzmacher2014-12-191-1/+0
| | | | | | | Bug: https://bugzilla.samba.org/show_bug.cgi?id=11004 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* tdb/test: add tdb1-run-mutex-transaction1 testStefan Metzmacher2014-12-192-0/+237
| | | | | | | Bug: https://bugzilla.samba.org/show_bug.cgi?id=11004 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* tdb: allow transactions on on tdb's with TDB_MUTEX_LOCKINGStefan Metzmacher2014-12-191-1/+1
| | | | | | | | | | | | | There's no real reason to disallow transactions as the allrecord lock is also available with mutexes enabled. E.g. ctdbd requires transactions also on non-persistent databases opened with TDB_CLEAR_IF_FIRST and TDB_MUTEX_LOCKING. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11004 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* tdb: version 1.3.3Stefan Metzmacher2014-12-022-1/+69
| | | | | | | | | | | | This fixes the tdb1-run-mutex-openflags2 test when robust mutexes are available. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10781 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): Tue Dec 2 11:54:28 CET 2014 on sn-devel-104
* tdb/test: TDB_CLEAR_IF_FIRST | TDB_MUTEX_LOCKING, O_RDONLY is a valid ↵Stefan Metzmacher2014-12-021-2/+3
| | | | | | | | | | | | | | | combination This used to be invalid in the early developement code, but now we're able to open a tdb with mutex area and TDB_NOLOCK without problems. O_RDONLY implies TDB_NOLOCK... This should have been part of commit c8d05e934ea03fffbc34944d2d51a016b89a7eca. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10781 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: version 1.3.2Stefan Metzmacher2014-11-292-1/+69
| | | | | | | | | | | | | | | The following bugs are fixed with this release: - Bug 10625 - tdb.h missing include of stdbool.h - Bug 10781 - smbstatus: locking.tdb - TDB_MUTEX_LOCKING requires TDB_CLEAR_IF_FIRST - Bug 10968 - tdb mutex runtime test clobbers stdout Bug: https://bugzilla.samba.org/show_bug.cgi?id=10625 Bug: https://bugzilla.samba.org/show_bug.cgi?id=10781 Bug: https://bugzilla.samba.org/show_bug.cgi?id=10968 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: Fix tdb_runtime_check_for_robust_mutexes()Volker Lendecke2014-11-261-4/+4
| | | | | | | | | | When using exit() instead of _exit(), the child will flush buffered stdout (and other stdio) content that it inherited from the parent process. In make test, this led to duplicate output from net registry which then confused the blackbox selftest. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tdb: allow tdb_open_ex() with O_RDONLY of TDB_FEATURE_FLAG_MUTEX tdbs.Stefan Metzmacher2014-11-201-9/+9
| | | | | | | Bug: https://bugzilla.samba.org/show_bug.cgi?id=10781 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* tdb: Fix a commentVolker Lendecke2014-09-301-1/+1
| | | | | | | | 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 Sep 30 23:08:07 CEST 2014 on sn-devel-104
* tdb: Improve wording in a commentVolker Lendecke2014-09-251-1/+1
| | | | | | | | 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): Thu Sep 25 00:59:16 CEST 2014 on sn-devel-104
* tdb: tdb.h needs bool typeMartin Schwenke2014-09-191-0/+1
| | | | | | | Due to introduction of tdb_runtime_check_for_robust_mutexes(). Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: change version to 1.3.1Michael Adam2014-09-162-1/+69
| | | | | | | | | | | | | * internal code cleanup * improved free record detection with a highly contended freelist on tdb's with dead record support (TDB_VOLATILE). * implicit defragmentation of the free list. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Tue Sep 16 12:13:31 CEST 2014 on sn-devel-104
* tdb:tools: fix a compiler warningStefan Metzmacher2014-09-161-4/+4
| | | | | | | | | ../../tdb/tools/tdbtool.c: In function ‘do_command’: ../../tdb/tools/tdbtool.c:717: error: declaration of ‘count’ shadows a global declaration ../../tdb/tools/tdbtool.c:597: error: shadowed declaration is here Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tdbtorture: print details when run with -n 1David Disseldorp2014-08-181-4/+4
| | | | | | | | | | | | | Currently tdbtorture prints the test details (processes, loops, etc.) from the first forked child process. When run with -n 1 (one process), the test is run from within the parent and no details are printed. This change ensures that they are. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Mon Aug 18 13:26:32 CEST 2014 on sn-devel-104
* tdb: defragment the freelist in tdb_allocate_from_freelist()Michael Adam2014-06-261-0/+55
| | | | | | | | | | | | | | | | | | | | While we are traversing the freelist anyways, merge a record with the left if it is also a free list record. That partially makes up for the fragmentation introduced by the lack of merging with right records in tdb_free(). Note there is a potential slight downside: If the left record we merge the current record into was earlier in the chain and has hence already been met in traverse, then we can not use the enlarged record even if it might be a new best fit. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Thu Jun 26 12:16:03 CEST 2014 on sn-devel-104
* tdb: add "freelist_size" sub-command to tdbtoolMichael Adam2014-06-261-0/+15
| | | | | | | | | With the new code, this has the side effect of merging adjacent records in the freelist if the database is not read-only. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: use tdb_freelist_merge_adjacent in tdb_freelist_size()Michael Adam2014-06-261-4/+29
| | | | | | | | So that we automatically defragment the free list when freelist_size is called (unless the database is read only). Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: add tdb_freelist_merge_adjacent()Michael Adam2014-06-261-0/+59
| | | | | | | | | | | | | | | | This is intended to be called to reduce the fragmentation in the freelist. This is to make up the deficiency of the freelist to be not doubly linked. If the freelist were doubly linked, we could easily avoid the creation of adjacent freelist entries. But with the current singly linked list, it is only possible to cheaply merge a new free record into a freelist entry on the left, not on the right... This can be called periodically, e.g. in the vacuuming process of a ctdb cluster. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: add utility function check_merge_ptr_with_left_record()Michael Adam2014-06-261-0/+53
| | | | | | | | Variant of check_merge_with_left_record() that reads the record itself if necessary. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: simplify tdb_free() using check_merge_with_left_record()Michael Adam2014-06-261-17/+9
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: add utility function check_merge_with_left_record()Michael Adam2014-06-261-0/+50
| | | | | | | | Check whether the record left of a given freelist record is also a freelist record, and if so, merge the two records. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: improve comments for tdb_free().Michael Adam2014-06-261-7/+11
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: factor merge_with_left_record() out of tdb_free()Michael Adam2014-06-261-7/+37
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: fix debug message in tdb_free()Michael Adam2014-06-261-1/+1
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: reduce indentation in tdb_free() for merging leftMichael Adam2014-06-261-18/+23
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: increase readability of read_record_on_left()Michael Adam2014-06-261-27/+41
| | | | | | | | by using early returns and better variable names, and reducing indentation. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb: factor read_record_on_left() out of tdb_free()Michael Adam2014-06-261-30/+49
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* tdb:build: improve detection of srcdir.Michael Adam2014-06-201-1/+1
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* 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