From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 676041FF18A for ; Mon, 26 May 2025 16:14:51 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 45EC133FBA; Mon, 26 May 2025 16:15:01 +0200 (CEST) From: Hannes Laimer To: pbs-devel@lists.proxmox.com Date: Mon, 26 May 2025 16:14:44 +0200 Message-Id: <20250526141445.228717-12-h.laimer@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250526141445.228717-1-h.laimer@proxmox.com> References: <20250526141445.228717-1-h.laimer@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup v2 11/12] datastore: move `fn gc_running` out of DataStoreImpl X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Like this we can avoid having to get a `CanWrite` datastore reference just to check if we can obtain the gc lock, as lookup references (neither `CanRead` nor `CanWrite`) will not come from the cache that would contain the relevant locks. Signed-off-by: Hannes Laimer --- pbs-datastore/src/datastore.rs | 10 ++++++---- pbs-datastore/src/lib.rs | 3 ++- src/bin/proxmox-backup-proxy.rs | 15 ++------------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs index cb2d2172..20ad73c5 100644 --- a/pbs-datastore/src/datastore.rs +++ b/pbs-datastore/src/datastore.rs @@ -118,6 +118,12 @@ pub fn ensure_datastore_is_mounted(config: &DataStoreConfig) -> Result<(), Error } } +pub fn is_garbage_collection_running(name: &str) -> bool { + let datastore_cache = DATASTORE_MAP_WRITE.lock().unwrap(); + let cache_entry = datastore_cache.get(name); + cache_entry.is_some_and(|s| s.gc_mutex.try_lock().is_err()) +} + /// Datastore Management /// /// A Datastore can store severals backups, and provides the @@ -752,10 +758,6 @@ impl DataStore { self.inner.last_gc_status.lock().unwrap().clone() } - pub fn garbage_collection_running(&self) -> bool { - self.inner.gc_mutex.try_lock().is_err() - } - pub fn try_shared_chunk_store_lock(&self) -> Result { self.inner.chunk_store.try_shared_lock() } diff --git a/pbs-datastore/src/lib.rs b/pbs-datastore/src/lib.rs index 5014b6c0..857ee78e 100644 --- a/pbs-datastore/src/lib.rs +++ b/pbs-datastore/src/lib.rs @@ -202,7 +202,8 @@ pub use store_progress::StoreProgress; mod datastore; pub use datastore::{ - check_backup_owner, ensure_datastore_is_mounted, get_datastore_mount_status, DataStore, + check_backup_owner, ensure_datastore_is_mounted, get_datastore_mount_status, + is_garbage_collection_running, DataStore, }; mod hierarchy; diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index bda2f17b..643a2dbd 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -482,19 +482,8 @@ async fn schedule_datastore_garbage_collection() { } }; - { - // limit datastore scope due to Op::Lookup - let datastore = match DataStore::lookup_datastore(&store, Some(Operation::Lookup)) { - Ok(datastore) => datastore, - Err(err) => { - eprintln!("lookup_datastore failed - {err}"); - continue; - } - }; - - if datastore.garbage_collection_running() { - continue; - } + if is_garbage_collection_running(&store) { + continue; } let worker_type = "garbage_collection"; -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel