public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup v2 1/3] fix #4077: Estimated Full metric on ext4 file systems
@ 2022-06-03 11:21 Daniel Tschlatscher
  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
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Tschlatscher @ 2022-06-03 11:21 UTC (permalink / raw)
  To: pbs-devel

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





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-03 11:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-03 11:21 [pbs-devel] [PATCH proxmox-backup v2 1/3] fix #4077: Estimated Full metric on ext4 file systems Daniel Tschlatscher
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

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