diff options
author | Xavier Hernandez <xhernandez@datalab.es> | 2017-02-01 10:01:26 +0100 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2017-02-16 10:52:16 -0500 |
commit | 9475d006793f0b5b0284ddc6ad038605e31a81a8 (patch) | |
tree | f1136414c056ae09ad5e0c8b7bd556c6b154060e /extras | |
parent | 69ab6b963585f3080771221c3a0cc4549e6eebb1 (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>
Change-Id: I751155e2507cab08ded3eafa85d571b778713fbb
BUG: 1422777
Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
Reviewed-on: https://review.gluster.org/16631
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Diffstat (limited to 'extras')
-rwxr-xr-x | extras/rebalance.py | 10 |
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: |