From fecbe9d5e51fbb0c3f3da6fdadf25cf4d432cafd Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 8 Jun 2009 15:19:22 +0200 Subject: [PATCH] Enable stripped LVs This patch enables stripped LVs, falling back to non-stripped if the stripped creation fails. If the configure-time lvm-stripecount is 1, this patch becomes a noop (with an insignificant python-level overhead, but no extra lvm calls). The effect of this patch is that new instances will get stripped LVs from the start, whereas old instances will have their LVs stripped as soon as replace-disks is run for them. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- lib/bdev.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/bdev.py b/lib/bdev.py index 50c1e5c6a..5f94d5078 100644 --- a/lib/bdev.py +++ b/lib/bdev.py @@ -319,14 +319,23 @@ class LogicalVolume(BlockDev): pvlist = [ pv[1] for pv in pvs_info ] free_size = sum([ pv[0] for pv in pvs_info ]) + current_pvs = len(pvlist) + stripes = min(current_pvs, constants.LVM_STRIPECOUNT) # The size constraint should have been checked from the master before # calling the create function. if free_size < size: _ThrowError("Not enough free space: required %s," " available %s", size, free_size) - result = utils.RunCmd(["lvcreate", "-L%dm" % size, "-n%s" % lv_name, - vg_name] + pvlist) + cmd = ["lvcreate", "-L%dm" % size, "-n%s" % lv_name] + # If the free space is not well distributed, we won't be able to + # create an optimally-striped volume; in that case, we want to try + # with N, N-1, ..., 2, and finally 1 (non-stripped) number of + # stripes + for stripes_arg in range(stripes, 0, -1): + result = utils.RunCmd(cmd + ["-i%d" % stripes_arg] + [vg_name] + pvlist) + if not result.failed: + break if result.failed: _ThrowError("LV create failed (%s): %s", result.fail_reason, result.output) -- GitLab