diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2009-07-29 14:50:39 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-08-04 16:43:17 +0930 |
commit | d66a7c40da1812767c6cc321512ec0c0357e95ab (patch) | |
tree | 283b512b6e1f9591921233c5b37255169181f8e5 /ctdb | |
parent | f10db37b82859750ae8fbf7b8ce2f0bab3b13669 (diff) | |
download | samba-d66a7c40da1812767c6cc321512ec0c0357e95ab.tar.gz samba-d66a7c40da1812767c6cc321512ec0c0357e95ab.tar.xz samba-d66a7c40da1812767c6cc321512ec0c0357e95ab.zip |
Port from SAMBA tdb: commit 4b4fec65db4e202afa13b2d15867f4d8a54d154e Author: Andrew Tridgell <tridge@samba.org> Date: Thu May 28 16:08:28 2009 +1000
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.
(This used to be ctdb commit e03980add02a28609a7a0a0c87ebc85419b98144)
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/lib/tdb/common/transaction.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ctdb/lib/tdb/common/transaction.c b/ctdb/lib/tdb/common/transaction.c index 6abe5ac3707..673b91ee5a7 100644 --- a/ctdb/lib/tdb/common/transaction.c +++ b/ctdb/lib/tdb/common/transaction.c @@ -533,6 +533,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")); @@ -1041,11 +1045,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); |