From cafdab5e13d74130abab6dca4267778d22d7d7f4 Mon Sep 17 00:00:00 2001 From: Xavier Hernandez Date: Wed, 1 Feb 2017 10:01:26 +0100 Subject: extras/rebalance.py: Fix statvfs for FreeBSD in python FreeBSD doesn't return the block size in f_bsize as linux does. It returns the optimal I/O size, so we need to consider this to avoid invalid results. On FreeBSD we take f_frsize as the block size. Change-Id: I72083d8ae183548439de874c77f1d60d9c2d14a7 BUG: 1356076 Signed-off-by: Xavier Hernandez Reviewed-on: https://review.gluster.org/16498 CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System Smoke: Gluster Build System Reviewed-by: Jeff Darcy --- extras/rebalance.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'extras') diff --git a/extras/rebalance.py b/extras/rebalance.py index 80c614c5dfe..9579e5616ad 100755 --- a/extras/rebalance.py +++ b/extras/rebalance.py @@ -11,6 +11,7 @@ import subprocess import sys import tempfile import volfilter +import platform # It's just more convenient to have named fields. class Brick: @@ -218,12 +219,19 @@ if __name__ == "__main__": total = 0 for b in bricks: info = os.statvfs(b.path) + # On FreeBSD f_bsize (info[0]) contains the optimal I/O size, + # not the block size as it's found on Linux. In this case we + # use f_frsize (info[1]). + if platform.system() == 'FreeBSD': + bsize = info[1] + else: + bsize = info[0] # We want a standard unit even if different bricks use # different block sizes. The size is chosen to avoid overflows # for very large bricks with very small block sizes, but also # accommodate filesystems which use very large block sizes to # cheat on benchmarks. - blocksper100mb = 104857600 / info[0] + blocksper100mb = 104857600 / bsize if options.free_space: size = info[3] / blocksper100mb else: -- cgit