r4022 - trunk/varnish-cache/bin/varnishd

des at projects.linpro.no des at projects.linpro.no
Thu Apr 2 14:09:16 CEST 2009


Author: des
Date: 2009-04-02 14:09:15 +0200 (Thu, 02 Apr 2009)
New Revision: 4022

Modified:
   trunk/varnish-cache/bin/varnishd/stevedore_utils.c
Log:
In struct statvfs, f_bsize is not the block size (i.e. the granularity
of f_bavail), but the recommended I/O granularity.  The field we want
is f_frsize.  This should probably be abstracted away in libvarnish.


Modified: trunk/varnish-cache/bin/varnishd/stevedore_utils.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore_utils.c	2009-04-02 09:24:43 UTC (rev 4021)
+++ trunk/varnish-cache/bin/varnishd/stevedore_utils.c	2009-04-02 12:09:15 UTC (rev 4022)
@@ -140,23 +140,28 @@
 static uintmax_t
 stv_fsspace(int fd, unsigned *bs)
 {
+	uintmax_t bsize, bavail;
 #if defined(HAVE_SYS_STATVFS_H)
 	struct statvfs fsst;
 
 	AZ(fstatvfs(fd, &fsst));
+	bsize = fsst.f_frsize;
+	bavail = fsst.f_bavail;
 #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;
 #else
 #error no struct statfs / struct statvfs
 #endif
 
 	/* We use units of the larger of filesystem blocksize and pagesize */
-	if (*bs < fsst.f_bsize)
-		*bs = fsst.f_bsize;
-	xxxassert(*bs % fsst.f_bsize == 0);
-	return (fsst.f_bsize * fsst.f_bavail);
+	if (*bs < bsize)
+		*bs = bsize;
+	xxxassert(*bs % bsize == 0);
+	return (bsize * bavail);
 }
 
 



More information about the varnish-commit mailing list