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 47013706D8 for ; Fri, 3 Jun 2022 13:22:58 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4535B6CBD for ; Fri, 3 Jun 2022 13:22:58 +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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id D6C256CB2 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 B02F343128 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:19 +0200 Message-Id: <20220603112120.429696-2-d.tschlatscher@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220603112120.429696-1-d.tschlatscher@proxmox.com> References: <20220603112120.429696-1-d.tschlatscher@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.123 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. [status.rs, datastore.rs, data.total, status.total] Subject: [pbs-devel] [PATCH proxmox-backup v2 2/3] expose the unpriviliged total in the api and use it in the GUI 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:58 -0000 Until now, the total size for a datastore was reported as the total blocks on the filesystem. On ext4 filesystems this number will not match the observed behaviour though when some amount of blocks are reserved, as the proxmox-backup-proxy uses the unpriviliged 'backup' user. Therefore backuping new data would fail, even though the GUI still displays that X% of the datastore is free. I think using the unpriviliged total makes more sense as it communicates to the user how much they can actually still store on the datastore, rather than the full total of which some part might not be usable. This will also not lead to issues in the GUI when the reserved space is written to, because the value reported by statfs will automatically increase accordingly. I.e. when the unprivliged space is full and a 500MB file is written by the root user, both the 'unpriv_total' and 'available' fields will increase by this amount, keeping the usage at 100%. Note: While the value for total is no longer used in the GUI, I did not overwrite it in the backend as it could break existing code which might depend on the API returning the total byte size for the underlying disk. Signed-off-by: Daniel Tschlatscher --- pbs-api-types/src/datastore.rs | 5 +++++ src/api2/admin/datastore.rs | 3 +++ src/api2/status.rs | 1 + www/dashboard/DataStoreStatistics.js | 6 +++--- www/datastore/DataStoreListSummary.js | 4 ++-- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index bb20e149..fcf21ff1 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -1250,6 +1250,8 @@ impl Default for GarbageCollectionStatus { pub struct DataStoreStatus { /// Total space (bytes). pub total: u64, + /// Total unreserved space (bytes) + pub unpriv_total: u64, /// Used space (bytes). pub used: u64, /// Available space (bytes). @@ -1284,6 +1286,8 @@ pub struct DataStoreStatusListItem { pub store: String, /// The Size of the underlying storage in bytes. (-1 on error) pub total: i64, + /// The Size of the total blocks available to the unpriviliged user (-1 on error) + pub unpriv_total: i64, /// The used bytes of the underlying storage. (-1 on error) pub used: i64, /// The available bytes of the underlying storage. (-1 on error) @@ -1316,6 +1320,7 @@ impl DataStoreStatusListItem { DataStoreStatusListItem { store: store.to_owned(), total: -1, + unpriv_total: -1, used: -1, avail: -1, history: None, diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 44208a4c..52488732 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -678,6 +678,7 @@ pub fn status( let storage = crate::tools::disks::disk_usage(&datastore.base_path())?; DataStoreStatus { total: storage.total, + unpriv_total: storage.unpriv_total, used: storage.used, avail: storage.avail, gc_status, @@ -686,6 +687,7 @@ pub fn status( } else { DataStoreStatus { total: 0, + unpriv_total: 0, used: 0, avail: 0, gc_status, @@ -1768,6 +1770,7 @@ pub fn get_rrd_stats( let mut rrd_fields = vec![ "total", + "unpriv_total", "used", "read_ios", "read_bytes", diff --git a/src/api2/status.rs b/src/api2/status.rs index 3575932b..d9ccc97a 100644 --- a/src/api2/status.rs +++ b/src/api2/status.rs @@ -69,6 +69,7 @@ pub fn datastore_status( let mut entry = DataStoreStatusListItem { store: store.clone(), total: status.total as i64, + unpriv_total: status.unpriv_total as i64, used: status.used as i64, avail: status.avail as i64, history: None, diff --git a/www/dashboard/DataStoreStatistics.js b/www/dashboard/DataStoreStatistics.js index 38f7a2fe..8dbd1caf 100644 --- a/www/dashboard/DataStoreStatistics.js +++ b/www/dashboard/DataStoreStatistics.js @@ -3,7 +3,7 @@ Ext.define('pbs-datastore-statistics', { fields: [ 'store', - 'total', + 'unpriv_total', 'used', 'avail', 'estimated-full-date', @@ -27,7 +27,7 @@ Ext.define('pbs-datastore-statistics', { name: 'usage', calculate: function(data) { let used = data.used || 0; - let total = data.total || 0; + let total = data["unpriv-total"] || 0; if (total > 0) { return used/total; } else { @@ -78,7 +78,7 @@ Ext.define('PBS.DatastoreStatistics', { }, { text: gettext('Size'), - dataIndex: 'total', + dataIndex: 'unpriv-total', sortable: true, width: 90, renderer: v => v === undefined || v < 0 ? '-' : Proxmox.Utils.format_size(v, true), diff --git a/www/datastore/DataStoreListSummary.js b/www/datastore/DataStoreListSummary.js index c7b67d56..3714528e 100644 --- a/www/datastore/DataStoreListSummary.js +++ b/www/datastore/DataStoreListSummary.js @@ -52,10 +52,10 @@ Ext.define('PBS.datastore.DataStoreListSummary', { vm.set('maintenance', ''); } - let usage = statusData.used/statusData.total; + let usage = statusData.used/statusData["unpriv-total"]; let usagetext = Ext.String.format(gettext('{0} of {1}'), Proxmox.Utils.format_size(statusData.used, true), - Proxmox.Utils.format_size(statusData.total, true), + Proxmox.Utils.format_size(statusData["unpriv-total"], true), ); let usagePanel = me.lookup('usage'); -- 2.30.2