lvmplugin: to squash
This commit is contained in:
parent
54b2e4bb22
commit
49192fdda6
2 changed files with 26 additions and 16 deletions
|
|
@ -11,7 +11,6 @@ use PVE::Storage::Plugin;
|
|||
use PVE::JSONSchema qw(get_standard_option);
|
||||
|
||||
use PVE::Storage::Common;
|
||||
use PVE::SafeSyslog;
|
||||
|
||||
use JSON;
|
||||
|
||||
|
|
@ -401,6 +400,8 @@ sub options {
|
|||
tagged_only => { optional => 1 },
|
||||
bwlimit => { optional => 1 },
|
||||
'snapshot-as-volume-chain' => { optional => 1 },
|
||||
chunksize => { optional => 1 },
|
||||
'chunk-percentage' => { optional => 1 },
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -586,7 +587,6 @@ my sub lvm_qcow2_format {
|
|||
};
|
||||
if ($backing_snap) {
|
||||
my $backing_volname = get_snap_name($class, $name, $backing_snap);
|
||||
# TODO: make this variable a check box when taking a snapshot
|
||||
PVE::Storage::Common::qemu_img_create_qcow2_backed(
|
||||
$path, $backing_volname, $fmt, $options, $thin,
|
||||
);
|
||||
|
|
@ -634,8 +634,12 @@ my sub alloc_lvm_image {
|
|||
|
||||
my $free = int($vgs->{$vg}->{free});
|
||||
my $lvmsize;
|
||||
if ($backing_snap) {
|
||||
$lvmsize = 2.5 * 1024 * 1024;
|
||||
|
||||
# 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);
|
||||
}
|
||||
|
|
@ -649,7 +653,6 @@ my sub alloc_lvm_image {
|
|||
|
||||
return if $fmt ne 'qcow2';
|
||||
|
||||
my $thin = $backing_snap ? 1 : 0;
|
||||
#format the lvm volume with qcow2 format
|
||||
eval { lvm_qcow2_format($class, $storeid, $scfg, $name, $fmt, $backing_snap, $size, $thin) };
|
||||
if ($@) {
|
||||
|
|
@ -952,10 +955,7 @@ sub volume_underlay_resize {
|
|||
my ($class, $scfg, $storeid, $volname, $backing_snap) = @_;
|
||||
|
||||
my ($format) = ($class->parse_volname($volname))[6];
|
||||
# extend underlay lv
|
||||
# need to check if next size is going to surpass the qcow2 virtual size
|
||||
# if so need to calculate the final size with calculate_lvm_size
|
||||
# by using qemu_img_info
|
||||
|
||||
my $path = $class->filesystem_path($scfg, $volname);
|
||||
my $json = PVE::Storage::Common::qemu_img_info($path, undef, 10, 0);
|
||||
my $json_decode = eval { decode_json($json) };
|
||||
|
|
@ -963,18 +963,14 @@ sub volume_underlay_resize {
|
|||
die "Can't decode qemu snapshot list. Invalid JSON: $@\n";
|
||||
}
|
||||
|
||||
my $virtual_size = int($json_decode->{'virtual-size'} / 1024);
|
||||
syslog("info", "current qcow2 virtual size $virtual_size KiB\n");
|
||||
my $virtual_size = $json_decode->{'virtual-size'} / 1024;
|
||||
|
||||
my $underlay_size = lv_size($path, 10);
|
||||
syslog("info", "current underlay size $underlay_size B\n ");
|
||||
# FIX: 1GiB increment needs to change to a configurable var $scfg->{chunk_size}
|
||||
my $updated_underlay_size = ($underlay_size + (1024 * 1024 * 1024)) / 1024;
|
||||
syslog("info", "current updated underlay size $updated_underlay_size KiB\n");
|
||||
|
||||
my $updated_underlay_size = ($underlay_size + $scfg->{chunksize}) / 1024;
|
||||
$updated_underlay_size = calculate_lvm_size($virtual_size, $format, $backing_snap)
|
||||
if $updated_underlay_size >= $virtual_size;
|
||||
|
||||
syslog("info", "current updated underlay size $updated_underlay_size KiB\n");
|
||||
my $lvmsize = "${updated_underlay_size}k";
|
||||
lv_extend($class, $scfg, $storeid, $lvmsize, $path);
|
||||
|
||||
|
|
|
|||
|
|
@ -228,6 +228,20 @@ my $defaultData = {
|
|||
default => 0,
|
||||
optional => 1,
|
||||
},
|
||||
chunksize => {
|
||||
type => 'integer',
|
||||
description => 'The chunksize in Bytes to define the write threshold'
|
||||
. 'of thin disks on thick storage.',
|
||||
default => 1073741824, # 1 GiB
|
||||
optional => 1,
|
||||
},
|
||||
'chunk-percentage' => {
|
||||
type => 'number',
|
||||
description => 'The percentage of written disk to define the write'
|
||||
. 'threshold.',
|
||||
default => 0.5,
|
||||
optional => 1,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue