On Tue, 11 May 2010, Raphael Hertzog wrote:
> I also attach the relevant patch (you can apply it on the master branch,
> or even on the sid version if you prefer). Be sure to run autoreconf -f -i
> after having applied the patch.

This time the patch is here. It's also here:
http://git.hadrons.org/?p=debian/dpkg.git;a=commitdiff;h=b405384cfeff583197198213f0e86f7accccf4ce

Cheers,
-- 
Raphaƫl Hertzog

Like what I do? Sponsor me: http://ouaza.com/wp/2010/01/05/5-years-of-freexian/
My Debian goals: http://ouaza.com/wp/2010/01/09/debian-related-goals-for-2010/
commit b405384cfeff583197198213f0e86f7accccf4ce
Author: Guillem Jover <guil...@debian.org>
Date:   Tue May 11 09:38:04 2010 +0200

    dpkg: On Linux use sync() instead of an fsync() per file
    
    Due to the performance degradation on ext4 file systems, as a
    workaround, on Linux we use sync() which is synchronous, before
    rename() to make sure the data is on disk.

diff --git a/configure.ac b/configure.ac
index 8b7e213..1a7ddd6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -118,6 +118,7 @@ DPKG_DECL_SYS_SIGLIST
 # Checks for library functions.
 DPKG_FUNC_VA_COPY
 DPKG_FUNC_C99_SNPRINTF
+DPKG_FUNC_ASYNC_SYNC
 DPKG_CHECK_DECL([offsetof], [stddef.h])
 DPKG_CHECK_DECL([WCOREDUMP], [sys/wait.h])
 DPKG_CHECK_COMPAT_FUNCS([getopt getopt_long obstack_free \
diff --git a/m4/dpkg-funcs.m4 b/m4/dpkg-funcs.m4
index 39b026c..188fa6b 100644
--- a/m4/dpkg-funcs.m4
+++ b/m4/dpkg-funcs.m4
@@ -68,6 +68,22 @@ AS_IF([test "x$dpkg_cv_c99_snprintf" = "xyes"],
 AM_CONDITIONAL(HAVE_C99_SNPRINTF, [test "x$dpkg_cv_c99_snprintf" = "xyes"])
 ])# DPKG_FUNC_C99_SNPRINTF
 
+# DPKG_FUNC_ASYNC_SYNC
+# --------------------
+# Define HAVE_ASYNC_SYNC if sync() is asynchronous
+AC_DEFUN([DPKG_FUNC_ASYNC_SYNC],
+[
+  AC_CANONICAL_HOST
+  AC_MSG_CHECKING([whether sync is asynchronous])
+  AS_CASE([$host_os],
+          [linux-*], [dpkg_cv_async_sync=no],
+          [dpkg_cv_async_sync=yes])
+  AS_IF([test "x$dpkg_cv_async_sync" = "xyes"],
+        [AC_DEFINE([HAVE_ASYNC_SYNC], 1,
+                   [Define to 1 if the 'sync' function is asynchronous])])
+  AC_MSG_RESULT([$dpkg_cv_async_sync])
+])# DPKG_FUNC_ASYNC_SYNC
+
 # DPKG_CHECK_COMPAT_FUNCS(LIST)
 # -----------------------
 # Check each function and define an automake conditional
diff --git a/src/archives.c b/src/archives.c
index 17fdf12..4577571 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -816,6 +816,11 @@ tar_deferred_extract(struct fileinlist *files, struct 
pkginfo *pkg)
   struct filenamenode *usenode;
   const char *usename;
 
+#if !defined(HAVE_ASYNC_SYNC)
+  debug(dbg_general, "deferred extract mass sync");
+  sync();
+#endif
+
   for (cfile = files; cfile; cfile = cfile->next) {
     debug(dbg_eachfile, "deferred extract of '%.255s'", cfile->namenode->name);
 
@@ -829,6 +834,7 @@ tar_deferred_extract(struct fileinlist *files, struct 
pkginfo *pkg)
 
     setupfnamevbs(usename);
 
+#if defined(HAVE_ASYNC_SYNC)
     if (cfile->namenode->flags & fnnf_deferred_fsync) {
       int fd;
 
@@ -844,6 +850,7 @@ tar_deferred_extract(struct fileinlist *files, struct 
pkginfo *pkg)
 
       cfile->namenode->flags &= ~fnnf_deferred_fsync;
     }
+#endif
 
     if (rename(fnamenewvb.buf, fnamevb.buf))
       ohshite(_("unable to install new version of `%.255s'"),

Reply via email to