summaryrefslogtreecommitdiff
path: root/ctdb/lib
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-01-18 10:47:11 +1030
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2011-01-18 14:07:41 +1100
commite68b97ffc9823dc18b4477553dda3cb7c4b5590e (patch)
tree2f4538b17202c99c45acb06d47adc3e660a978b2 /ctdb/lib
parent849ef2e39b85521dd8fcfa2497f93756c7ba09f2 (diff)
downloadsamba-e68b97ffc9823dc18b4477553dda3cb7c4b5590e.tar.gz
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')
-rw-r--r--ctdb/lib/tdb/common/lock.c20
-rw-r--r--ctdb/lib/tdb/include/tdb.h4
2 files changed, 24 insertions, 0 deletions
diff --git a/ctdb/lib/tdb/common/lock.c b/ctdb/lib/tdb/common/lock.c
index 803feeecbb0..f0da8818d19 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 aac7c9221de..536a0b37372 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);