From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 7677E7902D for ; Mon, 3 May 2021 13:24:16 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6C9FB1CD60 for ; Mon, 3 May 2021 13:23:46 +0200 (CEST) Received: from elsa.proxmox.com (unknown [94.136.29.99]) by firstgate.proxmox.com (Proxmox) with ESMTP id E26841CD40 for ; Mon, 3 May 2021 13:23:44 +0200 (CEST) Received: by elsa.proxmox.com (Postfix, from userid 0) id BA2F7AEB2DA; Mon, 3 May 2021 13:23:38 +0200 (CEST) From: Dietmar Maurer To: pbs-devel@lists.proxmox.com Date: Mon, 3 May 2021 13:23:37 +0200 Message-Id: <20210503112337.29879-4-dietmar@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210503112337.29879-1-dietmar@proxmox.com> References: <20210503112337.29879-1-dietmar@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.365 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS 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 4/4] tape restore: do not verify restored files 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: , X-List-Received-Date: Mon, 03 May 2021 11:24:16 -0000 Because this is too slow and causes the tape motor to stop. Instead, remove the verify_state from the manifest. --- src/api2/tape/restore.rs | 53 +++++++++++++--------------------------- 1 file changed, 17 insertions(+), 36 deletions(-) diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs index 2e422cbc..2614c68a 100644 --- a/src/api2/tape/restore.rs +++ b/src/api2/tape/restore.rs @@ -32,7 +32,7 @@ use crate::{ task_log, task_warn, task::TaskState, - tools::{compute_file_csum, ParallelHandler}, + tools::ParallelHandler, api2::types::{ DATASTORE_MAP_ARRAY_SCHEMA, DATASTORE_MAP_LIST_SCHEMA, @@ -51,17 +51,12 @@ use crate::{ }, }, backup::{ - archive_type, MANIFEST_BLOB_NAME, CryptMode, DataStore, BackupDir, DataBlob, BackupManifest, - ArchiveType, - IndexFile, - DynamicIndexReader, - FixedIndexReader, }, server::{ lookup_user_email, @@ -790,8 +785,8 @@ fn try_restore_snapshot_archive( worker: &WorkerTask, decoder: &mut pxar::decoder::sync::Decoder, snapshot_path: &Path, - datastore: &DataStore, - checked_chunks: &mut HashSet<[u8;32]>, + _datastore: &DataStore, + _checked_chunks: &mut HashSet<[u8;32]>, ) -> Result<(), Error> { let _root = match decoder.next() { @@ -848,6 +843,16 @@ fn try_restore_snapshot_archive( if filename == manifest_file_name { let blob = DataBlob::load_from_reader(&mut contents)?; + let mut old_manifest = BackupManifest::try_from(blob)?; + + // Remove verify_state to indicate that this snapshot is not verified + old_manifest.unprotected + .as_object_mut() + .map(|m| m.remove("verify_state")); + + let old_manifest = serde_json::to_string_pretty(&old_manifest)?; + let blob = DataBlob::encode(old_manifest.as_bytes(), None, true)?; + let options = CreateOptions::new(); replace_file(&tmp_path, blob.raw_data(), options)?; @@ -868,36 +873,12 @@ fn try_restore_snapshot_archive( } } - let manifest = match manifest { - None => bail!("missing manifest"), - Some(manifest) => manifest, - }; - - for item in manifest.files() { - let mut archive_path = snapshot_path.to_owned(); - archive_path.push(&item.filename); - - match archive_type(&item.filename)? { - ArchiveType::DynamicIndex => { - let index = DynamicIndexReader::open(&archive_path)?; - let (csum, size) = index.compute_csum(); - manifest.verify_file(&item.filename, &csum, size)?; - datastore.fast_index_verification(&index, checked_chunks)?; - } - ArchiveType::FixedIndex => { - let index = FixedIndexReader::open(&archive_path)?; - let (csum, size) = index.compute_csum(); - manifest.verify_file(&item.filename, &csum, size)?; - datastore.fast_index_verification(&index, checked_chunks)?; - } - ArchiveType::Blob => { - let mut tmpfile = std::fs::File::open(&archive_path)?; - let (csum, size) = compute_file_csum(&mut tmpfile)?; - manifest.verify_file(&item.filename, &csum, size)?; - } - } + if manifest.is_none() { + bail!("missing manifest"); } + // Do not verify anything here, because this would be to slow (causes tape stops). + // commit manifest let mut manifest_path = snapshot_path.to_owned(); manifest_path.push(MANIFEST_BLOB_NAME); -- 2.20.1