[pbs-devel] [PATCH proxmox-backup v3 23/23] chunk store: never fail when trying to remove missing chunk file

Christian Ebner c.ebner at proxmox.com
Wed Nov 5 13:22:33 CET 2025


Although this is an unexpected case, never fail if the chunk store
marker is not there during removal from cache in phase 2 of garbage
collection for datastores with s3 backend (that codepath needs no
further adaption). The chunk file might be missing for other reasons,
e.g. after manual intervention in offline maintenance mode.

On the other hand, phase 3 should fail on chunks which cannot be
removed from the cache in e.g. out-of-space or permission issue
cases.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
changes since version 2:
- not present in previous version

 pbs-datastore/src/chunk_store.rs | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/pbs-datastore/src/chunk_store.rs b/pbs-datastore/src/chunk_store.rs
index 234b5e8e7..58195aef6 100644
--- a/pbs-datastore/src/chunk_store.rs
+++ b/pbs-datastore/src/chunk_store.rs
@@ -436,7 +436,7 @@ impl ChunkStore {
                                                 Ok(stat) if stat.st_atime < min_atime => {
                                                     // still protected by per-chunk file lock
                                                     drop(lock);
-                                                    let _ = cache.remove(&digest);
+                                                    cache.remove(&digest)?;
                                                     return Ok(());
                                                 }
                                                 _ => return Ok(()),
@@ -721,7 +721,12 @@ impl ChunkStore {
     pub(crate) fn remove_chunk(&self, digest: &[u8; 32]) -> Result<(), Error> {
         let (chunk_path, _digest_str) = self.chunk_path(digest);
         let _lock = self.mutex.lock();
-        std::fs::remove_file(chunk_path).map_err(Error::from)
+        if let Err(err) = std::fs::remove_file(chunk_path) {
+            if err.kind() != std::io::ErrorKind::NotFound {
+                return Err(err.into());
+            }
+        }
+        Ok(())
     }
 
     pub fn relative_path(&self, path: &Path) -> PathBuf {
-- 
2.47.3





More information about the pbs-devel mailing list