1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

tdb: cleanup: remove ltype argument from _tdb_transaction_cancel.

Now the transaction allrecord lock is the standard one, and thus is cleaned
in tdb_release_extra_locks(), _tdb_transaction_cancel() doesn't need to
know what type it is.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2010-02-24 12:42:24 +10:30
parent fca1621965
commit dd1b508c63

View File

@ -577,8 +577,7 @@ static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t
}
/* ltype is F_WRLCK after prepare. */
static int _tdb_transaction_cancel(struct tdb_context *tdb, int ltype)
static int _tdb_transaction_cancel(struct tdb_context *tdb)
{
int i, ret = 0;
@ -633,11 +632,8 @@ static int _tdb_transaction_cancel(struct tdb_context *tdb, int ltype)
*/
int tdb_transaction_cancel(struct tdb_context *tdb)
{
int ltype = F_RDLCK;
tdb_trace(tdb, "tdb_transaction_cancel");
if (tdb->transaction && tdb->transaction->prepared)
ltype = F_WRLCK;
return _tdb_transaction_cancel(tdb, ltype);
return _tdb_transaction_cancel(tdb);
}
/*
@ -903,14 +899,14 @@ static int _tdb_transaction_prepare_commit(struct tdb_context *tdb)
if (tdb->transaction->prepared) {
tdb->ecode = TDB_ERR_EINVAL;
_tdb_transaction_cancel(tdb, F_WRLCK);
_tdb_transaction_cancel(tdb);
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_prepare_commit: transaction already prepared\n"));
return -1;
}
if (tdb->transaction->transaction_error) {
tdb->ecode = TDB_ERR_IO;
_tdb_transaction_cancel(tdb, F_RDLCK);
_tdb_transaction_cancel(tdb);
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_prepare_commit: transaction error pending\n"));
return -1;
}
@ -932,14 +928,14 @@ static int _tdb_transaction_prepare_commit(struct tdb_context *tdb)
if (tdb_have_extra_locks(tdb)) {
tdb->ecode = TDB_ERR_LOCK;
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_prepare_commit: locks pending on commit\n"));
_tdb_transaction_cancel(tdb, F_RDLCK);
_tdb_transaction_cancel(tdb);
return -1;
}
/* upgrade the main transaction lock region to a write lock */
if (tdb_allrecord_upgrade(tdb) == -1) {
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_prepare_commit: failed to upgrade hash locks\n"));
_tdb_transaction_cancel(tdb, F_RDLCK);
_tdb_transaction_cancel(tdb);
return -1;
}
@ -947,7 +943,7 @@ static int _tdb_transaction_prepare_commit(struct tdb_context *tdb)
during the commit */
if (tdb_nest_lock(tdb, OPEN_LOCK, F_WRLCK, TDB_LOCK_WAIT) == -1) {
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_prepare_commit: failed to get open lock\n"));
_tdb_transaction_cancel(tdb, F_WRLCK);
_tdb_transaction_cancel(tdb);
return -1;
}
@ -955,7 +951,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_transaction_cancel(tdb, F_WRLCK);
_tdb_transaction_cancel(tdb);
return -1;
}
}
@ -969,7 +965,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_transaction_cancel(tdb, F_WRLCK);
_tdb_transaction_cancel(tdb);
return -1;
}
tdb->map_size = tdb->transaction->old_map_size;
@ -1008,7 +1004,7 @@ int tdb_transaction_commit(struct tdb_context *tdb)
if (tdb->transaction->transaction_error) {
tdb->ecode = TDB_ERR_IO;
_tdb_transaction_cancel(tdb, F_RDLCK);
_tdb_transaction_cancel(tdb);
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_commit: transaction error pending\n"));
return -1;
}
@ -1021,7 +1017,7 @@ int tdb_transaction_commit(struct tdb_context *tdb)
/* check for a null transaction */
if (tdb->transaction->blocks == NULL) {
_tdb_transaction_cancel(tdb, F_RDLCK);
_tdb_transaction_cancel(tdb);
return 0;
}
@ -1057,7 +1053,7 @@ int tdb_transaction_commit(struct tdb_context *tdb)
tdb->methods = methods;
tdb_transaction_recover(tdb);
_tdb_transaction_cancel(tdb, F_WRLCK);
_tdb_transaction_cancel(tdb);
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: write failed\n"));
return -1;
@ -1092,7 +1088,7 @@ int tdb_transaction_commit(struct tdb_context *tdb)
/* use a transaction cancel to free memory and remove the
transaction locks */
_tdb_transaction_cancel(tdb, F_WRLCK);
_tdb_transaction_cancel(tdb);
if (need_repack) {
return tdb_repack(tdb);