public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v2 1/3] fix #4077: Estimated Full metric on ext4 file systems
Date: Fri,  3 Jun 2022 13:21:18 +0200	[thread overview]
Message-ID: <20220603112120.429696-1-d.tschlatscher@proxmox.com> (raw)

The rrd data now includes tracking the total disk usage for the unpri-
vileged backup user. The calculation for the estimated_time_full was
adapted to use the total for the unpriviliged user.

The calculation for "unpriv_total" is as follows:
= (total blocks - (free blocks in fs - avail for unpriv user)) * bsize

Note: Statistics for 'unpriv_total' were not tracked in the rrdb
before. Existing datastores will therefore show a somewhat incorrect
value for 'estimated_full', at least until it is populated with enough
new values.

Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
---
Changes from v1:
* 1/3 Should now use the correct values for the calculation of the
  estimated time full
* 1/3 Started tracking the unprivileged total in the backend disk
  status types and in the rrdb
* 2/3 Revised the usage of "total" in the GUI to display the total
  left for unprivileged users
* 3/3 Fixed displaying "Never" when a datastore was full. Now displays
  "Full" instead

 pbs-api-types/src/lib.rs        | 2 ++
 src/api2/status.rs              | 3 ++-
 src/bin/proxmox-backup-proxy.rs | 2 ++
 src/tools/disks/mod.rs          | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs
index d9c8cee1..629a6812 100644
--- a/pbs-api-types/src/lib.rs
+++ b/pbs-api-types/src/lib.rs
@@ -345,6 +345,8 @@ pub struct StorageStatus {
     pub used: u64,
     /// Available space (bytes).
     pub avail: u64,
+    /// Total space for the unpriviliged user (bytes)
+    pub unpriv_total: u64,
 }
 
 pub const PASSWORD_HINT_SCHEMA: Schema = StringSchema::new("Password hint.")
diff --git a/src/api2/status.rs b/src/api2/status.rs
index 55c811a5..3575932b 100644
--- a/src/api2/status.rs
+++ b/src/api2/status.rs
@@ -84,7 +84,8 @@ pub fn datastore_status(
         let get_rrd =
             |what: &str| extract_rrd_data(&rrd_dir, what, RRDTimeFrame::Month, RRDMode::Average);
 
-        let total_res = get_rrd("total")?;
+        // Use the space for the unpriviliged user, as e.g. ext4 reserves 5% of disks for root only
+        let total_res = get_rrd("unpriv_total")?;
         let used_res = get_rrd("used")?;
 
         if let (Some((start, reso, total_list)), Some((_, _, used_list))) = (total_res, used_res) {
diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index aadd7c93..d25aa08f 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -1129,6 +1129,8 @@ fn gather_disk_stats(disk_manager: Arc<DiskManage>, path: &Path, rrd_prefix: &st
             rrd_update_gauge(&rrd_key, status.total as f64);
             let rrd_key = format!("{}/used", rrd_prefix);
             rrd_update_gauge(&rrd_key, status.used as f64);
+            let rrd_key = format!("{}/unpriv_total", rrd_prefix);
+            rrd_update_gauge(&rrd_key, status.unpriv_total as f64);
         }
         Err(err) => {
             eprintln!("read disk_usage on {:?} failed - {}", path, err);
diff --git a/src/tools/disks/mod.rs b/src/tools/disks/mod.rs
index 568dccbf..08f516df 100644
--- a/src/tools/disks/mod.rs
+++ b/src/tools/disks/mod.rs
@@ -543,6 +543,7 @@ pub fn disk_usage(path: &std::path::Path) -> Result<StorageStatus, Error> {
         total: stat.f_blocks * bsize,
         used: (stat.f_blocks - stat.f_bfree) * bsize,
         avail: stat.f_bavail * bsize,
+        unpriv_total: (stat.f_blocks - (stat.f_bfree - stat.f_bavail)) * bsize,
     })
 }
 
-- 
2.30.2





             reply	other threads:[~2022-06-03 11:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-03 11:21 Daniel Tschlatscher [this message]
2022-06-03 11:21 ` [pbs-devel] [PATCH proxmox-backup v2 2/3] expose the unpriviliged total in the api and use it in the GUI Daniel Tschlatscher
2022-06-03 11:21 ` [pbs-devel] [PATCH proxmox-backup v2 3/3] gui: change reporting of the estimated_time_full to "Full" if no space Daniel Tschlatscher

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=20220603112120.429696-1-d.tschlatscher@proxmox.com \
    --to=d.tschlatscher@proxmox.com \
    --cc=pbs-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