Просмотр исходного кода

build: Disable usage of synchronous sync(2) by default

It causes undesired I/O on unrelated file systems. It also makes the
code behave differently on Linux systems.

Allow the possibility to enable it again for the benefit of downstreams,
which might want to use it regardless of its problems. Although this
code path will most probably be removed in the near future.

Closes: #588339, #595927, #600075
Guillem Jover лет назад: 16
Родитель
Сommit
5ee4e4e045
4 измененных файлов с 30 добавлено и 14 удалено
  1. 1 1
      configure.ac
  2. 4 0
      debian/changelog
  3. 23 11
      m4/dpkg-funcs.m4
  4. 2 2
      src/archives.c

+ 1 - 1
configure.ac

@@ -129,7 +129,7 @@ DPKG_DECL_SYS_SIGLIST
 # Checks for library functions.
 DPKG_FUNC_VA_COPY
 DPKG_FUNC_C99_SNPRINTF
-DPKG_FUNC_ASYNC_SYNC
+DPKG_FUNC_SYNC_SYNC
 DPKG_CHECK_DECL([offsetof], [stddef.h])
 DPKG_CHECK_DECL([WCOREDUMP], [sys/wait.h])
 DPKG_CHECK_DECL([TIOCNOTTY], [sys/ioctl.h])

+ 4 - 0
debian/changelog

@@ -11,6 +11,10 @@ dpkg (1.15.8.6) UNRELEASED; urgency=low
     correct series file if the source package provides vendor specific patch
     sets.
 
+  [ Guillem Jover ]
+  * Disable by default usage of synchronous sync(2), as it causes undesired
+    I/O on unrelated file systems. Closes: #588339, #595927, #600075
+
   [ Updated man page translations ]
   * French (Christian Perrier). Including a typo fix
     and a typographical change reported by Vincent Danjean

+ 23 - 11
m4/dpkg-funcs.m4

@@ -84,21 +84,33 @@ AC_DEFUN([DPKG_MMAP],
   )
 ])
 
-# DPKG_FUNC_ASYNC_SYNC
+# DPKG_FUNC_SYNC_SYNC
 # --------------------
-# Define HAVE_ASYNC_SYNC if sync() is asynchronous
-AC_DEFUN([DPKG_FUNC_ASYNC_SYNC],
+# Define USE_SYNC_SYNC if sync() is synchronous and it has been enabled
+# on configure
+AC_DEFUN([DPKG_FUNC_SYNC_SYNC],
 [
   AC_CANONICAL_HOST
-  AC_MSG_CHECKING([whether sync is asynchronous])
+
+  AC_MSG_CHECKING([whether sync is synchronous])
   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
+          [linux-*], [dpkg_cv_sync_sync=yes],
+          [dpkg_cv_sync_sync=no])
+  AC_MSG_RESULT([$dpkg_cv_sync_sync])
+
+  AC_ARG_ENABLE([sync-sync],
+    AS_HELP_STRING([--enable-sync-sync],
+                   [enable usage of synchronous sync(2) if available]),
+    [],
+    [enable_sync_sync=no])
+  AC_MSG_CHECKING([whether to use synchronous sync])
+  AS_IF([test "x$dpkg_cv_sync_sync" = "xyes" &&
+         test "x$enable_sync_sync" = "xyes"],
+        [AC_DEFINE([USE_SYNC_SYNC], 1,
+                   [Define to 1 if sync(2) is synchronous])],
+        [enable_sync_sync=no])
+  AC_MSG_RESULT([$enable_sync_sync])
+])# DPKG_FUNC_SYNC_SYNC
 
 # DPKG_CHECK_COMPAT_FUNCS(LIST)
 # -----------------------

+ 2 - 2
src/archives.c

@@ -855,7 +855,7 @@ tar_deferred_extract(struct fileinlist *files, struct pkginfo *pkg)
   struct filenamenode *usenode;
   const char *usename;
 
-#if !defined(HAVE_ASYNC_SYNC)
+#if defined(USE_SYNC_SYNC)
   debug(dbg_general, "deferred extract mass sync");
   sync();
 #endif
@@ -871,7 +871,7 @@ tar_deferred_extract(struct fileinlist *files, struct pkginfo *pkg)
 
     setupfnamevbs(usename);
 
-#if defined(HAVE_ASYNC_SYNC)
+#if !defined(USE_SYNC_SYNC)
     if (cfile->namenode->flags & fnnf_deferred_fsync) {
       int fd;