[pbs-devel] [PATCH proxmox-backup 05/11] verify: acquire shared snapshot flock and skip on error
Stefan Reiter
s.reiter at proxmox.com
Wed Oct 14 14:16:33 CEST 2020
If we can't acquire a lock (either because the snapshot disappeared, it
is about to be forgotten/pruned, or it is currently still running) skip
the snapshot. Hold the lock during verification, so that it cannot be
deleted while we are still verifying.
Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---
src/backup/verify.rs | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/backup/verify.rs b/src/backup/verify.rs
index f2c38eae..5e1391d9 100644
--- a/src/backup/verify.rs
+++ b/src/backup/verify.rs
@@ -23,6 +23,7 @@ use crate::{
task::TaskState,
task_log,
tools::ParallelHandler,
+ tools::fs::lock_dir_noblock_shared,
};
fn verify_blob(datastore: Arc<DataStore>, backup_dir: &BackupDir, info: &FileInfo) -> Result<(), Error> {
@@ -284,6 +285,21 @@ pub fn verify_backup_dir(
upid: UPID,
) -> Result<bool, Error> {
+ let _guard_res = lock_dir_noblock_shared(
+ &datastore.snapshot_path(&backup_dir),
+ "snapshot",
+ "locked by another operation");
+ if let Err(err) = _guard_res {
+ task_log!(
+ worker,
+ "SKIPPED: verify {}:{} - could not acquire snapshot lock: {}",
+ datastore.name(),
+ backup_dir,
+ err,
+ );
+ return Ok(true);
+ }
+
let mut manifest = match datastore.load_manifest(&backup_dir) {
Ok((manifest, _)) => manifest,
Err(err) => {
--
2.20.1
More information about the pbs-devel
mailing list