X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb%2Ftransaction.c;h=34137251bce51f2697184fbd8dc515315b9d64c6;hp=c2e4748a8e7c668acb9c568660a59ab9c2f4cff6;hb=3f011090d857a625f9eccfca6dd33d1b897417a8;hpb=b2c0ebc6f53b05b222937991f100f8a89701f9b1 diff --git a/ccan/tdb/transaction.c b/ccan/tdb/transaction.c index c2e4748a..34137251 100644 --- a/ccan/tdb/transaction.c +++ b/ccan/tdb/transaction.c @@ -144,14 +144,6 @@ static int transaction_read(struct tdb_context *tdb, tdb_off_t off, void *buf, { uint32_t blk; - /* Only a commit is allowed on a prepared transaction */ - if (tdb->transaction->prepared) { - tdb->ecode = TDB_ERR_EINVAL; - TDB_LOG((tdb, TDB_DEBUG_FATAL, "transaction_read: transaction already prepared, read not allowed\n")); - tdb->transaction->transaction_error = 1; - return -1; - } - /* break it down into block sized ops */ while (len + (off % tdb->transaction->block_size) > tdb->transaction->block_size) { tdb_len_t len2 = tdb->transaction->block_size - (off % tdb->transaction->block_size); @@ -927,11 +919,6 @@ static int _tdb_transaction_prepare_commit(struct tdb_context *tdb) return 0; } -#ifdef TDB_TRACE - /* store seqnum now, before reading becomes illegal. */ - tdb_ofs_read(tdb, TDB_SEQNUM_OFS, &tdb->transaction_prepare_seqnum); -#endif - /* check for a null transaction */ if (tdb->transaction->blocks == NULL) { return 0; @@ -969,7 +956,7 @@ static int _tdb_transaction_prepare_commit(struct tdb_context *tdb) /* write the recovery data to the end of the file */ if (transaction_setup_recovery(tdb, &tdb->transaction->magic_offset) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_prepare_commit: failed to setup recovery data\n")); - tdb_brunlock(tdb, F_WRLCK, GLOBAL_LOCK, 0); + tdb_brunlock(tdb, F_WRLCK, GLOBAL_LOCK, 1); _tdb_transaction_cancel(tdb, F_WRLCK); return -1; } @@ -984,7 +971,7 @@ static int _tdb_transaction_prepare_commit(struct tdb_context *tdb) tdb->transaction->old_map_size) == -1) { tdb->ecode = TDB_ERR_IO; TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_prepare_commit: expansion failed\n")); - tdb_brunlock(tdb, F_WRLCK, GLOBAL_LOCK, 0); + tdb_brunlock(tdb, F_WRLCK, GLOBAL_LOCK, 1); _tdb_transaction_cancel(tdb, F_WRLCK); return -1; } @@ -1020,13 +1007,7 @@ int tdb_transaction_commit(struct tdb_context *tdb) return -1; } - /* If we've prepared, can't read seqnum. */ - if (tdb->transaction->prepared) { - tdb_trace_seqnum(tdb, tdb->transaction_prepare_seqnum, - "tdb_transaction_commit"); - } else { - tdb_trace(tdb, "tdb_transaction_commit"); - } + tdb_trace(tdb, "tdb_transaction_commit"); if (tdb->transaction->transaction_error) { tdb->ecode = TDB_ERR_IO; @@ -1080,7 +1061,7 @@ int tdb_transaction_commit(struct tdb_context *tdb) tdb_transaction_recover(tdb); _tdb_transaction_cancel(tdb, F_WRLCK); - tdb_brunlock(tdb, F_WRLCK, GLOBAL_LOCK, 0); + tdb_brunlock(tdb, F_WRLCK, GLOBAL_LOCK, 1); TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: write failed\n")); return -1;