diff --git a/tuned/plugins/plugin_disk.py b/tuned/plugins/plugin_disk.py index 3626764..ba63e1d 100644 --- a/tuned/plugins/plugin_disk.py +++ b/tuned/plugins/plugin_disk.py @@ -143,11 +143,7 @@ class DiskPlugin(base.Plugin): sys_file = self._elevator_file(device) # example of scheduler file content: # noop deadline [cfq] - schedulers = tuned.utils.commands.read_file(sys_file).split() - for scheduler in schedulers: - if scheduler[0] == "[" and scheduler[-1] == "]": - return scheduler[1:-1] - return schedulers[0] + return tuned.utils.commands.get_active_option(tuned.utils.commands.read_file(sys_file)) def _alpm_policy_files(self): policy_files = [] diff --git a/tuned/utils/commands.py b/tuned/utils/commands.py index 2be9caf..aec90ab 100644 --- a/tuned/utils/commands.py +++ b/tuned/utils/commands.py @@ -43,6 +43,15 @@ def execute(args): log.error("Executing %s error: %s" % (args[0], e)) return out +# Helper for parsing kernel options like: +# [always] never +# It will return 'always' +def get_active_option(options): + m = re.match(r'.*\[([^\]]+)\].*', options) + if m: + return m.group(1) + return options.split()[0] + def recommend_profile(): profile = consts.DEFAULT_PROFILE for f in consts.LOAD_DIRECTORIES: