From 7b2d3a5fe9b8765ebfc7fc6ed74ed46e5252334a Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 15 Apr 2021 12:36:50 +0200 Subject: [PATCH] backup verify: unify check if chunk can be skipped This also re-checks the corrupt chunk list before actually loading a chunk. Signed-off-by: Thomas Lamprecht --- src/backup/verify.rs | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/backup/verify.rs b/src/backup/verify.rs index 1192821e..95a45f63 100644 --- a/src/backup/verify.rs +++ b/src/backup/verify.rs @@ -166,6 +166,19 @@ fn verify_index_chunks( } ); + let skip_chunk = |digest: &[u8; 32]| -> bool { + if verify_worker.verified_chunks.lock().unwrap().contains(digest) { + true + } else if verify_worker.corrupt_chunks.lock().unwrap().contains(digest) { + let digest_str = proxmox::tools::digest_to_hex(digest); + task_log!(verify_worker.worker, "chunk {} was marked as corrupt", digest_str); + errors.fetch_add(1, Ordering::SeqCst); + true + } else { + false + } + }; + let index_count = index.index_count(); let mut chunk_list = Vec::with_capacity(index_count); @@ -177,15 +190,8 @@ fn verify_index_chunks( let info = index.chunk_info(pos).unwrap(); - if verify_worker.verified_chunks.lock().unwrap().contains(&info.digest) { - continue; // already verified - } - - if verify_worker.corrupt_chunks.lock().unwrap().contains(&info.digest) { - let digest_str = proxmox::tools::digest_to_hex(&info.digest); - task_log!(verify_worker.worker, "chunk {} was marked as corrupt", digest_str); - errors.fetch_add(1, Ordering::SeqCst); - continue; + if skip_chunk(&info.digest) { + continue; // already verified or marked corrupt } match verify_worker.datastore.stat_chunk(&info.digest) { @@ -215,9 +221,8 @@ fn verify_index_chunks( let info = index.chunk_info(pos).unwrap(); // we must always recheck this here, the parallel worker below alter it! - // Else we miss skipping repeated chunks from the same index, and re-verify them all - if verify_worker.verified_chunks.lock().unwrap().contains(&info.digest) { - continue; // already verified + if skip_chunk(&info.digest) { + continue; // already verified or marked corrupt } match verify_worker.datastore.load_chunk(&info.digest) {