calculate reasonable metadatasize for lvm thin pools on creation
Letting LVM set the meta-data size internally was not a good idea, as it produces really small metadata LVs. Adapts the same logic as the installer. Signed-off-by: Tim Marx <t.marx@proxmox.com> Reviewed-By: Dominik Csapak <d.csapak@proxmox.com> Tested-By: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
committed by
Thomas Lamprecht
parent
14c7ede3a3
commit
3ea55f0532
@ -109,9 +109,26 @@ __PACKAGE__->register_method ({
|
||||
my $worker = sub {
|
||||
PVE::Diskmanage::locked_disk_action(sub {
|
||||
PVE::Storage::LVMPlugin::lvm_create_volume_group($dev, $name);
|
||||
my $pv = PVE::Storage::LVMPlugin::lvm_pv_info($dev);
|
||||
# keep some free space just in case
|
||||
my $datasize = $pv->{size} - 128*1024;
|
||||
# default to 1% for metadata
|
||||
my $metadatasize = $datasize/100;
|
||||
# but at least 1G, as recommended in lvmthin man
|
||||
$metadatasize = 1024*1024 if $metadatasize < 1024*1024;
|
||||
# but at most 16G, which is the current lvm max
|
||||
$metadatasize = 16*1024*1024 if $metadatasize > 16*1024*1024;
|
||||
# shrink data by needed amount for metadata
|
||||
$datasize -= 2*$metadatasize;
|
||||
|
||||
# create thinpool with size 100%, let lvm handle the metadata size
|
||||
run_command(['/sbin/lvcreate', '--type', 'thin-pool', '-l100%FREE', '-n', $name, $name]);
|
||||
run_command([
|
||||
'/sbin/lvcreate',
|
||||
'--type', 'thin-pool',
|
||||
"-L${datasize}K",
|
||||
'--poolmetadatasize', "${metadatasize}K",
|
||||
'-n', $name,
|
||||
$name
|
||||
]);
|
||||
|
||||
if ($param->{add_storage}) {
|
||||
my $storage_params = {
|
||||
|
||||
Reference in New Issue
Block a user