Bug 764816 (GLUSTER-3084) - Correcting percent calculation of disk space
Summary: Correcting percent calculation of disk space
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: GLUSTER-3084
Product: GlusterFS
Classification: Community
Component: core
Version: 3.0.0
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
Assignee: shishir gowda
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-06-24 08:19 UTC by jenith
Modified: 2013-12-09 01:25 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Regression: ---
Mount Type: ---
Documentation: ---
CRM: 3432
Verified Versions: master


Attachments (Terms of Use)

Description Amar Tumballi 2011-06-24 05:47:31 UTC
One line change,

change, '(f_bfree * 100) / f_blocks' to '(f_bavail * 100) / f_blocks'

Comment 1 jenith 2011-06-24 08:19:44 UTC
Hi,
Here the system df and the Gluster is reporting the different percentage of disk use.

[........]
Below are the output from 'statfs()' call of customer.


> This brick are now to 89%:
>
>
> [root@llfe894 ~]# strace -f -v df -h
> statfs("/data", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096,
> f_blocks=233970473, f_bfree=38103468, f_bavail=26026705,
> f_files=241565696, f_ffree=239328261, f_fsid={0, 0}, f_namelen=255,
> f_frsize=4096}) = 0
> write(1, "/dev/mapper/ddf1_RAIDp3\n", 24/dev/mapper/ddf1_RAIDp3
> ) = 24
> write(1, " 893G 748G"..., 50
> 893G 748G 100G 89% /data
> ) = 50
>

Here df is using the formula 'f_bavail * 100 / f_blocks' to get the
available space, and we as said earlier use formula 'f_bfree * 100 /
f_blocks'.


> percent = (statvfs->f_bfree * 100) / statvfs->f_blocks;
> > 'man statvfs'
> >
> > Where's:
> > f_bfree = /* # free blocks */
> > f_blocks = /* size of fs in f_frsize units */
>

long f_bavail; /* free blocks avail to non-superuser */


> > f_frsize = /* fragment size */
> > [...]
> >
>

That explains the current behavior of he seeing less than 'min-free-disk'
space in filesystem, but GlusterFS seeing more than 'min-free-disk'.

[........]

Comment 2 Anand Avati 2011-07-07 08:45:34 UTC
PATCH: http://patches.gluster.com/patch/7765 in master (dht disk usage: Correct free blk calculation)

Comment 3 shylesh 2011-09-15 04:27:05 UTC
Formula has changed to calculate the available space

if (statvfs && statvfs->f_blocks) {
                percent = (statvfs->f_bavail * 100) / statvfs->f_blocks;
                bytes = (statvfs->f_bavail * statvfs->f_frsize);
        }


Note You need to log in before you can comment on or make changes to this bug.