From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id BBAA51FF0B3 for ; Wed, 14 Oct 2026 16:44:06 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id F38452147C; Wed, 14 Oct 2026 16:44:04 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox v2 02/14] pbs-api-types: add types for fine-grained datastore usage statistics Date: Wed, 14 Oct 2026 16:43:45 +0200 Message-ID: <20261014144357.771051-3-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261014144357.771051-1-c.ebner@proxmox.com> References: <20261014144357.771051-1-c.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1791989041158 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.534 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: GMCAFX3GW5ANFDM4NPCXPOHYASX42VHI X-Message-ID-Hash: GMCAFX3GW5ANFDM4NPCXPOHYASX42VHI X-MailFrom: c.ebner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Defines the api types for chunk data usage statistics to be used on datastore, namespace, group and snapshot hierarchy levels, as well as the list type to fetch these per-level usage statistics via the api. Signed-off-by: Christian Ebner --- pbs-api-types/src/datastore.rs | 97 ++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index 93ccaf07..05baa1b3 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -1582,6 +1582,103 @@ pub struct NamespaceListItem { pub comment: Option, } +#[api( + properties: { + "raw-size": { + type: Integer, + }, + "logical-size": { + type: Integer, + }, + "unique-raw-size": { + type: Integer, + }, + "reference-count": { + type: Integer, + }, + "unique-count": { + type: Integer, + }, + "dedup-count": { + type: Integer, + }, + } +)] +#[derive(Default, Serialize, Deserialize, Clone, PartialEq)] +#[serde(rename_all = "kebab-case")] +/// Usage statistics for datastores, namespaces, groups and snapshots. +pub struct StoreUsageStatistics { + /// On disk size of all referenced chunks + pub raw_size: u64, + /// Logical size of all referenced chunks + pub logical_size: u64, + /// On disk size of all unique chunks + pub unique_raw_size: u64, + /// Count of all chunks being referenced + pub reference_count: u64, + /// Count of unique chunks being referenced + pub unique_count: u64, + /// Count of chunks with multiple references + pub dedup_count: u64, +} + +impl StoreUsageStatistics { + /// Account for storage usage by chunk + pub fn add(&mut self, raw: u64, logical: u64, unique: bool) { + self.raw_size += raw; + self.logical_size += logical; + self.reference_count += 1; + if unique { + self.unique_count += 1; + self.unique_raw_size += raw; + } else { + self.dedup_count += 1; + } + } +} + +#[api( + properties: { + "ns": { + type: BackupNamespace, + optional: true, + }, + "backup-type": { + type: BackupType, + optional: true, + }, + "backup-id": { + schema: BACKUP_ID_SCHEMA, + optional: true, + }, + "backup-time": { + schema: BACKUP_TIME_SCHEMA, + optional: true, + }, + "stats": { + type: StoreUsageStatistics + }, + }, +)] +#[derive(Serialize, Deserialize, Clone, PartialEq)] +#[serde(rename_all = "kebab-case")] +/// Basic information about a backup group. +pub struct StatisticsListItem { + #[serde(skip_serializing_if = "Option::is_none")] + pub ns: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(rename = "backup-type")] + pub ty: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(rename = "backup-id")] + pub id: Option, + #[serde(rename = "backup-time")] + #[serde(skip_serializing_if = "Option::is_none")] + pub time: Option, + #[serde(flatten)] + pub stats: StoreUsageStatistics, +} + #[api( properties: { "backup": { type: BackupDir }, -- 2.47.3