summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2016-11-16 03:00:07 +0100
committerGuillem Jover <guillem@debian.org>2016-11-16 05:02:10 +0100
commita971ad91437af8880cad4703695dcf12ee45959b (patch)
tree884ef66a13042a0432fb1333a542efe3959447dd /lib
parent4c217aee7a610dad02d5b28a2f9bf5d934fea77c (diff)
downloaddpkg-a971ad91437af8880cad4703695dcf12ee45959b.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/dpkg/fdio.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/dpkg/fdio.c b/lib/dpkg/fdio.c
index 38781c887..b98596e2b 100644
--- a/lib/dpkg/fdio.c
+++ b/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)