From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id E0DF47070C for ; Fri, 3 Jun 2022 13:22:57 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DEED06CBB for ; Fri, 3 Jun 2022 13:22:57 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 8FD6B6CA0 for ; Fri, 3 Jun 2022 13:22:56 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 693F843A02 for ; Fri, 3 Jun 2022 13:22:56 +0200 (CEST) From: Daniel Tschlatscher To: pbs-devel@lists.proxmox.com Date: Fri, 3 Jun 2022 13:21:18 +0200 Message-Id: <20220603112120.429696-1-d.tschlatscher@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.126 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox-backup-proxy.rs, lib.rs, status.total, status.rs, mod.rs] Subject: [pbs-devel] [PATCH proxmox-backup v2 1/3] fix #4077: Estimated Full metric on ext4 file systems X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Jun 2022 11:22:57 -0000 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 --- 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, 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 { 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