[DRBD-user] drbdmanage-proxmox v2.0

Robert Altnoeder robert.altnoeder at linbit.com
Thu Sep 28 11:51:28 CEST 2017

Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.


On 09/28/2017 11:10 AM, Frank Rust wrote:
> Hi Roland,
> I am not a perl-friend too.
+1
> +    my $x=$size;
> +    my $unit="gib"; # GiB is default
> +    my $factor=1024*1024;
> +    if ($x/$factor != int($x/$factor)) {
> +      $factor=$factor/1024; $unit="mib";
> +      if ($x/$factor != int($x/$factor)) {
> +        $factor=$factor/1024; $unit="kib";
> +      }
> +    };
> +    $size=sprintf("%u%s",($x/$factor),$unit);
> +    print "Size=$size\n";
> +
>      drbdmanage_cmd(['/usr/bin/drbdmanage', 'new-resource', $name], "Could not create resource $name");
>      drbdmanage_cmd(['/usr/bin/drbdmanage', 'new-volume', $name, $size], "Could not create-volume in $name resource");
Apparently, the original size ($size) is in kiB, so the question would
rather be whether it makes much sense to recalculate the size in a
different unit if it is only going to be used for a machine-to-machine
interface.
The most efficient way would be to just pass the original size in kiB to
drbdmanage, because drbdmanage also uses kiB internally, so if a value
in any other unit is passed to drbdmanage, it is recalculated in kiB anyway.

If the size is a number that is not a round number in MiB or GiB, and
you would like to pass in round numbers, I would suggest to just align
the kiB value, e.g.

int alignment = 1 << 20;
if (size % alignment != 0)
{
    size = (size / alignment + 1) * alignment;
}

(good luck translating it to Perl ;)

> BTW: I am sure that I never added a VM Image that was not multiple of 1GB in size, but other storage implementations seem to have rounding errors causing strange sizes after moving images around...
The actual size that is allocated by drbdmanage on the backend storage
will almost never be a multiple of a MiB or GiB, because the size of
volumes is specified as a net value, while the backend storage will have
to be slightly larger to provide space for DRBD meta data.

br,
-- 
Robert Altnoeder
+43 1 817 82 92 0
robert.altnoeder at linbit.com

LINBIT | Keeping The Digital World Running
DRBD - Corosync - Pacemaker
f /  t /  in /  g+

DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.



More information about the drbd-user mailing list