[master] eb1ca9d Use VFIL_allocate in -sfile

Martin Blix Grydeland martin at varnish-software.com
Tue Oct 21 12:25:43 CEST 2014


commit eb1ca9d710bbfbf0ab9306b6e9b2789bbcf15c1e
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Tue Oct 7 16:09:40 2014 +0200

    Use VFIL_allocate in -sfile

diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c
index 04d9707..9b6a794 100644
--- a/bin/varnishd/storage/storage_file.c
+++ b/bin/varnishd/storage/storage_file.c
@@ -40,6 +40,7 @@
 #include "storage/storage.h"
 
 #include "vnum.h"
+#include "vfil.h"
 
 #ifndef MAP_NOCORE
 #define MAP_NOCORE 0 /* XXX Linux */
@@ -99,16 +100,6 @@ struct smf_sc {
 /*--------------------------------------------------------------------*/
 
 static void
-smf_initfile(struct smf_sc *sc, const char *size)
-{
-	sc->filesize = STV_FileSize(sc->fd, size, &sc->pagesize, "-sfile");
-
-	AZ(ftruncate(sc->fd, (off_t)sc->filesize));
-
-	/* XXX: force block allocation here or in open ? */
-}
-
-static void
 smf_init(struct stevedore *parent, int ac, char * const *av)
 {
 	const char *size, *fn, *r;
@@ -149,9 +140,10 @@ smf_init(struct stevedore *parent, int ac, char * const *av)
 	parent->priv = sc;
 
 	(void)STV_GetFile(fn, &sc->fd, &sc->filename, "-sfile");
-
 	mgt_child_inherit(sc->fd, "storage_file");
-	smf_initfile(sc, size);
+	sc->filesize = STV_FileSize(sc->fd, size, &sc->pagesize, "-sfile");
+	if (VFIL_allocate(sc->fd, (off_t)sc->filesize, 0))
+		ARGV_ERR("(-sfile) allocation error: %s\n", strerror(errno));
 }
 
 /*--------------------------------------------------------------------



More information about the varnish-commit mailing list