summaryrefslogtreecommitdiff
path: root/lib/tdb/common
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-05-28 16:08:28 +1000
committerAndrew Tridgell <tridge@samba.org>2009-05-28 16:08:28 +1000
commit4b4fec65db4e202afa13b2d15867f4d8a54d154e (patch)
tree170670eff8995c25fdfcb77c4fb987951d18c2e4 /lib/tdb/common
parenta9542ba21b4d4ef088ac2cf31f9f4074dc211aa8 (diff)
downloadsamba-4b4fec65db4e202afa13b2d15867f4d8a54d154e.tar.gz
samba-4b4fec65db4e202afa13b2d15867f4d8a54d154e.tar.bz2
samba-4b4fec65db4e202afa13b2d15867f4d8a54d154e.zip
make TDB_NOSYNC affect all the fsync/msync calls in transactions
During a transaction commit tdb normally uses fsync/msync calls to make it crash safe. This can be disabled using the TDB_NOSYNC flag, but it wasn't disabling all the code paths that caused a fsync/msync.
Diffstat (limited to 'lib/tdb/common')
-rw-r--r--lib/tdb/common/transaction.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/tdb/common/transaction.c b/lib/tdb/common/transaction.c
index cb723ed134..f5c04a69cc 100644
--- a/lib/tdb/common/transaction.c
+++ b/lib/tdb/common/transaction.c
@@ -522,6 +522,10 @@ fail:
*/
static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t length)
{
+ if (tdb->flags & TDB_NOSYNC) {
+ return 0;
+ }
+
if (fsync(tdb->fd) != 0) {
tdb->ecode = TDB_ERR_IO;
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: fsync failed\n"));
@@ -1030,11 +1034,9 @@ int tdb_transaction_commit(struct tdb_context *tdb)
SAFE_FREE(tdb->transaction->blocks);
tdb->transaction->num_blocks = 0;
- if (!(tdb->flags & TDB_NOSYNC)) {
- /* ensure the new data is on disk */
- if (transaction_sync(tdb, 0, tdb->map_size) == -1) {
- return -1;
- }
+ /* ensure the new data is on disk */
+ if (transaction_sync(tdb, 0, tdb->map_size) == -1) {
+ return -1;
}
tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1);