Skip to content

Commit

Permalink
lib/commit: Use direct repo writes if fsync is disabled
Browse files Browse the repository at this point in the history
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 ostreedev#1184

Closes: ostreedev#1354
Approved by: giuseppe
  • Loading branch information
cgwalters authored and rh-atomic-bot committed Nov 29, 2017
1 parent a1745e1 commit bd6a15e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/libostree/ostree-repo-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@
#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;
Expand Down

0 comments on commit bd6a15e

Please sign in to comment.