'Given a disk name, a path to a tunable value under _TUNE_PATH and the
new value for the parameter, set the value and verify that the value
has been successfully set.'

def set_tunable(self, disk, name, path, val):

    fpath = partition.get_iosched_path(disk, path)
    try:
        step = 'open    tunable    path'
        tunef = open(fpath, 'w', buffering=(-1))
        step = 'write    new    tunable    value'
        tunef.write(val)
        step = 'close    the    tunable    path'
        tunef.close()
        step = 'read    back    new    tunable    value'
        nval = open(fpath, 'r', buffering=(-1)).read().strip()
        if (name == 'scheduler'):
            nval = re.match('.*\\[(.*)\\].*', nval).group(1)
    except IOError as info:
        if ((name == 'max_sectors_kb') and (info.errno == 22) and (val != '128')):
            self.set_tunable(disk, name, path, '128')
            return
        raise Exception(((((("Unable    to    set    tunable    value    '" + name) + "'    at    step    '") + step) + "':    ") + str(info)))
    except Exception:
        raise Exception(('Unable    to    set    tunable    value    for    ' + name))
    if (nval != val):
        raise Exception(((((('Unable    to    correctly    set    tunable    value    for    ' + name) + ':    desired    ') + val) + ',    but    found    ') + nval))
    return
