public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
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	[thread overview]
Message-ID: <20261014144357.771051-3-c.ebner@proxmox.com> (raw)
In-Reply-To: <20261014144357.771051-1-c.ebner@proxmox.com>

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 <c.ebner@proxmox.com>
---
 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<String>,
 }
 
+#[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<BackupNamespace>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    #[serde(rename = "backup-type")]
+    pub ty: Option<BackupType>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    #[serde(rename = "backup-id")]
+    pub id: Option<String>,
+    #[serde(rename = "backup-time")]
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub time: Option<i64>,
+    #[serde(flatten)]
+    pub stats: StoreUsageStatistics,
+}
+
 #[api(
     properties: {
         "backup": { type: BackupDir },
-- 
2.47.3





  parent reply	other threads:[~2026-10-14 14:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 14:43 [PATCH proxmox{,-backup} v2 00/14] fix #5799: gather datastore usage statistics on per-entity level Christian Ebner
2026-10-14 14:43 ` [PATCH proxmox v2 01/14] pbs-api-types: avoid reimplementation of is_false helper Christian Ebner
2026-10-14 14:43 ` Christian Ebner [this message]
2026-10-14 14:43 ` [PATCH proxmox v2 03/14] pbs-api-types: add schema for datastore usage statistics listing Christian Ebner
2026-10-14 14:43 ` [PATCH proxmox v2 04/14] pbs-api-types: add flag to control usage statistics collection Christian Ebner
2026-10-14 14:43 ` [PATCH proxmox-backup v2 05/14] chunk store: restrict chunk sweep helper method to module parent Christian Ebner
2026-10-14 14:43 ` [PATCH proxmox-backup v2 06/14] datastore: implement index map for compact chunk usage tracking Christian Ebner
2026-10-14 14:43 ` [PATCH proxmox-backup v2 07/14] datastore: implement chunk map for collecting chunk usage statistics Christian Ebner
2026-10-14 14:43 ` [PATCH proxmox-backup v2 08/14] datastore: cleanup persisted statistics during datastore destruction Christian Ebner
2026-10-14 14:43 ` [PATCH proxmox-backup v2 09/14] fix #5799: GC: track chunk digests and accumulate statistics Christian Ebner
2026-10-14 14:43 ` [PATCH proxmox-backup v2 10/14] api: config: allow modification of extended-usage-statistics flag Christian Ebner
2026-10-14 14:43 ` [PATCH proxmox-backup v2 11/14] ui: expose extended usage statistics flag in datastore options Christian Ebner
2026-10-14 14:43 ` [PATCH proxmox-backup v2 12/14] api: admin: add endpoint to fetch fine-grained datastore usage stats Christian Ebner
2026-10-14 14:43 ` [PATCH proxmox-backup v2 13/14] bin: manager: allow listing of extended usage statistics via cli Christian Ebner
2026-10-14 14:43 ` [PATCH proxmox-backup v2 14/14] ui: implement statistics tab for datastore panel Christian Ebner

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=20261014144357.771051-3-c.ebner@proxmox.com \
    --to=c.ebner@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