[PATCH 4/4] Use VFIL_fallocate for the shmlog file

Martin Blix Grydeland martin at varnish-software.com
Mon Oct 6 17:53:15 CEST 2014


---
 bin/varnishd/mgt/mgt_shmem.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c
index dc1fa5c..5db385a 100644
--- a/bin/varnishd/mgt/mgt_shmem.c
+++ b/bin/varnishd/mgt/mgt_shmem.c
@@ -47,6 +47,7 @@
 #include "flopen.h"
 #include "vapi/vsm_int.h"
 #include "vmb.h"
+#include "vfil.h"
 
 #ifndef MAP_HASSEMAPHORE
 #define MAP_HASSEMAPHORE 0 /* XXX Linux */
@@ -173,6 +174,11 @@ vsm_zerofile(const char *fn, ssize_t size)
 		u += i;
 	}
 	AZ(ftruncate(fd, (off_t)size));
+	if (VFIL_fallocate(fd, (off_t)size)) {
+		fprintf(stderr, "Could not preallocate %s: %s\n",
+		    fn, strerror(errno));
+		return (-1);
+	}
 	return (fd);
 }
 
-- 
2.1.1




More information about the varnish-dev mailing list