[pve-devel] [PATCH storage] Fix #2346: rbd: storage shows wrong %-usage
Thomas Lamprecht
t.lamprecht at proxmox.com
Mon Sep 2 15:56:19 CEST 2019
On 9/2/19 3:49 PM, Alwin Antreich wrote:
> The patch uses the value from the new field 'stored' if it is available.
>
> In Ceph 14.2.2 the storage calculation changed to a per pool basis. This
> introduced an additional field 'stored' that holds the amount of data
> that has been written to the pool. While the field 'used' now has the
> data after replication for the pool.
>
> The new calculation will be used only if all OSDs are running with the
> on-disk format introduced by Ceph 14.2.2.
>
> Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
> ---
> PVE/Storage/RBDPlugin.pm | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
> index 8433715..5e351a9 100644
> --- a/PVE/Storage/RBDPlugin.pm
> +++ b/PVE/Storage/RBDPlugin.pm
> @@ -521,7 +521,7 @@ sub status {
> # max_avail -> max available space for data w/o replication in the pool
> # bytes_used -> data w/o replication in the pool
> my $free = $d->{stats}->{max_avail};
> - my $used = $d->{stats}->{bytes_used};
> + my $used = $d->{stats}->{stored} ? $d->{stats}->{stored} : $d->{stats}->{bytes_used};
and stored can never be validly zero? I'd rathe do:
my $used = $d->{stats}->{stored} // $d->{stats}->{bytes_used};
So it's works on "defindness" not "perl-truthiness" and is sligthly
more concise, personally I'd like to avoid ternary statements where
not really necessary or a good alternative exists.
> my $total = $used + $free;
> my $active = 1;
>
>
More information about the pve-devel
mailing list