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: [pbs-devel] [PATCH proxmox-backup v2 4/4] datastore: refactor common delete list logic into closure
Date: Mon, 24 Nov 2025 10:40:18 +0100	[thread overview]
Message-ID: <20251124094018.224661-5-c.ebner@proxmox.com> (raw)
In-Reply-To: <20251124094018.224661-1-c.ebner@proxmox.com>

Reduce code duplication by defining a dedicated closure to update
the delete list age and push file lock guarded chunk object keys to
it.

No functional changes intended.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
Changes since version 1:
- not present

 pbs-datastore/src/datastore.rs | 36 +++++++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index d88785c6d..077b199e6 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -1691,6 +1691,19 @@ impl DataStore {
                 delete_list.clear();
                 Ok(())
             };
+
+            let add_to_delete_list =
+                |delete_list: &mut Vec<(S3ObjectKey, BackupLockGuard)>,
+                 delete_list_age: &mut i64,
+                 key: S3ObjectKey,
+                 _chunk_guard: BackupLockGuard| {
+                    // set age based on first insertion
+                    if delete_list.is_empty() {
+                        *delete_list_age = epoch_i64();
+                    }
+                    delete_list.push((key, _chunk_guard));
+                };
+
             loop {
                 for content in list_bucket_result.contents {
                     let (chunk_path, digest, bad) =
@@ -1745,12 +1758,12 @@ impl DataStore {
                                             std::fs::remove_file(chunk_path)?;
                                         }
                                     }
-
-                                    // set age based on first insertion
-                                    if delete_list.is_empty() {
-                                        delete_list_age = epoch_i64();
-                                    }
-                                    delete_list.push((content.key, _chunk_guard));
+                                    add_to_delete_list(
+                                        &mut delete_list,
+                                        &mut delete_list_age,
+                                        content.key,
+                                        _chunk_guard,
+                                    );
                                     Ok(())
                                 },
                             )?;
@@ -1758,11 +1771,12 @@ impl DataStore {
                     } else {
                         gc_status.removed_chunks += 1;
                         gc_status.removed_bytes += content.size;
-                        // set age based on first insertion
-                        if delete_list.is_empty() {
-                            delete_list_age = epoch_i64();
-                        }
-                        delete_list.push((content.key, _chunk_guard));
+                        add_to_delete_list(
+                            &mut delete_list,
+                            &mut delete_list_age,
+                            content.key,
+                            _chunk_guard,
+                        );
                     }
 
                     chunk_count += 1;
-- 
2.47.3



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


  parent reply	other threads:[~2025-11-24  9:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-24  9:40 [pbs-devel] [PATCH proxmox-backup v2 0/4] fix local marker cleanup for unreferenced, s3 only chunks Christian Ebner
2025-11-24  9:40 ` [pbs-devel] [PATCH proxmox-backup v2 1/4] GC: s3: " Christian Ebner
2025-11-24  9:40 ` [pbs-devel] [PATCH proxmox-backup v2 2/4] chunk store: fix and expand the clear_chunk_expected_mark() docstring Christian Ebner
2025-11-24  9:40 ` [pbs-devel] [PATCH proxmox-backup v2 3/4] chunk store: clarify chunk marker helper creates marker if missing Christian Ebner
2025-11-24  9:40 ` Christian Ebner [this message]
2025-11-24 12:23 ` [pbs-devel] applied: [PATCH proxmox-backup v2 0/4] fix local marker cleanup for unreferenced, s3 only chunks Thomas Lamprecht
2025-11-24 12:51   ` 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=20251124094018.224661-5-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