Varnish on FreeBSD

Olivier Nicole on at cs.ait.ac.th
Wed Apr 1 09:47:50 CEST 2009


Hi again,

After some diging I have the answer.

On FreeBSD, from the man page of fstatvfs:

           f_bsize    The preferred length of I/O requests for files on this
                      file system.  (Corresponds to the f_iosize member of
                      struct statfs.)


It is not said that f_bsize is the block size, while f_bavail is given
in blocks. So in the function smf_fsspace:

	return (fsst.f_bsize * fsst.f_bavail);

is over estimating.

On Linux it seems that f_bsize is the block size, but I have no man
fstatvfs available at hand.

I ran a simple test:


#include <sys/statvfs.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>

main () {
  int fp;
  int r;
  struct statvfs buf;
    r=statvfs("/tmp/on", &buf);
    if (r==0) {
      printf("%lu %llu\n", buf.f_bsize, buf.f_bavail);
    }
    else {
      perror("me");
    }
}

$ a.out
16384 2297104
$ df /
Filesystem    1K-blocks  Used   Avail Capacity  Mounted on
/dev/mfid0s1a   5077038 76668 4594208     2%    /
$

If the block size of 2KB, the results are consistant.

Best regards,

Olivier



More information about the varnish-misc mailing list