verify: keep also track of corrupt chunks
so that we do not have to verify a corrupt one multiple times Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
f66f537da9
commit
d8594d87f1
|
@ -476,7 +476,8 @@ pub fn verify(
|
||||||
{
|
{
|
||||||
let success = if let Some(backup_dir) = backup_dir {
|
let success = if let Some(backup_dir) = backup_dir {
|
||||||
let mut verified_chunks = HashSet::with_capacity(1024*16);
|
let mut verified_chunks = HashSet::with_capacity(1024*16);
|
||||||
verify_backup_dir(&datastore, &backup_dir, &mut verified_chunks, &worker)?
|
let mut corrupt_chunks = HashSet::with_capacity(64);
|
||||||
|
verify_backup_dir(&datastore, &backup_dir, &mut verified_chunks, &mut corrupt_chunks, &worker)?
|
||||||
} else if let Some(backup_group) = backup_group {
|
} else if let Some(backup_group) = backup_group {
|
||||||
verify_backup_group(&datastore, &backup_group, &worker)?
|
verify_backup_group(&datastore, &backup_group, &worker)?
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -39,6 +39,7 @@ fn verify_index_chunks(
|
||||||
datastore: &DataStore,
|
datastore: &DataStore,
|
||||||
index: Box<dyn IndexFile>,
|
index: Box<dyn IndexFile>,
|
||||||
verified_chunks: &mut HashSet<[u8;32]>,
|
verified_chunks: &mut HashSet<[u8;32]>,
|
||||||
|
corrupt_chunks: &mut HashSet<[u8; 32]>,
|
||||||
worker: &WorkerTask,
|
worker: &WorkerTask,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
|
||||||
|
@ -51,11 +52,18 @@ fn verify_index_chunks(
|
||||||
let size = info.range.end - info.range.start;
|
let size = info.range.end - info.range.start;
|
||||||
|
|
||||||
if !verified_chunks.contains(&info.digest) {
|
if !verified_chunks.contains(&info.digest) {
|
||||||
if let Err(err) = datastore.verify_stored_chunk(&info.digest, size) {
|
if !corrupt_chunks.contains(&info.digest) {
|
||||||
worker.log(format!("{}", err));
|
if let Err(err) = datastore.verify_stored_chunk(&info.digest, size) {
|
||||||
errors += 1;
|
corrupt_chunks.insert(info.digest);
|
||||||
|
worker.log(format!("{}", err));
|
||||||
|
errors += 1;
|
||||||
|
} else {
|
||||||
|
verified_chunks.insert(info.digest);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
verified_chunks.insert(info.digest);
|
let digest_str = proxmox::tools::digest_to_hex(&info.digest);
|
||||||
|
worker.log(format!("chunk {} was marked as corrupt", digest_str));
|
||||||
|
errors += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +80,7 @@ fn verify_fixed_index(
|
||||||
backup_dir: &BackupDir,
|
backup_dir: &BackupDir,
|
||||||
info: &FileInfo,
|
info: &FileInfo,
|
||||||
verified_chunks: &mut HashSet<[u8;32]>,
|
verified_chunks: &mut HashSet<[u8;32]>,
|
||||||
|
corrupt_chunks: &mut HashSet<[u8;32]>,
|
||||||
worker: &WorkerTask,
|
worker: &WorkerTask,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
|
||||||
|
@ -89,7 +98,7 @@ fn verify_fixed_index(
|
||||||
bail!("wrong index checksum");
|
bail!("wrong index checksum");
|
||||||
}
|
}
|
||||||
|
|
||||||
verify_index_chunks(datastore, Box::new(index), verified_chunks, worker)
|
verify_index_chunks(datastore, Box::new(index), verified_chunks, corrupt_chunks, worker)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn verify_dynamic_index(
|
fn verify_dynamic_index(
|
||||||
|
@ -97,6 +106,7 @@ fn verify_dynamic_index(
|
||||||
backup_dir: &BackupDir,
|
backup_dir: &BackupDir,
|
||||||
info: &FileInfo,
|
info: &FileInfo,
|
||||||
verified_chunks: &mut HashSet<[u8;32]>,
|
verified_chunks: &mut HashSet<[u8;32]>,
|
||||||
|
corrupt_chunks: &mut HashSet<[u8;32]>,
|
||||||
worker: &WorkerTask,
|
worker: &WorkerTask,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
|
||||||
|
@ -114,7 +124,7 @@ fn verify_dynamic_index(
|
||||||
bail!("wrong index checksum");
|
bail!("wrong index checksum");
|
||||||
}
|
}
|
||||||
|
|
||||||
verify_index_chunks(datastore, Box::new(index), verified_chunks, worker)
|
verify_index_chunks(datastore, Box::new(index), verified_chunks, corrupt_chunks, worker)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Verify a single backup snapshot
|
/// Verify a single backup snapshot
|
||||||
|
@ -130,6 +140,7 @@ pub fn verify_backup_dir(
|
||||||
datastore: &DataStore,
|
datastore: &DataStore,
|
||||||
backup_dir: &BackupDir,
|
backup_dir: &BackupDir,
|
||||||
verified_chunks: &mut HashSet<[u8;32]>,
|
verified_chunks: &mut HashSet<[u8;32]>,
|
||||||
|
corrupt_chunks: &mut HashSet<[u8;32]>,
|
||||||
worker: &WorkerTask
|
worker: &WorkerTask
|
||||||
) -> Result<bool, Error> {
|
) -> Result<bool, Error> {
|
||||||
|
|
||||||
|
@ -149,8 +160,24 @@ pub fn verify_backup_dir(
|
||||||
let result = proxmox::try_block!({
|
let result = proxmox::try_block!({
|
||||||
worker.log(format!(" check {}", info.filename));
|
worker.log(format!(" check {}", info.filename));
|
||||||
match archive_type(&info.filename)? {
|
match archive_type(&info.filename)? {
|
||||||
ArchiveType::FixedIndex => verify_fixed_index(&datastore, &backup_dir, info, verified_chunks, worker),
|
ArchiveType::FixedIndex =>
|
||||||
ArchiveType::DynamicIndex => verify_dynamic_index(&datastore, &backup_dir, info, verified_chunks, worker),
|
verify_fixed_index(
|
||||||
|
&datastore,
|
||||||
|
&backup_dir,
|
||||||
|
info,
|
||||||
|
verified_chunks,
|
||||||
|
corrupt_chunks,
|
||||||
|
worker
|
||||||
|
),
|
||||||
|
ArchiveType::DynamicIndex =>
|
||||||
|
verify_dynamic_index(
|
||||||
|
&datastore,
|
||||||
|
&backup_dir,
|
||||||
|
info,
|
||||||
|
verified_chunks,
|
||||||
|
corrupt_chunks,
|
||||||
|
worker
|
||||||
|
),
|
||||||
ArchiveType::Blob => verify_blob(&datastore, &backup_dir, info),
|
ArchiveType::Blob => verify_blob(&datastore, &backup_dir, info),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -189,10 +216,11 @@ pub fn verify_backup_group(datastore: &DataStore, group: &BackupGroup, worker: &
|
||||||
let mut error_count = 0;
|
let mut error_count = 0;
|
||||||
|
|
||||||
let mut verified_chunks = HashSet::with_capacity(1024*16); // start with 16384 chunks (up to 65GB)
|
let mut verified_chunks = HashSet::with_capacity(1024*16); // start with 16384 chunks (up to 65GB)
|
||||||
|
let mut corrupt_chunks = HashSet::with_capacity(64); // start with 64 chunks since we assume there are few corrupt ones
|
||||||
|
|
||||||
BackupInfo::sort_list(&mut list, false); // newest first
|
BackupInfo::sort_list(&mut list, false); // newest first
|
||||||
for info in list {
|
for info in list {
|
||||||
if !verify_backup_dir(datastore, &info.backup_dir, &mut verified_chunks, worker)? {
|
if !verify_backup_dir(datastore, &info.backup_dir, &mut verified_chunks, &mut corrupt_chunks, worker)?{
|
||||||
error_count += 1;
|
error_count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue