tdb: don't suppress the transaction lock because of the allrecord lock.
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 17 Feb 2010 02:01:49 +0000 (12:31 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 17 Feb 2010 02:01:49 +0000 (12:31 +1030)
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>
lib/tdb/common/lock.c

index e3759a3f8dddd38465fa4da4fdaea992cecb264c..66cfcbdeea6eab9cd943f7b18a9dd8f66e4c9f8e 100644 (file)
@@ -420,9 +420,6 @@ int tdb_unlock(struct tdb_context *tdb, int list, int ltype)
  */
 int tdb_transaction_lock(struct tdb_context *tdb, int ltype)
 {
  */
 int tdb_transaction_lock(struct tdb_context *tdb, int ltype)
 {
-       if (tdb->allrecord_lock.count) {
-               return 0;
-       }
        if (tdb->transaction_lock_count > 0) {
                tdb->transaction_lock_count++;
                return 0;
        if (tdb->transaction_lock_count > 0) {
                tdb->transaction_lock_count++;
                return 0;
@@ -443,9 +440,6 @@ int tdb_transaction_lock(struct tdb_context *tdb, int ltype)
 int tdb_transaction_unlock(struct tdb_context *tdb, int ltype)
 {
        int ret;
 int tdb_transaction_unlock(struct tdb_context *tdb, int ltype)
 {
        int ret;
-       if (tdb->allrecord_lock.count) {
-               return 0;
-       }
        if (tdb->transaction_lock_count > 1) {
                tdb->transaction_lock_count--;
                return 0;
        if (tdb->transaction_lock_count > 1) {
                tdb->transaction_lock_count--;
                return 0;