[pve-devel] [PATCH manager 2/5] ceph: osd create: round size down to the next kib
Dominik Csapak
d.csapak at proxmox.com
Wed Jun 5 15:59:38 CEST 2019
since the size of an LV can only be a multiple of 512b, we round
down to the next kib
we then have to mulitply it by 1024 for the partition, since
append_partition expects bytes and not kib
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PVE/API2/Ceph/OSD.pm | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/PVE/API2/Ceph/OSD.pm b/PVE/API2/Ceph/OSD.pm
index 8c34b73e..64d2d0fb 100644
--- a/PVE/API2/Ceph/OSD.pm
+++ b/PVE/API2/Ceph/OSD.pm
@@ -321,6 +321,10 @@ __PACKAGE__->register_method ({
die "'$dev->{devpath}' is smaller than requested size '$size' bytes\n"
if $dev->{size} < $size;
+ # sgdisk and lvcreate can only sizes divisible by 512b
+ # so we round down to the nearest kb
+ $size = PVE::Tools::convert_size($size, 'b' => 'kb', 1);
+
if (!$dev->{used}) {
# create pv,vg,lv
@@ -328,7 +332,7 @@ __PACKAGE__->register_method ({
my $lv = $type . "-" . UUID::uuid();
PVE::Storage::LVMPlugin::lvm_create_volume_group($dev->{devpath}, $vg);
- PVE::Storage::LVMPlugin::lvcreate($vg, $lv, "${size}b");
+ PVE::Storage::LVMPlugin::lvcreate($vg, $lv, "${size}k");
return "$vg/$lv";
@@ -353,14 +357,14 @@ __PACKAGE__->register_method ({
my $lv = $type . "-" . UUID::uuid();
- PVE::Storage::LVMPlugin::lvcreate($vg, $lv, "${size}b");
+ PVE::Storage::LVMPlugin::lvcreate($vg, $lv, "${size}k");
return "$vg/$lv";
} elsif ($dev->{used} eq 'partitions') {
# create new partition at the end
- return PVE::Diskmanage::append_partition($dev->{devpath}, $size);
+ return PVE::Diskmanage::append_partition($dev->{devpath}, $size * 1024);
}
die "cannot use '$dev->{devpath}' for '$type'\n";
--
2.11.0
More information about the pve-devel
mailing list