public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 storage 2/2] rbd plugin: status: use actual storage usage as basis for calculation
Date: Wed, 14 May 2025 11:36:58 +0200	[thread overview]
Message-ID: <20250514093658.21308-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250514093658.21308-1-f.ebner@proxmox.com>

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.ebner@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	other threads:[~2025-05-14  9:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-14  9:36 [pve-devel] [PATCH v2 storage 1/2] rbd plugin: status: drop outdated fallback Fiona Ebner
2025-05-14  9:36 ` Fiona Ebner [this message]
2025-05-22 14:32   ` [pve-devel] [PATCH v2 storage 2/2] rbd plugin: status: use actual storage usage as basis for calculation Fiona Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250514093658.21308-2-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal