- 22 Feb, 2010 17 commits
-
-
Rusty Russell authored
Now the transaction allrecord lock the standard one, and thus is cleaned in tdb_release_extra_locks(), _tdb_transaction_cancel() doesn't need to know what type it is. Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
Centralize locking of all chains of the tdb; rename _tdb_lockall to tdb_allrecord_lock and _tdb_unlockall to tdb_allrecord_unlock, and tdb_brlock_upgrade to tdb_allrecord_upgrade. Then we use this in the transaction code. Unfortunately, if the transaction code records that it has grabbed the allrecord lock read-only, write locks will fail, so we treat this upgradable lock as a write lock, and mark it as upgradable using the otherwise-unused offset field. One subtlety: now the transaction code is using the allrecord_lock, the tdb_release_extra_locks() function drops it for us, so we no longer need to do it manually in _tdb_transaction_cancel. Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
We were previously inconsistent with our "global" lock: the transaction code grabbed it from FREELIST_TOP to end of file, and the rest of the code grabbed it from FREELIST_TOP to end of the hash chains. Change it to always grab to end of file for simplicity. Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
This was redundant before this patch series: it mirrored num_lockrecs exactly. It still does. Also, skip useless branch when locks == 1: unconditional assignment is cheaper anyway. Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
This is pure overhead, but it centralizes the locking. Realloc (esp. as most implementations are lazy) is fast compared to the fnctl anyway. Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
Rather than a boutique lock and a separate nest count, use our newly-generic nested lock tracking for the active lock. Note that the tdb_have_extra_locks() and tdb_release_extra_locks() functions have to skip over this lock now it is tracked. Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
This never nests, so it's overkill, but it centralizes the locking into lock.c and removes the ugly flag in the transaction code to track whether we have the lock or not. Note that we have a temporary hack so this places a real lock, despite the fact that we are in a transaction. Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
Rather than a boutique lock and a separate nest count, use our newly-generic nested lock tracking for the transaction lock. Note that the tdb_have_extra_locks() and tdb_release_extra_locks() functions have to skip over this lock now it is tracked. Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
Factor out two loops which find locks; we are going to introduce a couple more so a helper makes sense. Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
Move locking intelligence back into lock.c. Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
In many places we check whether locks are held: add a helper to do this. The _tdb_lockall() case has already checked for the allrecord lock, so the extra work done by tdb_have_extra_locks() is merely redundant. Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
tdb_transaction_lock() and tdb_transaction_unlock() do nothing if we hold the allrecord lock. However, the two locks don't overlap, so this is wrong. This simplification makes the transaction lock a straight-forward nested lock. There are two callers for these functions: 1) The transaction code, which already makes sure the allrecord_lock isn't held. 2) The traverse code, which wants to stop transactions whether it has the allrecord lock or not. There have been deadlocks here before, however this should not bring them back (I hope!) Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
Because fcntl locks don't nest, we track them in the tdb->lockrecs array and only place/release them when the count goes to 1/0. We only do this for record locks, so we simply place the list number (or -1 for the free list) in the structure. To generalize this: 1) Put the offset rather than list number in struct tdb_lock_type. 2) Rename _tdb_lock() to tdb_nest_lock, make it non-static and move the allrecord check out to the callers (except the mark case which doesn't care). 3) Rename _tdb_unlock() to tdb_nest_unlock(), make it non-static and move the allrecord out to the callers (except mark again). Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
The word global is overloaded in tdb. The global_lock inside struct tdb_context is used to indicate we hold a lock across all the chains. Rename it to allrecord_lock. Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
The word global is overloaded in tdb. The GLOBAL_LOCK offset is used at open time to serialize initialization (and by the transaction code to block open). Rename it to OPEN_LOCK. Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
Author: Volker Lendecke <vl@samba.org> Date: Tue Aug 12 22:31:52 2008 +0200 Attempt to fix bug 5684 With the ctdb checkin dde9f3f006 tdb optimized out write lock checks for write-enabled transaction. Sadly, this also removed the possibility to ever remove dead records left over from tdb_delete calls within a transaction. Tridge, please check this! Did dde9f3f006 have any reason beyond performance optimizations? Thanks, Volker (This used to be commit 3f884c4ae36f3260e63626bdd4989d9258ae6497)
-
Rusty Russell authored
Whitespace and C++-compatibility mainly.
-
- 11 Feb, 2010 1 commit
-
-
Rusty Russell authored
-
- 04 Feb, 2010 4 commits
-
-
Rusty Russell authored
-
Rusty Russell authored
This patch is made larger by moving the work out to a separate function: with -k, the parent can't run the ops itself but the children must do it.
-
Rusty Russell authored
-
Rusty Russell authored
This demonstrates some serious failings, which get cleaned up in following patches.
-
- 02 Feb, 2010 11 commits
-
-
Rusty Russell authored
-
Rusty Russell authored
-
Rusty Russell authored
Author: Volker Lendecke <vl@samba.org> 2010-01-30 03:51:09 tdb: fix an early release of the global lock that can cause data corruption There was a bug in tdb where the tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1); (ending the transaction-"mutex") was done before the /* remove the recovery marker */ This means that when a transaction is committed there is a window where another opener of the file sees the transaction marker while the transaction committer is still fully functional and working on it. This led to transaction being rolled back by that second opener of the file while transaction_commit() gave no error to the caller. This patch moves the F_UNLCK to after the recovery marker was removed, closing this window.
-
Rusty Russell authored
Add more logging.
-
Rusty Russell authored
Unlike the upstream, we don't have a stable ABI/API.
-
Rusty Russell authored
tdb: add TDB_DISALLOW_NESTING and make TDB_ALLOW_NESTING the default behavior We need to keep TDB_ALLOW_NESTING as default behavior, so that existing code continues to work. However we may change the default together with a major version number change in future. metze (cherry picked from samba commit 3b9f19ed919fef2e88b2f92ae541e07bc7379cd1) Signed-off-by:
Stefan Metzmacher <metze@samba.org>
-
Rusty Russell authored
tdb: always set tdb->tracefd to -1 to be safe on goto fail metze (cherry picked from samba commit 85449b7bcc4bd7948bea38b5514a02357950a002) Signed-off-by:
Stefan Metzmacher <metze@samba.org>
-
Rusty Russell authored
tdb: reset tdb->fd to -1 in tdb_close() So that erroneous double tdb_close() calls do not try to close() same fd again. This is like SAFE_FREE() but for fd. Signed-off-by:
Kirill Smelkov <kirr@mns.spb.ru> Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au> (cherry picked from samba commit b4424f8234a78a79fb2d71d46ca208b4f12e0f9e) Signed-off-by:
Stefan Metzmacher <metze@samba.org>
-
Rusty Russell authored
tdb: detect tdb store of identical records and skip This can help with ldb where we rewrite the index records (cherry picked from samba commit d4c0e8fdf063f88032c32de7ece60d502b322089) Signed-off-by:
Stefan Metzmacher <metze@samba.org>
-
Rusty Russell authored
tdb: rename 'struct list_struct' into 'struct tdb_record' metze (cherry picked from samba commit 3b62e250c066f44d0ab08a7db037b6b4f74a914b) Signed-off-by:
Stefan Metzmacher <metze@samba.org>
-
Rusty Russell authored
-
- 01 Feb, 2010 2 commits
-
-
Rusty Russell authored
-
Rusty Russell authored
-
- 23 Jan, 2010 1 commit
-
-
Rusty Russell authored
-
- 20 Jan, 2010 1 commit
-
-
Rusty Russell authored
-
- 19 Jan, 2010 1 commit
-
-
Rusty Russell authored
-
- 18 Jan, 2010 1 commit
-
-
Rusty Russell authored
(Also, remove bogus test dependency for hdr include check)
-
- 17 Jan, 2010 1 commit
-
-
Rusty Russell authored
-