[pve-devel] [PATCH Storage] Newly created LVM volumes are now created with a number of stripes equal to the number of physical volumes in a volume group.

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Jul 27 11:54:22 CEST 2017


LVM seems to do a sane thing by default here, and can be configured to
do what you're doing via lvm.conf AFAICT.
>From lvcreate(1):
| In order to stripe across all PVs of the VG if the -i argument is
| omitted, set raid_stripe_all_devices=1 in the allocation section of
| lvm.conf (5)

And the default behavior:
| RAID 0 will stripe across 2 devices, RAID 4/5 across 3 PVs, RAID 6
| across 5 PVs and RAID 10 across 4 PVs in the volume group if the -i
| argument is omitted.


I'd argue this should be left to the user to configure via lvm.conf
then.

In any case, two comments on the patch itself:
You should disable line-wrapping in your mail client when sending
patches as it cannot be applied via `git am` currently.
And I think I'd prefer adding the "pv_count" option to `lvm_vgs()`
instead of adding a separate function for it.


On Wed, Jul 26, 2017 at 08:47:03PM +0200, Martin Lablans wrote:
> Signed-off-by: Martin Lablans <code at martin.lablans.de>
> ---
>  PVE/Storage/LVMPlugin.pm | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/Storage/LVMPlugin.pm b/PVE/Storage/LVMPlugin.pm
> index 9633e4c..cfb18e4 100644
> --- a/PVE/Storage/LVMPlugin.pm
> +++ b/PVE/Storage/LVMPlugin.pm
> @@ -285,13 +285,30 @@ sub alloc_image {
>      $name = lvm_find_free_diskname(lvm_list_volumes($vg), $vg, $storeid,
> $vmid)
>  	if !$name;
> 
> -    my $cmd = ['/sbin/lvcreate', '-aly', '--addtag', "pve-vm-$vmid",
> '--size', "${size}k", '--name', $name, $vg];
> +    my $num_pvs = lvm_find_number_of_pv($vg);
> +
> +    my $cmd = ['/sbin/lvcreate', '-aly', '-i', $num_pvs, '--addtag',
> "pve-vm-$vmid", '--size', "${size}k", '--name', $name, $vg];
> 
>      run_command($cmd, errmsg => "lvcreate '$vg/pve-vm-$vmid' error");
> 
>      return $name;
>  }
> 
> +sub lvm_find_number_of_pv {
> +    my ($vg) = @_;
> +
> +    my $cmd = ['/sbin/vgs', $vg, '--noheadings', '--unbuffered',
> '--nosuffix', '--options', 'pv_count'];
> +
> +    my $ret;
> +
> +    run_command($cmd, errmsg => "lvm_find_number_of_pv: Cannot determine
> number of PVs for VG $vg", outfunc => sub {
> +        my $line = shift;
> +        $ret = trim($line);
> +    });
> +
> +    return $ret;
> +}
> +
>  sub free_image {
>      my ($class, $storeid, $scfg, $volname, $isBase) = @_;




More information about the pve-devel mailing list