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 0ABB01FF183 for ; Wed, 5 Nov 2025 16:51:28 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EEA8F226C; Wed, 5 Nov 2025 16:52:07 +0100 (CET) From: Nicolas Frey To: pbs-devel@lists.proxmox.com Date: Wed, 5 Nov 2025 16:51:27 +0100 Message-ID: <20251105155129.517430-4-n.frey@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251105155129.517430-1-n.frey@proxmox.com> References: <20251105155129.517430-1-n.frey@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.102 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 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pbs-devel] [PATCH proxmox-backup 2/4] api: verify: use worker-threads to determine the number of threads to use 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" Signed-off-by: Nicolas Frey --- src/api2/admin/datastore.rs | 13 +++++++++++-- src/api2/backup/environment.rs | 2 +- src/backup/verify.rs | 5 ++++- src/server/verify_job.rs | 3 ++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index d192ee39..69a09081 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -677,6 +677,14 @@ pub async fn status( schema: NS_MAX_DEPTH_SCHEMA, optional: true, }, + "worker-threads": { + description: "Set the number of worker threads to use for the job", + type: Integer, + optional: true, + minimum: 1, + maximum: 32, + default: 1, + }, }, }, returns: { @@ -690,7 +698,7 @@ pub async fn status( )] /// Verify backups. /// -/// This function can verify a single backup snapshot, all backup from a backup group, +/// This function can verify a single backup snapshot, all backups from a backup group, /// or all backups in the datastore. #[allow(clippy::too_many_arguments)] pub fn verify( @@ -702,6 +710,7 @@ pub fn verify( ignore_verified: Option, outdated_after: Option, max_depth: Option, + worker_threads: Option, rpcenv: &mut dyn RpcEnvironment, ) -> Result { let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; @@ -781,7 +790,7 @@ pub fn verify( auth_id.to_string(), to_stdout, move |worker| { - let verify_worker = VerifyWorker::new(worker.clone(), datastore)?; + let verify_worker = VerifyWorker::new(worker.clone(), datastore, worker_threads)?; let failed_dirs = if let Some(backup_dir) = backup_dir { let mut res = Vec::new(); if !verify_worker.verify_backup_dir( diff --git a/src/api2/backup/environment.rs b/src/api2/backup/environment.rs index 0e8eab1b..5e6a73b9 100644 --- a/src/api2/backup/environment.rs +++ b/src/api2/backup/environment.rs @@ -812,7 +812,7 @@ impl BackupEnvironment { move |worker| { worker.log_message("Automatically verifying newly added snapshot"); - let verify_worker = VerifyWorker::new(worker.clone(), datastore)?; + let verify_worker = VerifyWorker::new(worker.clone(), datastore, None)?; if !verify_worker.verify_backup_dir_with_lock( &backup_dir, worker.upid().clone(), diff --git a/src/backup/verify.rs b/src/backup/verify.rs index 7f91f38c..e11dba8e 100644 --- a/src/backup/verify.rs +++ b/src/backup/verify.rs @@ -32,6 +32,7 @@ pub struct VerifyWorker { verified_chunks: Arc>>, corrupt_chunks: Arc>>, backend: DatastoreBackend, + worker_threads: Option, } impl VerifyWorker { @@ -39,6 +40,7 @@ impl VerifyWorker { pub fn new( worker: Arc, datastore: Arc, + worker_threads: Option, ) -> Result { let backend = datastore.backend()?; Ok(Self { @@ -49,6 +51,7 @@ impl VerifyWorker { // start with 64 chunks since we assume there are few corrupt ones corrupt_chunks: Arc::new(Mutex::new(HashSet::with_capacity(64))), backend, + worker_threads, }) } @@ -220,7 +223,7 @@ impl VerifyWorker { .datastore .get_chunks_in_order(&*index, skip_chunk, check_abort)?; - let reader_pool = ParallelHandler::new("read chunks", 4, { + let reader_pool = ParallelHandler::new("read chunks", self.worker_threads.unwrap_or(4), { let decoder_pool = decoder_pool.channel(); let datastore = Arc::clone(&self.datastore); let corrupt_chunks = Arc::clone(&self.corrupt_chunks); diff --git a/src/server/verify_job.rs b/src/server/verify_job.rs index c8792174..9d790b07 100644 --- a/src/server/verify_job.rs +++ b/src/server/verify_job.rs @@ -41,7 +41,8 @@ pub fn do_verification_job( None => Default::default(), }; - let verify_worker = VerifyWorker::new(worker.clone(), datastore)?; + let verify_worker = + VerifyWorker::new(worker.clone(), datastore, verification_job.worker_threads)?; let result = verify_worker.verify_all_backups( worker.upid(), ns, -- 2.47.3 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel