servalproject / serval-dna

The Serval Project's core daemon that implements Distributed Numbering Architecture (DNA), MDP, VoMP, Rhizome, MeshMS, etc.
http://servalproject.org
Other
170 stars 81 forks source link

wrong free space computation #125

Closed gh0st42 closed 6 years ago

gh0st42 commented 6 years ago

Freshly build and installed servald on a pi3.

Unable to add anything to rhizome store due to insufficient disk space.

df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        15G  1.6G   13G  12% /
devtmpfs        458M     0  458M   0% /dev
tmpfs           462M     0  462M   0% /dev/shm
tmpfs           462M  6.2M  456M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           462M     0  462M   0% /sys/fs/cgroup
/dev/mmcblk0p1   41M   21M   20M  52% /boot

df -i
Filesystem     Inodes IUsed  IFree IUse% Mounted on
/dev/root      887168 58755 828413    7% /
devtmpfs       117037   366 116671    1% /dev
tmpfs          118189     1 118188    1% /dev/shm
tmpfs          118189   435 117754    1% /run
tmpfs          118189     4 118185    1% /run/lock
tmpfs          118189    10 118179    1% /sys/fs/cgroup
/dev/mmcblk0p1      0     0      0     - /boot

Serval has its rhizome directory on / where plenty of disk space and inodes are available. A quick test with dd and writing a file larger than 100M revealed no disk related problems.

The log records DEBUG:[11593] 08:20:47.859 rhizome_store.c:200:store_get_free_space() {rhizome} RHIZOME SPACE FREE bytes=72036352 (68.7MB)

After reducing rhizome.min_free_space from 100M to 50M it works again. All other config values are left to default, e.g. rhizome.database_size=18446744073709551615.

Never had this bug before, might be SD card or OS specific or related to statvfs() implementation.

lakeman commented 6 years ago

Just because the result is assigned to a uint64_t, doesn't mean that the calculation is performed as a uint64_t. This is an easy mistake to make (that's my excuse). Which would suggest that the type of struct statvfs f_frsize and f_bavail in your statvfs.h is at most a uint32_t.