all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Cc: w.bumiller@proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] garbage-collect: switch to tokio Mutex
Date: Mon, 29 Sep 2025 11:32:02 +0200	[thread overview]
Message-ID: <20250929093228.205510-1-f.gruenbichler@proxmox.com> (raw)

this Mutex is held for the duration of the whole garbage collection run, which
now includes async calls into S3 code. this is not a highly contested lock, so
switching to the more expensive tokio variant shouldn't cause noticeable
overhead, and fix potential deadlock problems that could occur because of
holding the lock guard across await points.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
also found while going through std::sync::Mutex usage with S3

 pbs-datastore/src/datastore.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 7cf020fc0..68043e7a5 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -136,7 +136,7 @@ pub fn ensure_datastore_is_mounted(config: &DataStoreConfig) -> Result<(), Error
 /// management interface for backup.
 pub struct DataStoreImpl {
     chunk_store: Arc<ChunkStore>,
-    gc_mutex: Mutex<()>,
+    gc_mutex: tokio::sync::Mutex<()>,
     last_gc_status: Mutex<GarbageCollectionStatus>,
     verify_new: bool,
     chunk_order: ChunkOrder,
@@ -152,7 +152,7 @@ impl DataStoreImpl {
     pub(crate) unsafe fn new_test() -> Arc<Self> {
         Arc::new(Self {
             chunk_store: Arc::new(unsafe { ChunkStore::panic_store() }),
-            gc_mutex: Mutex::new(()),
+            gc_mutex: tokio::sync::Mutex::new(()),
             last_gc_status: Mutex::new(GarbageCollectionStatus::default()),
             verify_new: false,
             chunk_order: Default::default(),
@@ -513,7 +513,7 @@ impl DataStore {
 
         Ok(DataStoreImpl {
             chunk_store,
-            gc_mutex: Mutex::new(()),
+            gc_mutex: tokio::sync::Mutex::new(()),
             last_gc_status: Mutex::new(gc_status),
             verify_new: config.verify_new.unwrap_or(false),
             chunk_order: tuning.chunk_order.unwrap_or_default(),
-- 
2.47.3



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

             reply	other threads:[~2025-09-29  9:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-29  9:32 Fabian Grünbichler [this message]
2025-09-29 16:07 ` Christian Ebner
2025-09-30  6:24   ` Fabian Grünbichler
2025-10-01 11:20 ` [pbs-devel] superseded: " Fabian Grünbichler

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=20250929093228.205510-1-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=w.bumiller@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal