Browse Source

build: Disable disk pre-allocation by default

Contrary to what one would expect, this seems to be causing major issues
in several "modern" filesystems, as it collides with the heuristics and
optimizations that these try to perform.

Disable this by default, but let the builder enable it again in case
this is not a problem on certain systems.
Guillem Jover 7 years ago
parent
commit
9d5e55d449
4 changed files with 30 additions and 0 deletions
  1. 2 0
      configure.ac
  2. 4 0
      debian/changelog
  3. 9 0
      lib/dpkg/fdio.c
  4. 15 0
      m4/dpkg-funcs.m4

+ 2 - 0
configure.ac

@@ -178,6 +178,7 @@ AS_IF([test "x$build_dselect" = "xyes"], [
 ])
 
 DPKG_USE_MMAP
+DPKG_USE_DISK_PREALLOCATE
 
 # Checks for the build machinery.
 AC_DEFINE([LIBDPKG_VOLATILE_API], [1], [Acknowledge the volatility of the API.])
@@ -228,6 +229,7 @@ Configuration:
     code coverage . . . . . . . . : $enable_coverage
     build shared libraries  . . . : $enable_shared
     mmap loaders  . . . . . . . . : $enable_mmap
+    disk pre-allocation . . . . . : $enable_disk_preallocate
     default dpkg-deb compressor . : $with_dpkg_deb_compressor
 
   Paths:

+ 4 - 0
debian/changelog

@@ -33,6 +33,10 @@ dpkg (1.18.19) UNRELEASED; urgency=medium
     - Move control member file references from dpkg(1) to deb(5).
     - Fix typos in docs and code comments.
     - Document Auto-Built-Package field in deb-control(5).
+  * Build system:
+    - Disable disk pre-allocation by default, but let the builder re-enable
+      it via a new configure option. This has been causing major performance
+      issues on "modern" filesystems.
   * Packaging:
     - Add debsig-verify to dpkg Suggests. The code optionally supports this
       specific signed .deb verification program.

+ 9 - 0
lib/dpkg/fdio.c

@@ -77,6 +77,7 @@ fd_write(int fd, const void *buf, size_t len)
 	return total;
 }
 
+#ifdef USE_DISK_PREALLOCATE
 #ifdef HAVE_F_PREALLOCATE
 static void
 fd_preallocate_setup(fstore_t *fs, int flags, off_t offset, off_t len)
@@ -152,3 +153,11 @@ fd_allocate_size(int fd, off_t offset, off_t len)
 
 	return rc;
 }
+#else
+int
+fd_allocate_size(int fd, off_t offset, off_t len)
+{
+	errno = ENOSYS;
+	return -1;
+}
+#endif

+ 15 - 0
m4/dpkg-funcs.m4

@@ -106,6 +106,21 @@ AC_DEFUN([DPKG_USE_MMAP], [
   ])
 ])
 
+# DPKG_USE_DISK_PREALLOCATE
+# -------------------------
+# Define USE_DISK_PREALLOCATE if disk size pre-allocation is available
+# and it was requested.
+AC_DEFUN([DPKG_USE_DISK_PREALLOCATE], [
+  AC_ARG_ENABLE([disk-preallocate],
+    [AS_HELP_STRING([--enable-disk-preallocate],
+      [enable usage of disk size pre-allocation])],
+    [], [enable_disk_preallocate=no])
+
+  AS_IF([test "x$enable_disk_preallocate" = "xyes"], [
+    AC_DEFINE([USE_DISK_PREALLOCATE], [1], [Use disk size pre-allocation])
+  ])
+])
+
 # DPKG_CHECK_PROGNAME
 # -------------------
 # Check for system implementations of program name tracking.