Bug #1619
closedweird problem with statvfs() on a hammer filesystems
0%
Description
Hi,
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;
+
return(0);
}
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?
Cheers,
Johannes
PS: The original problem is that pkgin is reporting not enough space to
install packages.
Updated by dillon about 15 years ago
:Hi,
:
:I'm seeing a weird problem with statvfs() on a hammer filesystems.
:With this little test program:
:
:..
:
:I get fsbuf.f_bavail == 0 on a freshly mounted hammer FS:
Ach. I think I see it. Try the patch below.
-Matt
diff --git a/sys/vfs/hammer/hammer_vfsops.c b/sys/vfs/hammer/hammer_vfsops.c
index fa478bf..79321cd 100644
--- a/sys/vfs/hammer/hammer_vfsops.c
+++ b/sys/vfs/hammer/hammer_vfsops.c@ -935,7 +935,7
@ 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;
- mp->mnt_vstat.f_bavail = mp->mnt_stat.f_bfree;
+ mp->mnt_vstat.f_bavail = mp->mnt_vstat.f_bfree;
if (mp->mnt_vstat.f_files < 0)
mp->mnt_vstat.f_files = 0;
*sbp = mp->mnt_vstat;
Updated by Johannes.Hofmann about 15 years ago
Matthew Dillon <dillon@apollo.backplane.com> wrote:
:Hi,
:
:I'm seeing a weird problem with statvfs() on a hammer filesystems.
:With this little test program:
:
:..
:
:I get fsbuf.f_bavail == 0 on a freshly mounted hammer FS:Ach. I think I see it. Try the patch below.
-Matt
diff --git a/sys/vfs/hammer/hammer_vfsops.c b/sys/vfs/hammer/hammer_vfsops.c
index fa478bf..79321cd 100644
--- a/sys/vfs/hammer/hammer_vfsops.c
+++ b/sys/vfs/hammer/hammer_vfsops.c@ -935,7 +935,7
@ 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;
- mp->mnt_vstat.f_bavail = mp->mnt_stat.f_bfree;
+ mp->mnt_vstat.f_bavail = mp->mnt_vstat.f_bfree;
if (mp->mnt_vstat.f_files < 0)
mp->mnt_vstat.f_files = 0;
*sbp = mp->mnt_vstat;
Haha. That's it. I was staring at this line for quite some time and
started to blame compiler bugs and cosmic rays.
Thanks,
Johannes
Updated by tuxillo almost 15 years ago
Fix in commit c07636592ca4cdb9af0f0dc65a13221577fad67b