[PATCH 1/2] Change stv_fsspace to be stv_fssize
Martin Blix Grydeland
martin at varnish-software.com
Fri Oct 3 16:43:09 CEST 2014
Doing e.g. -sfile,varnish.bin,90% sets the size of varnish.bin to 90%
of the available file system space where the file resides. This
doesn't take into account the size of varnish.bin and creates problems
on subsequent invocations. The first time it becomes 90% of the free
space. Next startup it becomes 90% of the 10% free space, which would
be 9% of the total space causing the free space to be 91%. Next
startup it becomes 90% of 91% etc.
With this change we look at the total size of the filesystem, which
can be a useful and well defined metric when using a dedicated data
partion for the storage.
---
bin/varnishd/storage/stevedore_utils.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c
index a86d57e..c865f6e 100644
--- a/bin/varnishd/storage/stevedore_utils.c
+++ b/bin/varnishd/storage/stevedore_utils.c
@@ -133,25 +133,25 @@ STV_GetFile(const char *fn, int *fdp, const char **fnp, const char *ctx)
}
/*--------------------------------------------------------------------
- * Figure out how much space is in a filesystem
+ * Figure out the size of the filesystem
*/
static uintmax_t
-stv_fsspace(int fd, unsigned *bs)
+stv_fssize(int fd, unsigned *bs)
{
- uintmax_t bsize, bavail;
+ uintmax_t bsize, blocks;
#if defined(HAVE_SYS_STATVFS_H)
struct statvfs fsst;
AZ(fstatvfs(fd, &fsst));
bsize = fsst.f_frsize;
- bavail = fsst.f_bavail;
+ blocks = fsst.f_blocks;
#elif defined(HAVE_SYS_MOUNT_H) || defined(HAVE_SYS_VFS_H)
struct statfs fsst;
AZ(fstatfs(sc->fd, &fsst));
bsize = fsst.f_bsize;
- bavail = fsst.f_bavail;
+ blocks = fsst.f_blocks;
#else
#error no struct statfs / struct statvfs
#endif
@@ -160,7 +160,7 @@ stv_fsspace(int fd, unsigned *bs)
if (*bs < bsize)
*bs = bsize;
XXXAZ(*bs % bsize);
- return (bsize * bavail);
+ return (bsize * blocks);
}
@@ -187,7 +187,7 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx)
xxxassert(S_ISREG(st.st_mode));
bs = *granularity;
- fssize = stv_fsspace(fd, &bs);
+ fssize = stv_fssize(fd, &bs);
XXXAZ(bs % *granularity);
if ((size == NULL || *size == '\0') && st.st_size != 0) {
--
2.1.0
More information about the varnish-dev
mailing list