Skip to content

Instantly share code, notes, and snippets.

@splaice
Created May 8, 2014 18:43
Show Gist options
  • Save splaice/f4cab66633518554acb2 to your computer and use it in GitHub Desktop.
Save splaice/f4cab66633518554acb2 to your computer and use it in GitHub Desktop.
Speed up md raid rebuilds
#!/usr/bin/env python
import argparse
import sys
MAX_FP = '/proc/sys/dev/raid/speed_limit_max'
MIN_FP = '/proc/sys/dev/raid/speed_limit_min'
MAX_DEFAULT=200000
MIN_DEFAULT=1000
MAX_TURBO = MAX_DEFAULT * 2
MIN_TURBO = MIN_DEFAULT * 50
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'--enable',
dest='enable',
action='store_true',
default=False)
parser.add_argument(
'--disable',
dest='disable',
action='store_true',
default=False)
args = parser.parse_args()
if args.enable and args.disable:
sys.stderr.write('you cannot enable and disable turbo at the same time\n')
sys.exit(1)
elif not args.enable and not args.disable:
sys.stderr.write('doing nothing, use --enable or --disable\n')
sys.exit(1)
if args.enable:
enable_turbo = True
elif args.disable:
enable_turbo = False
with open(MAX_FP, 'w') as fd:
if enable_turbo:
fd.write(str(MAX_TURBO))
else:
fd.write(str(MAX_DEFAULT))
with open(MIN_FP, 'w') as fd:
if enable_turbo:
fd.write(str(MIN_TURBO))
else:
fd.write(str(MIN_DEFAULT))
if enable_turbo:
sys.stdout.write('turbo rebuild enabled\n')
else:
sys.stdout.write('turbo rebuild disabled\n')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment