lvmplugin: add thin volume support for LVM external snapshots
This commit is contained in:
parent
5660533330
commit
52a5705540
2 changed files with 17 additions and 6 deletions
|
|
@ -170,7 +170,7 @@ C<$options> currently allows setting the C<preallocation> value.
|
|||
=cut
|
||||
|
||||
sub qemu_img_create_qcow2_backed {
|
||||
my ($path, $backing_path, $backing_format, $options) = @_;
|
||||
my ($path, $backing_path, $backing_format, $options, $thin) = @_;
|
||||
|
||||
my $cmd = [
|
||||
'/usr/bin/qemu-img',
|
||||
|
|
@ -188,7 +188,7 @@ sub qemu_img_create_qcow2_backed {
|
|||
my $opts = ['extended_l2=on', 'cluster_size=128k'];
|
||||
|
||||
push @$opts, "preallocation=$options->{preallocation}"
|
||||
if defined($options->{preallocation});
|
||||
if defined($options->{preallocation}) && !$thin;
|
||||
push @$cmd, '-o', join(',', @$opts) if @$opts > 0;
|
||||
|
||||
run_command($cmd, errmsg => "unable to create image");
|
||||
|
|
|
|||
|
|
@ -575,7 +575,7 @@ sub lvrename {
|
|||
}
|
||||
|
||||
my sub lvm_qcow2_format {
|
||||
my ($class, $storeid, $scfg, $name, $fmt, $backing_snap, $size) = @_;
|
||||
my ($class, $storeid, $scfg, $name, $fmt, $backing_snap, $size, $thin) = @_;
|
||||
|
||||
$class->activate_volume($storeid, $scfg, $name);
|
||||
my $path = $class->path($scfg, $name, $storeid);
|
||||
|
|
@ -585,7 +585,9 @@ my sub lvm_qcow2_format {
|
|||
};
|
||||
if ($backing_snap) {
|
||||
my $backing_volname = get_snap_name($class, $name, $backing_snap);
|
||||
PVE::Storage::Common::qemu_img_create_qcow2_backed($path, $backing_volname, $fmt, $options);
|
||||
PVE::Storage::Common::qemu_img_create_qcow2_backed(
|
||||
$path, $backing_volname, $fmt, $options, $thin,
|
||||
);
|
||||
} else {
|
||||
PVE::Storage::Common::qemu_img_create($fmt, $size, $path, $options);
|
||||
}
|
||||
|
|
@ -629,7 +631,16 @@ my sub alloc_lvm_image {
|
|||
die "no such volume group '$vg'\n" if !defined($vgs->{$vg});
|
||||
|
||||
my $free = int($vgs->{$vg}->{free});
|
||||
my $lvmsize = calculate_lvm_size($size, $fmt, $backing_snap);
|
||||
my $lvmsize;
|
||||
|
||||
# FIX: make this variable a check box when taking a snapshot
|
||||
# right now all snapshots are created thin for testing purposes
|
||||
my $thin = $backing_snap ? 1 : 0;
|
||||
if ($thin) {
|
||||
$lvmsize = 2 * 1024 * 1024;
|
||||
} else {
|
||||
$lvmsize = calculate_lvm_size($size, $fmt, $backing_snap);
|
||||
}
|
||||
|
||||
die "not enough free space ($free < $size)\n" if $free < $size;
|
||||
|
||||
|
|
@ -641,7 +652,7 @@ my sub alloc_lvm_image {
|
|||
return if $fmt ne 'qcow2';
|
||||
|
||||
#format the lvm volume with qcow2 format
|
||||
eval { lvm_qcow2_format($class, $storeid, $scfg, $name, $fmt, $backing_snap, $size) };
|
||||
eval { lvm_qcow2_format($class, $storeid, $scfg, $name, $fmt, $backing_snap, $size, $thin) };
|
||||
if ($@) {
|
||||
my $err = $@;
|
||||
#no need to safe cleanup as the volume is still empty
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue