Kaynağa Gözat

libdpkg: Only preallocate disk size for files bigger than 16 KiB

Preallocating for very small fails causes some filesystems to degrade
performance. Do so only for "big enough" files.

Closes: #824636
Guillem Jover 9 yıl önce
ebeveyn
işleme
a971ad9143
2 değiştirilmiş dosya ile 5 ekleme ve 1 silme
  1. 2 0
      debian/changelog
  2. 3 1
      lib/dpkg/fdio.c

+ 2 - 0
debian/changelog

@@ -15,6 +15,8 @@ dpkg (1.18.15) UNRELEASED; urgency=medium
     execution when we cannot infer the number of online processors on
     unsupported or exotic systems. This should be a safer mode of operation.
     Proposed by Simon McVittie <smcv@debian.org>.
+  * Only preallocate disk size in dpkg for unpacked files bigger than 16 KiB.
+    Closes: #824636
   * Perl modules:
     - Validate architecture arguments in Dpkg::Deps deps_parse().
       Prompted by Johannes Schauer <josch@debian.org>.

+ 3 - 1
lib/dpkg/fdio.c

@@ -102,7 +102,9 @@ fd_allocate_size(int fd, off_t offset, off_t len)
 {
 	int rc;
 
-	if (len == 0)
+	/* Do not preallocate on very small files as that degrades performance
+	 * on some filesystems. */
+	if (len < (4 * 4096) - 1)
 		return 0;
 
 #if defined(HAVE_F_PREALLOCATE)