tdb2: allow multiple chain locks.
[ccan] / ccan / tdb2 / transaction.c
index 29192beece4e3e48f0a6a337c677af2e14c0de63..68ae234d2f90ccbe4fb993dd27476df7c89afba2 100644 (file)
@@ -682,7 +682,7 @@ static enum TDB_ERROR tdb_recovery_allocate(struct tdb_context *tdb,
           us an area that is being currently used (as of the start of
           the transaction) */
        if (recovery_head != 0) {
-               add_stat(tdb, frees, 1);
+               tdb->stats.frees++;
                ecode = add_free_record(tdb, recovery_head,
                                        sizeof(rec) + rec.max_len);
                if (ecode != TDB_SUCCESS) {
@@ -921,10 +921,6 @@ static enum TDB_ERROR _tdb_transaction_prepare_commit(struct tdb_context *tdb)
        /* upgrade the main transaction lock region to a write lock */
        ecode = tdb_allrecord_upgrade(tdb);
        if (ecode != TDB_SUCCESS) {
-               tdb_logerr(tdb, ecode, TDB_LOG_ERROR,
-                        "tdb_transaction_prepare_commit:"
-                        " failed to upgrade hash locks");
-               _tdb_transaction_cancel(tdb);
                return ecode;
        }
 
@@ -932,10 +928,6 @@ static enum TDB_ERROR _tdb_transaction_prepare_commit(struct tdb_context *tdb)
           during the commit */
        ecode = tdb_lock_open(tdb, TDB_LOCK_WAIT|TDB_LOCK_NOCHECK);
        if (ecode != TDB_SUCCESS) {
-               tdb_logerr(tdb, ecode, TDB_LOG_ERROR,
-                          "tdb_transaction_prepare_commit:"
-                          " failed to get open lock");
-               _tdb_transaction_cancel(tdb);
                return ecode;
        }
 
@@ -946,10 +938,6 @@ static enum TDB_ERROR _tdb_transaction_prepare_commit(struct tdb_context *tdb)
                                                   &tdb->transaction
                                                   ->magic_offset);
                if (ecode != TDB_SUCCESS) {
-                       tdb_logerr(tdb, ecode, TDB_LOG_ERROR,
-                                "tdb_transaction_prepare_commit:"
-                                " failed to setup recovery data");
-                       _tdb_transaction_cancel(tdb);
                        return ecode;
                }
        }
@@ -965,10 +953,6 @@ static enum TDB_ERROR _tdb_transaction_prepare_commit(struct tdb_context *tdb)
                tdb->file->map_size = tdb->transaction->old_map_size;
                ecode = methods->expand_file(tdb, add);
                if (ecode != TDB_SUCCESS) {
-                       tdb_logerr(tdb, ecode, TDB_LOG_ERROR,
-                                "tdb_transaction_prepare_commit:"
-                                " expansion failed");
-                       _tdb_transaction_cancel(tdb);
                        return ecode;
                }
        }
@@ -1016,8 +1000,10 @@ enum TDB_ERROR tdb_transaction_commit(struct tdb_context *tdb)
 
        if (!tdb->transaction->prepared) {
                ecode = _tdb_transaction_prepare_commit(tdb);
-               if (ecode != TDB_SUCCESS)
+               if (ecode != TDB_SUCCESS) {
+                       _tdb_transaction_cancel(tdb);
                        return tdb->last_error = ecode;
+               }
        }
 
        methods = tdb->transaction->io_methods;
@@ -1040,10 +1026,6 @@ enum TDB_ERROR tdb_transaction_commit(struct tdb_context *tdb)
                ecode = methods->twrite(tdb, offset,
                                        tdb->transaction->blocks[i], length);
                if (ecode != TDB_SUCCESS) {
-                       tdb_logerr(tdb, ecode, TDB_LOG_ERROR,
-                                  "tdb_transaction_commit:"
-                                  " write failed during commit");
-
                        /* we've overwritten part of the data and
                           possibly expanded the file, so we need to
                           run the crash recovery code */