X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Ftdb1_transaction.c;h=d35c4bc4662463da5c2734e1092abcc59ba6efff;hb=2b50be90a23893a06e0f1436a31d18b97ad0e11d;hp=165fd7f972f5b74dd0d1de0271c97ec9e502ebbe;hpb=919937354a331bb964564a11b5a5b80403ff8db9;p=ccan diff --git a/ccan/tdb2/tdb1_transaction.c b/ccan/tdb2/tdb1_transaction.c index 165fd7f9..d35c4bc4 100644 --- a/ccan/tdb2/tdb1_transaction.c +++ b/ccan/tdb2/tdb1_transaction.c @@ -81,25 +81,16 @@ usual. This allows for smooth crash recovery with no administrator intervention. - - if TDB1_NOSYNC is passed to flags in tdb1_open then transactions are + - if TDB_NOSYNC is passed to flags in tdb1_open then transactions are still available, but no transaction recovery area is used and no fsync/msync calls are made. - - if TDB1_ALLOW_NESTING is passed to flags in tdb open, or added using + - if TDB_ALLOW_NESTING is passed to flags in tdb open, or added using tdb1_add_flags() transaction nesting is enabled. - It resets the TDB1_DISALLOW_NESTING flag, as both cannot be used together. - The default is that transaction nesting is allowed. - Note: this default may change in future versions of tdb. + The default is that transaction nesting is NOT allowed. Beware. when transactions are nested a transaction successfully completed with tdb1_transaction_commit() can be silently unrolled later. - - - if TDB1_DISALLOW_NESTING is passed to flags in tdb open, or added using - tdb1_add_flags() transaction nesting is disabled. - It resets the TDB1_ALLOW_NESTING flag, as both cannot be used together. - An attempt create a nested transaction will fail with TDB_ERR_EINVAL. - The default is that transaction nesting is allowed. - Note: this default may change in future versions of tdb. */ @@ -427,7 +418,7 @@ static const struct tdb1_methods transaction1_methods = { static int _tdb1_transaction_start(struct tdb1_context *tdb) { /* some sanity checks */ - if (tdb->read_only || (tdb->flags & TDB1_INTERNAL) || tdb->traverse_read) { + if (tdb->read_only || (tdb->flags & TDB_INTERNAL) || tdb->traverse_read) { tdb->last_error = tdb_logerr(tdb, TDB_ERR_EINVAL, TDB_LOG_USE_ERROR, "tdb1_transaction_start: cannot start a" " transaction on a read-only or" @@ -437,7 +428,7 @@ static int _tdb1_transaction_start(struct tdb1_context *tdb) /* cope with nested tdb1_transaction_start() calls */ if (tdb->transaction != NULL) { - if (!(tdb->flags & TDB1_ALLOW_NESTING)) { + if (!(tdb->flags & TDB_ALLOW_NESTING)) { tdb->last_error = TDB_ERR_EINVAL; return -1; } @@ -478,7 +469,7 @@ static int _tdb1_transaction_start(struct tdb1_context *tdb) /* get the transaction write lock. This is a blocking lock. As discussed with Volker, there are a number of ways we could make this async, which we will probably do in the future */ - if (tdb1_transaction_lock(tdb, F_WRLCK, TDB1_LOCK_WAIT) == -1) { + if (tdb1_transaction_lock(tdb, F_WRLCK, TDB_LOCK_WAIT) == -1) { SAFE_FREE(tdb->transaction->blocks); SAFE_FREE(tdb->transaction); return -1; @@ -486,7 +477,7 @@ static int _tdb1_transaction_start(struct tdb1_context *tdb) /* get a read lock from the freelist to the end of file. This is upgraded to a write lock during the commit */ - if (tdb1_allrecord_lock(tdb, F_RDLCK, TDB1_LOCK_WAIT, true) == -1) { + if (tdb1_allrecord_lock(tdb, F_RDLCK, TDB_LOCK_WAIT, true) == -1) { tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR, "tdb1_transaction_start: failed to get hash locks"); goto fail_allrecord_lock; @@ -539,7 +530,7 @@ int tdb1_transaction_start(struct tdb1_context *tdb) */ static int transaction1_sync(struct tdb1_context *tdb, tdb1_off_t offset, tdb1_len_t length) { - if (tdb->flags & TDB1_NOSYNC) { + if (tdb->flags & TDB_NOSYNC) { return 0; } @@ -973,7 +964,7 @@ static int _tdb1_transaction_prepare_commit(struct tdb1_context *tdb) /* get the open lock - this prevents new users attaching to the database during the commit */ - if (tdb1_nest_lock(tdb, TDB1_OPEN_LOCK, F_WRLCK, TDB1_LOCK_WAIT) == -1) { + if (tdb1_nest_lock(tdb, TDB1_OPEN_LOCK, F_WRLCK, TDB_LOCK_WAIT) == -1) { tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR, "tdb1_transaction_prepare_commit:" " failed to get open lock"); @@ -981,7 +972,7 @@ static int _tdb1_transaction_prepare_commit(struct tdb1_context *tdb) return -1; } - if (!(tdb->flags & TDB1_NOSYNC)) { + if (!(tdb->flags & TDB_NOSYNC)) { /* write the recovery data to the end of the file */ if (transaction1_setup_recovery(tdb, &tdb->transaction->magic_offset) == -1) { tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,