As reported in the enterprise support, the usage percentage presented
by Proxmox VE can be quite different from what Ceph itself shows when
compression is used on the pool. The reason is that Proxmox VE used
the 'stored' value as a basis for the calculation which is the amount
of logically stored user data, i.e. before compression. In the context
of presenting storage usage, this is not the best choice and e.g. in
the ZFS plugin 'used' is preferred over 'logicalused'. Switch to using
'bytes_used' as the basis for the calculation to better match
expectations.

Signed-off-by: Fiona Ebner <f.eb...@proxmox.com>
---

New approach in v2, use actual storage usage as the basis for
calculation.

 src/PVE/Storage/RBDPlugin.pm | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm
index 154fa00..8bb5a26 100644
--- a/src/PVE/Storage/RBDPlugin.pm
+++ b/src/PVE/Storage/RBDPlugin.pm
@@ -690,7 +690,7 @@ sub status {
     my ($class, $storeid, $scfg, $cache) = @_;
 
     my $rados = $librados_connect->($scfg, $storeid);
-    my $df = $rados->mon_command({ prefix => 'df', format => 'json' });
+    my $df = $rados->mon_command({ prefix => 'df', detail => 'detail', format 
=> 'json'});
 
     my $pool = $scfg->{'data-pool'} // $scfg->{pool} // 'rbd';
 
@@ -701,10 +701,16 @@ sub status {
        return;
     }
 
-    # max_avail -> max available space for data w/o replication in the pool
-    # stored -> amount of user data w/o replication in the pool
+    # max_avail -> max available space for data with replication factored out
+    # avail_raw -> max available space for data before factoring out 
replication
+    # bytes_used -> actual used space before factoring out replication
+    # Note: the values with replication factored out are more interesting from 
a user perspective,
+    # so need to calculate actual usage with replication factored out.
+
+    my $replication = ($d->{stats}->{avail_raw} / $d->{stats}->{max_avail});
+
     my $free = $d->{stats}->{max_avail};
-    my $used = $d->{stats}->{stored};
+    my $used = $d->{stats}->{bytes_used} / $replication;
     my $total = $used + $free;
     my $active = 1;
 
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to