ntdb: still prepare recovery area with NTDB_NOSYNC.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 19 Jun 2012 03:09:33 +0000 (12:39 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 19 Jun 2012 03:38:06 +0000 (05:38 +0200)
NTDB_NOSYNC now just prevents the fsync/msync calls, which speeds
testing while still providing full coverage.  It also provides safety
against processes dying during transaction commit (though obviously,
not against the machine dying).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
lib/ntdb/transaction.c

index 222aa1fdbcaa83d444a77b2121f5d20ea2247b6c..b03bbbdb8a9ba69b38a00913c07746ac1be59891 100644 (file)
@@ -85,8 +85,9 @@
     intervention.
 
   - if NTDB_NOSYNC is passed to flags in ntdb_open then transactions are
-    still available, but no transaction recovery area is used and no
-    fsync/msync calls are made.
+    still available, but fsync/msync calls are made.  This means we
+    still are safe against unexpected death during transaction commit,
+    but not against machine reboots.
 */
 
 /*
@@ -977,14 +978,11 @@ static enum NTDB_ERROR _ntdb_transaction_prepare_commit(struct ntdb_context *ntd
                return ecode;
        }
 
-       /* Since we have whole db locked, we don't need the expansion lock. */
-       if (!(ntdb->flags & NTDB_NOSYNC)) {
-               /* Sets up ntdb->transaction->recovery and
-                * ntdb->transaction->magic_offset. */
-               ecode = transaction_setup_recovery(ntdb);
-               if (ecode != NTDB_SUCCESS) {
-                       return ecode;
-               }
+       /* Sets up ntdb->transaction->recovery and
+        * ntdb->transaction->magic_offset. */
+       ecode = transaction_setup_recovery(ntdb);
+       if (ecode != NTDB_SUCCESS) {
+               return ecode;
        }
 
        ntdb->transaction->prepared = true;