diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2011-01-18 10:47:11 +1030 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2011-01-18 14:07:41 +1100 |
commit | e68b97ffc9823dc18b4477553dda3cb7c4b5590e (patch) | |
tree | 2f4538b17202c99c45acb06d47adc3e660a978b2 /ctdb/lib/tdb | |
parent | 849ef2e39b85521dd8fcfa2497f93756c7ba09f2 (diff) | |
download | samba-e68b97ffc9823dc18b4477553dda3cb7c4b5590e.tar.gz samba-e68b97ffc9823dc18b4477553dda3cb7c4b5590e.tar.xz samba-e68b97ffc9823dc18b4477553dda3cb7c4b5590e.zip |
tdb: expose transaction lock infrastructure for ctdb
tdb_traverse_read() grabs the transaction lock. This can cause ctdbd
(which uses it) to block when it should not; expose mark and normal
variants of this lock, so ctdbd's child (the recovery daemon) can
acquire it and the ctdbd parent can mark it was held.
(This used to be ctdb commit d09fa845bd848d04507853809acf42e0471b44bf)
Diffstat (limited to 'ctdb/lib/tdb')
-rw-r--r-- | ctdb/lib/tdb/common/lock.c | 20 | ||||
-rw-r--r-- | ctdb/lib/tdb/include/tdb.h | 4 |
2 files changed, 24 insertions, 0 deletions
diff --git a/ctdb/lib/tdb/common/lock.c b/ctdb/lib/tdb/common/lock.c index 803feeecbb..f0da8818d1 100644 --- a/ctdb/lib/tdb/common/lock.c +++ b/ctdb/lib/tdb/common/lock.c @@ -861,3 +861,23 @@ void tdb_release_transaction_locks(struct tdb_context *tdb) SAFE_FREE(tdb->lockrecs); } } + +int tdb_transaction_write_lock_mark(struct tdb_context *tdb) +{ + return tdb_transaction_lock(tdb, F_WRLCK, TDB_LOCK_MARK_ONLY); +} + +int tdb_transaction_write_lock(struct tdb_context *tdb) +{ + return tdb_transaction_lock(tdb, F_WRLCK, 0); +} + +int tdb_transaction_write_unlock(struct tdb_context *tdb) +{ + return tdb_transaction_unlock(tdb, F_WRLCK); +} + +int tdb_transaction_write_lock_unmark(struct tdb_context *tdb) +{ + return tdb_nest_unlock(tdb, TRANSACTION_LOCK, F_WRLCK, true); +} diff --git a/ctdb/lib/tdb/include/tdb.h b/ctdb/lib/tdb/include/tdb.h index aac7c9221d..536a0b3737 100644 --- a/ctdb/lib/tdb/include/tdb.h +++ b/ctdb/lib/tdb/include/tdb.h @@ -161,6 +161,10 @@ _PUBLIC_ int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key); _PUBLIC_ int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key); _PUBLIC_ int tdb_chainlock_mark(struct tdb_context *tdb, TDB_DATA key); _PUBLIC_ int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key); +_PUBLIC_ int tdb_transaction_write_lock(struct tdb_context *tdb); +_PUBLIC_ int tdb_transaction_write_unlock(struct tdb_context *tdb); +_PUBLIC_ int tdb_transaction_write_lock_mark(struct tdb_context *tdb); +_PUBLIC_ int tdb_transaction_write_lock_unmark(struct tdb_context *tdb); _PUBLIC_ void tdb_setalarm_sigptr(struct tdb_context *tdb, volatile sig_atomic_t *sigptr); |