summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-repo-checkout.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2015-01-06 16:00:27 -0500
committerColin Walters <walters@verbum.org>2015-01-07 11:41:46 -0500
commitf23f556f03f72b966c7a6cc8f4afa03a29d1ea5f (patch)
treeecfdf62c815c832737dd757b53dae827fbd9503d /src/libostree/ostree-repo-checkout.c
parent687a6f8314acf62b4434302a9269cd7a5d2d97a1 (diff)
downloadostree-f23f556f03f72b966c7a6cc8f4afa03a29d1ea5f.tar.gz
checkout: Add --fsync=false
Some use cases for checkouts don't need to fsync during checkout. Installer programs for example will just do a global fsync at the end. In the future, the default "ostree admin" core could also be rearchitected to only do a transaction commit right before reboot, and do the fsync then. https://bugzilla.gnome.org/show_bug.cgi?id=742482
Diffstat (limited to 'src/libostree/ostree-repo-checkout.c')
-rw-r--r--src/libostree/ostree-repo-checkout.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/libostree/ostree-repo-checkout.c b/src/libostree/ostree-repo-checkout.c
index c31bd3d0..1340484c 100644
--- a/src/libostree/ostree-repo-checkout.c
+++ b/src/libostree/ostree-repo-checkout.c
@@ -64,13 +64,16 @@ checkout_object_for_uncompressed_cache (OstreeRepo *self,
fd = g_file_descriptor_based_get_fd ((GFileDescriptorBased*)temp_out);
- do
- res = fsync (fd);
- while (G_UNLIKELY (res == -1 && errno == EINTR));
- if (G_UNLIKELY (res == -1))
+ if (!self->disable_fsync)
{
- gs_set_error_from_errno (error, errno);
- goto out;
+ do
+ res = fsync (fd);
+ while (G_UNLIKELY (res == -1 && errno == EINTR));
+ if (G_UNLIKELY (res == -1))
+ {
+ gs_set_error_from_errno (error, errno);
+ goto out;
+ }
}
if (!g_output_stream_close (temp_out, cancellable, error))
@@ -100,7 +103,8 @@ checkout_object_for_uncompressed_cache (OstreeRepo *self,
}
static gboolean
-write_regular_file_content (OstreeRepoCheckoutMode mode,
+write_regular_file_content (OstreeRepo *self,
+ OstreeRepoCheckoutMode mode,
GOutputStream *output,
GFileInfo *file_info,
GVariant *xattrs,
@@ -150,10 +154,13 @@ write_regular_file_content (OstreeRepoCheckoutMode mode,
}
}
- if (fsync (fd) == -1)
+ if (!self->disable_fsync)
{
- gs_set_error_from_errno (error, errno);
+ if (fsync (fd) == -1)
+ {
+ gs_set_error_from_errno (error, errno);
goto out;
+ }
}
if (!g_output_stream_close (output, cancellable, error))
@@ -165,7 +172,8 @@ write_regular_file_content (OstreeRepoCheckoutMode mode,
}
static gboolean
-checkout_file_from_input_at (OstreeRepoCheckoutMode mode,
+checkout_file_from_input_at (OstreeRepo *self,
+ OstreeRepoCheckoutMode mode,
GFileInfo *file_info,
GVariant *xattrs,
GInputStream *input,
@@ -231,7 +239,7 @@ checkout_file_from_input_at (OstreeRepoCheckoutMode mode,
temp_out = g_unix_output_stream_new (fd, TRUE);
fd = -1; /* Transfer ownership */
- if (!write_regular_file_content (mode, temp_out, file_info, xattrs, input,
+ if (!write_regular_file_content (self, mode, temp_out, file_info, xattrs, input,
cancellable, error))
goto out;
}
@@ -248,7 +256,8 @@ checkout_file_from_input_at (OstreeRepoCheckoutMode mode,
* it into place. This implements union-like behavior.
*/
static gboolean
-checkout_file_unioning_from_input_at (OstreeRepoCheckoutMode mode,
+checkout_file_unioning_from_input_at (OstreeRepo *repo,
+ OstreeRepoCheckoutMode mode,
GFileInfo *file_info,
GVariant *xattrs,
GInputStream *input,
@@ -291,7 +300,7 @@ checkout_file_unioning_from_input_at (OstreeRepoCheckoutMode mode,
cancellable, error))
goto out;
- if (!write_regular_file_content (mode, temp_out, file_info, xattrs, input,
+ if (!write_regular_file_content (repo, mode, temp_out, file_info, xattrs, input,
cancellable, error))
goto out;
}
@@ -498,7 +507,7 @@ checkout_one_file_at (OstreeRepo *repo,
if (overwrite_mode == OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_FILES)
{
- if (!checkout_file_unioning_from_input_at (mode, source_info, xattrs, input,
+ if (!checkout_file_unioning_from_input_at (repo, mode, source_info, xattrs, input,
destination_dfd, destination_parent,
destination_name,
cancellable, error))
@@ -509,7 +518,7 @@ checkout_one_file_at (OstreeRepo *repo,
}
else
{
- if (!checkout_file_from_input_at (mode, source_info, xattrs, input,
+ if (!checkout_file_from_input_at (repo, mode, source_info, xattrs, input,
destination_dfd, destination_parent,
destination_name,
cancellable, error))