lib/commit: Use direct repo writes if fsync is disabled
authorColin Walters <walters@verbum.org>
Tue, 28 Nov 2017 20:17:10 +0000 (15:17 -0500)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 29 Nov 2017 11:22:14 +0000 (11:22 +0000)
For situations where fsync is disabled, there's basically
no reason to do the whole "staging directory" dance.  Just
write directly into the repo.

Today I use `fsync=false` for my build/cache repos.

I briefly considered not allocating a tmpdir at all
in this case, but we actually do want the txn tmpdir
for the non-`O_TMPFILE` case.

Part of https://github.com/ostreedev/ostree/issues/1184

Closes: #1354
Approved by: giuseppe

src/libostree/ostree-repo-commit.c

index cf1a513f037c7534c9132d6aa951f8f1ab8d7b1d..e43a0fa7939d6f8663f4f97f76f3d281a7688124 100644 (file)
 #include "ostree-checksum-input-stream.h"
 #include "ostree-varint.h"
 
-/* In most cases, we write into a staging dir for commit, but we also allow
- * direct writes into objects/ for e.g. hardlink imports.
+/* If fsync is enabled and we're in a txn, we write into a staging dir for
+ * commit, but we also allow direct writes into objects/ for e.g. hardlink
+ * imports.
  */
 static int
 commit_dest_dfd (OstreeRepo *self)
 {
-  if (self->in_transaction)
+  if (self->in_transaction && !self->disable_fsync)
     return self->commit_stagedir.fd;
   else
     return self->objects_dir_fd;