[pbs-devel] [RFC v2 proxmox-backup 09/21] datastore: refactor recursive namespace removal

Christian Ebner c.ebner at proxmox.com
Thu May 8 15:05:43 CEST 2025


Split off the recursive destruction logic for the namespace folder
hierarchy into its own helper function.
This will allow to separate the marking of namespaces as trashed
from the actually destruction an namespace cleanup by garbage
collection or when bypassing the trash.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
 pbs-datastore/src/datastore.rs | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index aee69768f..023a6a12e 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -628,6 +628,18 @@ impl DataStore {
             log::info!("pruning empty namespace recursively below {store}:/{ns}");
         }
 
+        removed_all_requested =
+            removed_all_requested && self.destroy_namespace_recursive(ns, delete_groups)?;
+
+        Ok((removed_all_requested, stats))
+    }
+
+    fn destroy_namespace_recursive(
+        self: &Arc<Self>,
+        ns: &BackupNamespace,
+        delete_groups: bool,
+    ) -> Result<bool, Error> {
+        let mut removed_all_requested = true;
         // now try to delete the actual namespaces, bottom up so that we can use safe rmdir that
         // will choke if a new backup/group appeared in the meantime (but not on an new empty NS)
         let mut children = self
@@ -662,7 +674,7 @@ impl DataStore {
             }
         }
 
-        Ok((removed_all_requested, stats))
+        Ok(removed_all_requested)
     }
 
     /// Remove a complete backup group including all snapshots.
-- 
2.39.5





More information about the pbs-devel mailing list