From bd6a15e7a32b1879c301ac1a77bbe4de1cee523d Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 28 Nov 2017 15:17:10 -0500 Subject: [PATCH] lib/commit: Use direct repo writes if fsync is disabled 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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c index cf1a513f03..e43a0fa793 100644 --- a/src/libostree/ostree-repo-commit.c +++ b/src/libostree/ostree-repo-commit.c @@ -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;