sysroot: Don't individually fsync dirs in checkout, rely on syncfs
authorColin Walters <walters@verbum.org>
Wed, 13 Jan 2016 15:15:21 +0000 (10:15 -0500)
committerColin Walters <walters@verbum.org>
Wed, 13 Jan 2016 18:15:08 +0000 (13:15 -0500)
Originally, a lot of the `fsync()` calls here were added for the
wrong reason - I was chasing a bug that ended up being the extlinux
bootloader not parsing 64 bit ext4 filesystems.  But since it looked
like corruption, I tried adding a lot more `fsync()` calls.

All we should have to do is use `syncfs()`.  If that doesn't work,
it's a kernel bug.

I'm making this change because skipping the individual fsyncs can be a
major performance win - it's easier for the FS to optimize, we do more
in parallel, etc.

https://bugzilla.gnome.org/show_bug.cgi?id=757117

doc/ostree-sections.txt
src/libostree/ostree-repo.c
src/libostree/ostree-repo.h
src/libostree/ostree-sysroot-deploy.c

index d448d6debc0fc38b7e08871ac7871a45de6158d8..4b22e25b9052ba1d9ceeb6c0b5b303f197a01d1c 100644 (file)
@@ -220,6 +220,7 @@ ostree_repo_new_for_sysroot_path
 ostree_repo_new_default
 ostree_repo_open
 ostree_repo_set_disable_fsync
+ostree_repo_get_disable_fsync
 ostree_repo_is_system
 ostree_repo_is_writable
 ostree_repo_create
index 415421af1496e76a3e7889edb681d727011be177..d5b9aeaff3cf0f0971c7a712b315170f754b913d 100644 (file)
@@ -2384,6 +2384,19 @@ ostree_repo_set_disable_fsync (OstreeRepo    *self,
   self->disable_fsync = disable_fsync;
 }
 
+/**
+ * ostree_repo_get_disable_fsync:
+ * @self: An #OstreeRepo
+ *
+ * For more information see ostree_repo_set_disable_fsync().
+ *
+ * Returns: Whether or not fsync() is enabled for this repo.
+ */
+gboolean
+ostree_repo_get_disable_fsync (OstreeRepo    *self)
+{
+  return self->disable_fsync;
+}
 
 /* Replace the contents of a file, honoring the repository's fsync
  * policy.
index 5bc25204972ea87d33b4dfb5d9a987a088f4b915..fd2b7f063e44ea5a5d3323dd5abc45a35907121d 100644 (file)
@@ -56,6 +56,8 @@ gboolean      ostree_repo_open   (OstreeRepo     *self,
 void          ostree_repo_set_disable_fsync (OstreeRepo    *self,
                                              gboolean       disable_fsync);
 
+gboolean      ostree_repo_get_disable_fsync (OstreeRepo    *self);
+
 gboolean      ostree_repo_is_system (OstreeRepo   *repo);
 
 gboolean      ostree_repo_is_writable (OstreeRepo  *self,
index 041b0b25b930670d5ab2b8c4b26cccdd5f40f914..1524a866c3e963e19366f612c95ebfa873ad7118 100644 (file)
@@ -540,10 +540,20 @@ checkout_deployment_tree (OstreeSysroot     *sysroot,
   if (!glnx_shutil_rm_rf_at (osdeploy_dfd, checkout_target_name, cancellable, error))
     goto out;
 
-  if (!ostree_repo_checkout_tree_at (repo, &checkout_opts, osdeploy_dfd,
-                                     checkout_target_name, csum,
-                                     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 (!glnx_opendirat (osdeploy_dfd, checkout_target_name, TRUE, &ret_fd, error))
     goto out;