diff options
author | Colin Walters <walters@verbum.org> | 2017-09-18 14:29:16 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-09-21 13:21:59 +0000 |
commit | 75150fe04a5dd830de87abfde99ce66ab9feb5a7 (patch) | |
tree | 58f49b016ad179330409b4fdd16b1e11864a375d /src/libostree/ostree-repo-commit.c | |
parent | 7a8511e0ca9c4e2441077ad0f2872c35a199eebe (diff) | |
download | ostree-75150fe04a5dd830de87abfde99ce66ab9feb5a7.tar.gz |
lib/repo: Don't syncfs or fsync() dirs if fsync opt is disabled
There are use cases for not syncing at all; think build cache repos, etc. Let's
be consistent here and make sure if fsync is disabled we do no sync at all.
I chose this opportunity to add tests using the shiny new strace fault
injection. I can forsee using this for a lot more things, so I made
the support for detecting things generic.
Related: https://github.com/ostreedev/ostree/issues/1184
Closes: #1186
Approved by: jlebon
Diffstat (limited to 'src/libostree/ostree-repo-commit.c')
-rw-r--r-- | src/libostree/ostree-repo-commit.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c index e226d500..04349ed0 100644 --- a/src/libostree/ostree-repo-commit.c +++ b/src/libostree/ostree-repo-commit.c @@ -1187,7 +1187,7 @@ rename_pending_loose_objects (OstreeRepo *self, renamed_some_object = TRUE; } - if (renamed_some_object) + if (renamed_some_object && !self->disable_fsync) { /* Ensure that in the case of a power cut all the directory metadata that we want has reached the disk. In particular, we want this before we @@ -1208,8 +1208,11 @@ rename_pending_loose_objects (OstreeRepo *self, } /* In case we created any loose object subdirs, make sure they are on disk */ - if (fsync (self->objects_dir_fd) == -1) - return glnx_throw_errno_prefix (error, "fsync"); + if (!self->disable_fsync) + { + if (fsync (self->objects_dir_fd) == -1) + return glnx_throw_errno_prefix (error, "fsync"); + } if (!glnx_tmpdir_delete (&self->commit_stagedir, cancellable, error)) return FALSE; @@ -1517,10 +1520,11 @@ ostree_repo_commit_transaction (OstreeRepo *self, if ((self->test_error_flags & OSTREE_REPO_TEST_ERROR_PRE_COMMIT) > 0) return glnx_throw (error, "OSTREE_REPO_TEST_ERROR_PRE_COMMIT specified"); - /* FIXME: Added since valgrind in el7 doesn't know about - * `syncfs`...we should delete this later. + /* FIXME: Added OSTREE_SUPPRESS_SYNCFS since valgrind in el7 doesn't know + * about `syncfs`...we should delete this later. */ - if (g_getenv ("OSTREE_SUPPRESS_SYNCFS") == NULL) + if (!self->disable_fsync && + g_getenv ("OSTREE_SUPPRESS_SYNCFS") == NULL) { if (syncfs (self->tmp_dir_fd) < 0) return glnx_throw_errno_prefix (error, "syncfs"); |