[ostree] Add a checkout option to skip fsync
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] Add a checkout option to skip fsync
- Date: Tue, 26 Jan 2016 20:40:06 +0000 (UTC)
commit cd0a9d3435d052f4f994673f1682e4c15b897458
Author: Colin Walters <walters verbum org>
Date: Sat Jan 23 15:07:55 2016 -0500
Add a checkout option to skip fsync
This is a better followup to dc9239dd7b09ef5e104309b4dbf0e136889da274
since I wanted to do fsync-less checkouts in rpm-ostree too, and
replicating the "turn off fsync temporarily" was in retrospect just a
hack.
We can simply add a boolean to the checkout options.
https://github.com/GNOME/ostree/pull/172
src/libostree/ostree-repo-checkout.c | 34 ++++++++++++++++++--------------
src/libostree/ostree-repo.h | 3 +-
src/libostree/ostree-sysroot-deploy.c | 23 ++++++++-------------
3 files changed, 30 insertions(+), 30 deletions(-)
---
diff --git a/src/libostree/ostree-repo-checkout.c b/src/libostree/ostree-repo-checkout.c
index ad309e7..0d0e7ef 100644
--- a/src/libostree/ostree-repo-checkout.c
+++ b/src/libostree/ostree-repo-checkout.c
@@ -103,8 +103,15 @@ checkout_object_for_uncompressed_cache (OstreeRepo *self,
}
static gboolean
+fsync_is_enabled (OstreeRepo *self,
+ OstreeRepoCheckoutOptions *options)
+{
+ return !(self->disable_fsync || options->disable_fsync);
+}
+
+static gboolean
write_regular_file_content (OstreeRepo *self,
- OstreeRepoCheckoutMode mode,
+ OstreeRepoCheckoutOptions *options,
GOutputStream *output,
GFileInfo *file_info,
GVariant *xattrs,
@@ -113,6 +120,7 @@ write_regular_file_content (OstreeRepo *self,
GError **error)
{
gboolean ret = FALSE;
+ const OstreeRepoCheckoutMode mode = options->mode;
int fd;
int res;
@@ -154,12 +162,12 @@ write_regular_file_content (OstreeRepo *self,
}
}
- if (!self->disable_fsync)
+ if (fsync_is_enabled (self, options))
{
if (fsync (fd) == -1)
{
gs_set_error_from_errno (error, errno);
- goto out;
+ goto out;
}
}
@@ -238,7 +246,7 @@ checkout_file_from_input_at (OstreeRepo *self,
temp_out = g_unix_output_stream_new (fd, TRUE);
fd = -1; /* Transfer ownership */
- if (!write_regular_file_content (self, options->mode, temp_out, file_info, xattrs, input,
+ if (!write_regular_file_content (self, options, temp_out, file_info, xattrs, input,
cancellable, error))
goto out;
}
@@ -298,7 +306,7 @@ checkout_file_unioning_from_input_at (OstreeRepo *repo,
cancellable, error))
goto out;
- if (!write_regular_file_content (repo, options->mode, temp_out, file_info, xattrs, input,
+ if (!write_regular_file_content (repo, options, temp_out, file_info, xattrs, input,
cancellable, error))
goto out;
}
@@ -726,17 +734,13 @@ checkout_tree_at (OstreeRepo *self,
}
}
- /* Finally, fsync to ensure all entries are on disk. Ultimately
- * this should be configurable for the case where we're constructing
- * buildroots.
- */
- if (!self->disable_fsync)
+ if (fsync_is_enabled (self, options))
{
- if (fsync (destination_dfd) == -1)
- {
- gs_set_error_from_errno (error, errno);
- goto out;
- }
+ if (fsync (destination_dfd) == -1)
+ {
+ gs_set_error_from_errno (error, errno);
+ goto out;
+ }
}
ret = TRUE;
diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h
index fd2b7f0..d4d0f41 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -532,7 +532,8 @@ typedef struct {
OstreeRepoCheckoutOverwriteMode overwrite_mode;
guint enable_uncompressed_cache : 1;
- guint unused : 31;
+ guint disable_fsync : 1;
+ guint reserved : 30;
const char *subpath;
diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c
index 1524a86..3dcf39f 100644
--- a/src/libostree/ostree-sysroot-deploy.c
+++ b/src/libostree/ostree-sysroot-deploy.c
@@ -528,6 +528,11 @@ checkout_deployment_tree (OstreeSysroot *sysroot,
glnx_fd_close int osdeploy_dfd = -1;
int ret_fd;
+ /* We end up using syncfs for the entire filesystem, so turn off
+ * OstreeRepo level fsync.
+ */
+ checkout_opts.disable_fsync = TRUE;
+
osdeploy_path = g_strconcat ("ostree/deploy/", ostree_deployment_get_osname (deployment), "/deploy", NULL);
checkout_target_name = g_strdup_printf ("%s.%d", csum, ostree_deployment_get_deployserial (deployment));
@@ -540,20 +545,10 @@ checkout_deployment_tree (OstreeSysroot *sysroot,
if (!glnx_shutil_rm_rf_at (osdeploy_dfd, checkout_target_name, cancellable, error))
goto out;
- /* We end up using syncfs for the entire filesystem, so turn off
- * OstreeRepo level fsync.
- */
- { gboolean fsync_was_disabled = ostree_repo_get_disable_fsync (repo);
- gboolean checkout_success;
-
- ostree_repo_set_disable_fsync (repo, TRUE);
- checkout_success = ostree_repo_checkout_tree_at (repo, &checkout_opts, osdeploy_dfd,
- checkout_target_name, csum,
- cancellable, error);
- ostree_repo_set_disable_fsync (repo, fsync_was_disabled);
- if (!checkout_success)
- goto out;
- }
+ if (!ostree_repo_checkout_tree_at (repo, &checkout_opts, osdeploy_dfd,
+ checkout_target_name, csum,
+ cancellable, error))
+ goto out;
if (!glnx_opendirat (osdeploy_dfd, checkout_target_name, TRUE, &ret_fd, error))
goto out;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]