[pbs-devel] [PATCH proxmox-backup v6 16/21] GC: s3: track if a chunk marker file is missing since a bad chunk

Christian Ebner c.ebner at proxmox.com
Fri Nov 14 14:18:56 CET 2025


For bad chunks the marker file must never be created, as otherwise it
cannot be re-inserted by chunk upload.

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

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 9c0ce9859..a726b152b 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -1327,11 +1327,14 @@ impl DataStore {
                 // touch any corresponding .bad files to keep them around, meaning if a chunk is
                 // rewritten correctly they will be removed automatically, as well as if no index
                 // file requires the chunk anymore (won't get to this loop then)
+                let mut is_bad = false;
                 for i in 0..=9 {
                     let bad_ext = format!("{i}.bad");
                     let mut bad_path = chunk_path.clone();
                     bad_path.set_extension(bad_ext);
-                    self.inner.chunk_store.cond_touch_path(&bad_path, false)?;
+                    if self.inner.chunk_store.cond_touch_path(&bad_path, false)? {
+                        is_bad = true;
+                    }
                 }
 
                 if let Some(ref _s3_client) = s3_client {
@@ -1341,7 +1344,7 @@ impl DataStore {
                         .inner
                         .chunk_store
                         .lock_chunk(digest, CHUNK_LOCK_TIMEOUT)?;
-                    if !self.inner.chunk_store.cond_touch_chunk(digest, false)? {
+                    if !self.inner.chunk_store.cond_touch_chunk(digest, false)? && !is_bad {
                         // Insert empty file as marker to tell GC phase2 that this is
                         // a chunk still in-use, so to keep in the S3 object store.
                         std::fs::File::options()
-- 
2.47.3





More information about the pbs-devel mailing list