From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 2F6101FF15E for ; Mon, 29 Sep 2025 10:04:27 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 57204BA2B; Mon, 29 Sep 2025 10:04:32 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Mon, 29 Sep 2025 10:04:07 +0200 Message-ID: <20250929080407.124362-4-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250929080407.124362-1-c.ebner@proxmox.com> References: <20250929080407.124362-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1759133049218 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.042 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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 v3 3/3] api: backup: avoid holding mutex and inline backup cleanup method 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" The method to cleanup backups due to failure (or because a benchmark) currently acquires a mutex guard before removing the backup directory. Since the S3 backend however needs to execute code in async context, it is not deadlock save to hold the guard. However, the guard was only acquired to set the state to finished, which is however not necessary since the request handling future is already executed to completion, so this has no further effect. Therefore, drop the mutex locking altoghether and inline the now trivial simple function call to the respective callsides. Signed-off-by: Christian Ebner --- changes since version 2: - not present in previous version src/api2/backup/environment.rs | 14 -------------- src/api2/backup/mod.rs | 24 +++++++++++++++++++++--- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/api2/backup/environment.rs b/src/api2/backup/environment.rs index de6ce3c89..ace305d7e 100644 --- a/src/api2/backup/environment.rs +++ b/src/api2/backup/environment.rs @@ -833,20 +833,6 @@ impl BackupEnvironment { state.finished == BackupState::Finished } - /// Remove complete backup - pub fn remove_backup(&self) -> Result<(), Error> { - let mut state = self.state.lock().unwrap(); - state.finished = BackupState::Finished; - - self.datastore.remove_backup_dir( - self.backup_dir.backup_ns(), - self.backup_dir.as_ref(), - true, - )?; - - Ok(()) - } - fn s3_upload_index(&self, s3_client: &S3Client, name: &str) -> Result<(), Error> { let object_key = pbs_datastore::s3::object_key_from_path(&self.backup_dir.relative_path(), name) diff --git a/src/api2/backup/mod.rs b/src/api2/backup/mod.rs index ae61ff697..8a076a2b0 100644 --- a/src/api2/backup/mod.rs +++ b/src/api2/backup/mod.rs @@ -282,7 +282,13 @@ fn upgrade_to_backup_protocol( }; if benchmark { env.log("benchmark finished successfully"); - proxmox_async::runtime::block_in_place(|| env.remove_backup())?; + proxmox_async::runtime::block_in_place(|| { + env.datastore.remove_backup_dir( + env.backup_dir.backup_ns(), + env.backup_dir.as_ref(), + true, + ) + })?; return Ok(()); } @@ -310,13 +316,25 @@ fn upgrade_to_backup_protocol( (Ok(_), Err(err)) => { env.log(format!("backup ended and finish failed: {}", err)); env.log("removing unfinished backup"); - proxmox_async::runtime::block_in_place(|| env.remove_backup())?; + proxmox_async::runtime::block_in_place(|| { + env.datastore.remove_backup_dir( + env.backup_dir.backup_ns(), + env.backup_dir.as_ref(), + true, + ) + })?; Err(err) } (Err(err), Err(_)) => { env.log(format!("backup failed: {}", err)); env.log("removing failed backup"); - proxmox_async::runtime::block_in_place(|| env.remove_backup())?; + proxmox_async::runtime::block_in_place(|| { + env.datastore.remove_backup_dir( + env.backup_dir.backup_ns(), + env.backup_dir.as_ref(), + true, + ) + })?; Err(err) } } -- 2.47.3 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel