DragonFly BSD
DragonFly bugs List (threaded) for 2009-12
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

weird problem with statvfs() on a hammer filesystems

From: Johannes Hofmann <johannes.hofmann@xxxxxx>
Date: 03 Dec 2009 18:03:53 GMT


I'm seeing a weird problem with statvfs() on a hammer filesystems.
With this little test program:

#include <inttypes.h> 
#include <stdio.h> 
#include <sys/statvfs.h>

int main(int argc, char **argv) {
	struct statvfs  fsbuf;

	if (statvfs(argv[1], &fsbuf) < 0)
		err(1, "Can't statvfs() `%s'", argv[1]);

	fprintf(stderr, "statvfs %s, bavail %lld, frsize %lld\n",
		argv[1], fsbuf.f_bavail, fsbuf.f_frsize);

I get fsbuf.f_bavail == 0 on a freshly mounted hammer FS:

vkernel-leaf# dd if=/dev/zero of=hammer.img bs=1024 count=194000
vkernel-leaf# vnconfig vn0 hammer.img
vkernel-leaf# newfs_hammer -L foo -f /dev/vn0
vkernel-leaf# mount_hammer /dev/vn0 /mnt/
vkernel-leaf# ./statvfs	/mnt/
statvfs /mnt/, bavail 0, frsize 16384

After doing df -k, things are back to normal:

vkernel-leaf# df -k
Filesystem   1K-blocks   Used   Avail Capacity  Mounted on
/dev/vkd0s0a    516054 503790  -29020   106%    /
devfs                1      1       0   100%    /dev
foo              65536 210016 -144480   320%    /mnt
vkernel-leaf# ./statvfs /mnt/
statvfs /mnt/, bavail -9030, frsize 16384

I added some kprintf()s:

diff --git a/sys/vfs/hammer/hammer_vfsops.c b/sys/vfs/hammer/hammer_vfsops.c
index 0b6139e..f94bfed 100644
--- a/sys/vfs/hammer/hammer_vfsops.c
+++ b/sys/vfs/hammer/hammer_vfsops.c
@@ -921,10 +921,17 @@ hammer_vfs_statvfs(struct mount *mp, struct statvfs *sbp, struct ucred *cred)
 	hammer_rel_volume(volume, 0);
 	mp->mnt_vstat.f_bfree = (bfree - breserved) / HAMMER_BUFSIZE;
+kprintf("hammer_vfs_statvfs: mp->mnt_vstat.f_bfree %lld\n", mp->mnt_vstat.f_bfree);
 	mp->mnt_vstat.f_bavail = mp->mnt_stat.f_bfree;
+kprintf("hammer_vfs_statvfs: mp->mnt_vstat.f_bavail %lld\n", mp->mnt_vstat.f_bavail);
 	if (mp->mnt_vstat.f_files < 0)
 		mp->mnt_vstat.f_files = 0;
 	*sbp = mp->mnt_vstat;

With those I get:

hammer_vfs_statvfs: mp->mnt_vstat.f_bfree 9721495
hammer_vfs_statvfs: mp->mnt_vstat.f_bavail 0

What am I missing?


PS: The original problem is that pkgin is reporting not enough space to
    install packages.

[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]