summaryrefslogtreecommitdiff
path: root/lib/tdb/common/transaction.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tdb/common/transaction.c')
-rw-r--r--lib/tdb/common/transaction.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/lib/tdb/common/transaction.c b/lib/tdb/common/transaction.c
index 5cd79501ae..ee9beeb3d3 100644
--- a/lib/tdb/common/transaction.c
+++ b/lib/tdb/common/transaction.c
@@ -1,4 +1,4 @@
- /*
+ /*
Unix SMB/CIFS implementation.
trivial database library
@@ -148,7 +148,7 @@ struct tdb_transaction {
read while in a transaction. We need to check first if the data is in our list
of transaction elements, then if not do a real read
*/
-static int transaction_read(struct tdb_context *tdb, tdb_off_t off, void *buf,
+static int transaction_read(struct tdb_context *tdb, tdb_off_t off, void *buf,
tdb_len_t len, int cv)
{
uint32_t blk;
@@ -205,7 +205,7 @@ fail:
/*
write while in a transaction
*/
-static int transaction_write(struct tdb_context *tdb, tdb_off_t off,
+static int transaction_write(struct tdb_context *tdb, tdb_off_t off,
const void *buf, tdb_len_t len)
{
uint32_t blk;
@@ -261,7 +261,7 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off,
tdb->ecode = TDB_ERR_OOM;
goto fail;
}
- memset(&new_blocks[tdb->transaction->num_blocks], 0,
+ memset(&new_blocks[tdb->transaction->num_blocks], 0,
(1+(blk - tdb->transaction->num_blocks))*sizeof(uint8_t *));
tdb->transaction->blocks = new_blocks;
tdb->transaction->num_blocks = blk+1;
@@ -274,23 +274,23 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off,
if (tdb->transaction->blocks[blk] == NULL) {
tdb->ecode = TDB_ERR_OOM;
tdb->transaction->transaction_error = 1;
- return -1;
+ return -1;
}
if (tdb->transaction->old_map_size > blk * tdb->transaction->block_size) {
tdb_len_t len2 = tdb->transaction->block_size;
if (len2 + (blk * tdb->transaction->block_size) > tdb->transaction->old_map_size) {
len2 = tdb->transaction->old_map_size - (blk * tdb->transaction->block_size);
}
- if (tdb->transaction->io_methods->tdb_read(tdb, blk * tdb->transaction->block_size,
- tdb->transaction->blocks[blk],
+ if (tdb->transaction->io_methods->tdb_read(tdb, blk * tdb->transaction->block_size,
+ tdb->transaction->blocks[blk],
len2, 0) != 0) {
- SAFE_FREE(tdb->transaction->blocks[blk]);
+ SAFE_FREE(tdb->transaction->blocks[blk]);
tdb->ecode = TDB_ERR_IO;
goto fail;
}
if (blk == tdb->transaction->num_blocks-1) {
tdb->transaction->last_block_size = len2;
- }
+ }
}
}
@@ -309,7 +309,7 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off,
return 0;
fail:
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "transaction_write: failed at off=%d len=%d\n",
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "transaction_write: failed at off=%d len=%d\n",
(blk*tdb->transaction->block_size) + off, len));
tdb->transaction->transaction_error = 1;
return -1;
@@ -320,7 +320,7 @@ fail:
write while in a transaction - this variant never expands the transaction blocks, it only
updates existing blocks. This means it cannot change the recovery size
*/
-static int transaction_write_existing(struct tdb_context *tdb, tdb_off_t off,
+static int transaction_write_existing(struct tdb_context *tdb, tdb_off_t off,
const void *buf, tdb_len_t len)
{
uint32_t blk;
@@ -396,7 +396,7 @@ static int transaction_oob(struct tdb_context *tdb, tdb_off_t off,
/*
transaction version of tdb_expand().
*/
-static int transaction_expand_file(struct tdb_context *tdb, tdb_off_t size,
+static int transaction_expand_file(struct tdb_context *tdb, tdb_off_t size,
tdb_off_t addition)
{
/* add a write to the transaction elements, so subsequent
@@ -440,7 +440,7 @@ static int _tdb_transaction_start(struct tdb_context *tdb,
return -1;
}
tdb->transaction->nesting++;
- TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n",
+ TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n",
tdb->transaction->nesting));
return 0;
}
@@ -545,7 +545,7 @@ _PUBLIC_ int tdb_transaction_start_nonblock(struct tdb_context *tdb)
sync to disk
*/
static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t length)
-{
+{
if (tdb->flags & TDB_NOSYNC) {
return 0;
}
@@ -562,7 +562,7 @@ static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t
#ifdef HAVE_MMAP
if (tdb->map_ptr) {
tdb_off_t moffset = offset & ~(tdb->page_size-1);
- if (msync(moffset + (char *)tdb->map_ptr,
+ if (msync(moffset + (char *)tdb->map_ptr,
length + (offset - moffset), MS_SYNC) != 0) {
tdb->ecode = TDB_ERR_IO;
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: msync failed - %s\n",
@@ -576,7 +576,7 @@ static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t
static int _tdb_transaction_cancel(struct tdb_context *tdb)
-{
+{
int i, ret = 0;
if (tdb->transaction == NULL) {
@@ -588,7 +588,7 @@ static int _tdb_transaction_cancel(struct tdb_context *tdb)
tdb->transaction->transaction_error = 1;
tdb->transaction->nesting--;
return 0;
- }
+ }
tdb->map_size = tdb->transaction->old_map_size;
@@ -655,7 +655,7 @@ static tdb_len_t tdb_recovery_size(struct tdb_context *tdb)
} else {
recovery_size += tdb->transaction->block_size;
}
- }
+ }
return recovery_size;
}
@@ -692,7 +692,7 @@ int tdb_recovery_area(struct tdb_context *tdb,
allocate the recovery area, or use an existing recovery area if it is
large enough
*/
-static int tdb_recovery_allocate(struct tdb_context *tdb,
+static int tdb_recovery_allocate(struct tdb_context *tdb,
tdb_len_t *recovery_size,
tdb_off_t *recovery_offset,
tdb_len_t *recovery_max_size)
@@ -752,7 +752,7 @@ static int tdb_recovery_allocate(struct tdb_context *tdb,
new_end = recovery_head + sizeof(rec) + *recovery_max_size;
- if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size,
+ if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size,
new_end - tdb->transaction->old_map_size)
== -1) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to create recovery area\n"));
@@ -769,7 +769,7 @@ static int tdb_recovery_allocate(struct tdb_context *tdb,
/* write the recovery header offset and sync - we can sync without a race here
as the magic ptr in the recovery record has not been set */
CONVERT(recovery_head);
- if (methods->tdb_write(tdb, TDB_RECOVERY_HEAD,
+ if (methods->tdb_write(tdb, TDB_RECOVERY_HEAD,
&recovery_head, sizeof(tdb_off_t)) == -1) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to write recovery head\n"));
return -1;
@@ -786,7 +786,7 @@ static int tdb_recovery_allocate(struct tdb_context *tdb,
/*
setup the recovery data that will be used on a crash during commit
*/
-static int transaction_setup_recovery(struct tdb_context *tdb,
+static int transaction_setup_recovery(struct tdb_context *tdb,
tdb_off_t *magic_offset)
{
tdb_len_t recovery_size;
@@ -801,7 +801,7 @@ static int transaction_setup_recovery(struct tdb_context *tdb,
/*
check that the recovery area has enough space
*/
- if (tdb_recovery_allocate(tdb, &recovery_size,
+ if (tdb_recovery_allocate(tdb, &recovery_size,
&recovery_offset, &recovery_max_size) == -1) {
return -1;
}
@@ -919,7 +919,7 @@ static int transaction_setup_recovery(struct tdb_context *tdb,
}
static int _tdb_transaction_prepare_commit(struct tdb_context *tdb)
-{
+{
const struct tdb_methods *methods;
if (tdb->transaction == NULL) {
@@ -944,7 +944,7 @@ static int _tdb_transaction_prepare_commit(struct tdb_context *tdb)
if (tdb->transaction->nesting != 0) {
return 0;
- }
+ }
/* check for a null transaction */
if (tdb->transaction->blocks == NULL) {
@@ -988,8 +988,8 @@ static int _tdb_transaction_prepare_commit(struct tdb_context *tdb)
/* expand the file to the new size if needed */
if (tdb->map_size != tdb->transaction->old_map_size) {
- if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size,
- tdb->map_size -
+ if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size,
+ tdb->map_size -
tdb->transaction->old_map_size) == -1) {
tdb->ecode = TDB_ERR_IO;
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_prepare_commit: expansion failed\n"));
@@ -1101,7 +1101,7 @@ _PUBLIC_ int tdb_transaction_commit(struct tdb_context *tdb)
possibly expanded the file, so we need to
run the crash recovery code */
tdb->methods = methods;
- tdb_transaction_recover(tdb);
+ tdb_transaction_recover(tdb);
_tdb_transaction_cancel(tdb);
@@ -1109,7 +1109,7 @@ _PUBLIC_ int tdb_transaction_commit(struct tdb_context *tdb)
return -1;
}
SAFE_FREE(tdb->transaction->blocks[i]);
- }
+ }
/* Do this before we drop lock or blocks. */
if (tdb->transaction->expanded) {
@@ -1176,9 +1176,9 @@ int tdb_transaction_recover(struct tdb_context *tdb)
}
/* read the recovery record */
- if (tdb->methods->tdb_read(tdb, recovery_head, &rec,
+ if (tdb->methods->tdb_read(tdb, recovery_head, &rec,
sizeof(rec), DOCONV()) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery record\n"));
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery record\n"));
tdb->ecode = TDB_ERR_IO;
return -1;
}
@@ -1198,7 +1198,7 @@ int tdb_transaction_recover(struct tdb_context *tdb)
data = (unsigned char *)malloc(rec.data_len);
if (data == NULL) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to allocate recovery data\n"));
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to allocate recovery data\n"));
tdb->ecode = TDB_ERR_OOM;
return -1;
}
@@ -1206,7 +1206,7 @@ int tdb_transaction_recover(struct tdb_context *tdb)
/* read the full recovery data */
if (tdb->methods->tdb_read(tdb, recovery_head + sizeof(rec), data,
rec.data_len, 0) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery data\n"));
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery data\n"));
tdb->ecode = TDB_ERR_IO;
return -1;
}
@@ -1243,7 +1243,7 @@ int tdb_transaction_recover(struct tdb_context *tdb)
if (tdb_ofs_write(tdb, TDB_RECOVERY_HEAD, &zero) == -1) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to remove recovery head\n"));
tdb->ecode = TDB_ERR_IO;
- return -1;
+ return -1;
}
}
@@ -1252,7 +1252,7 @@ int tdb_transaction_recover(struct tdb_context *tdb)
&zero) == -1) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to remove recovery magic\n"));
tdb->ecode = TDB_ERR_IO;
- return -1;
+ return -1;
}
if (transaction_sync(tdb, 0, recovery_eof) == -1) {
@@ -1261,7 +1261,7 @@ int tdb_transaction_recover(struct tdb_context *tdb)
return -1;
}
- TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_recover: recovered %d byte database\n",
+ TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_recover: recovered %d byte database\n",
recovery_eof));
/* all done */