summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorXavier Hernandez <xhernandez@datalab.es>2017-02-01 10:01:26 +0100
committerJeff Darcy <jdarcy@redhat.com>2017-02-07 07:51:01 -0500
commitcafdab5e13d74130abab6dca4267778d22d7d7f4 (patch)
tree7af7f9f972a1f0dc0ffb365e8ac93c9555dd56b9 /extras
parent563cafb5a5e742fc7fd2c175b332f0000c053040 (diff)
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 <xhernandez@datalab.es> Reviewed-on: https://review.gluster.org/16498 CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'extras')
-rwxr-xr-xextras/rebalance.py10
1 files changed, 9 insertions, 1 deletions
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: