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 A3A8272D6F for ; Wed, 14 Apr 2021 10:42:34 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A0F36BB33 for ; Wed, 14 Apr 2021 10:42:34 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 firstgate.proxmox.com (Proxmox) with ESMTPS id B9B0FBB26 for ; Wed, 14 Apr 2021 10:42:33 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 845BB42236 for ; Wed, 14 Apr 2021 10:42:33 +0200 (CEST) Date: Wed, 14 Apr 2021 10:42:17 +0200 (CEST) From: Dietmar Maurer To: Proxmox Backup Server development discussion , Dominik Csapak Message-ID: <567501781.2857.1618389737844@webmail.proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.5-Rev5 X-Originating-Client: open-xchange-appsuite X-SPAM-LEVEL: Spam detection results: 0 AWL 0.110 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [restore.rs, proxmox.com] Subject: [pbs-devel] applied: [PATCH proxmox-backup 1/2] api2/tape/restore: restore_chunk_archive: only ignore tape related errors 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: Wed, 14 Apr 2021 08:42:34 -0000 I don't think this fixes any bugs, but the code is cleaner and more obvious, so I applied it anyways... > On 04/13/2021 12:58 PM Dominik Csapak wrote: > > > when we get an error from the tape, we possibly want to ignore it, > i.e. when the file was incomplete, but we still want to error > out if the error came from e.g, the datastore, so we have to move > the error checking code to the 'next_chunk' call > > Signed-off-by: Dominik Csapak > --- > src/api2/tape/restore.rs | 77 ++++++++++++++++++++-------------------- > 1 file changed, 38 insertions(+), 39 deletions(-) > > diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs > index afce3449..9f79f06f 100644 > --- a/src/api2/tape/restore.rs > +++ b/src/api2/tape/restore.rs > @@ -597,54 +597,53 @@ fn restore_chunk_archive<'a>( > > let mut decoder = ChunkArchiveDecoder::new(reader); > > - let result: Result<_, Error> = proxmox::try_block!({ > - while let Some((digest, blob)) = decoder.next_chunk()? { > - > - worker.check_abort()?; > - > - if let Some(datastore) = datastore { > - let chunk_exists = datastore.cond_touch_chunk(&digest, false)?; > - if !chunk_exists { > - blob.verify_crc()?; > + loop { > + let (digest, blob) = match decoder.next_chunk() { > + Ok(Some((digest, blob))) => (digest, blob), > + Ok(None) => break, > + Err(err) => { > + let reader = decoder.reader(); > + > + // check if this stream is marked incomplete > + if let Ok(true) = reader.is_incomplete() { > + return Ok(Some(chunks)); > + } > > - if blob.crypt_mode()? == CryptMode::None { > - blob.decode(None, Some(&digest))?; // verify digest > - } > - if verbose { > - task_log!(worker, "Insert chunk: {}", proxmox::tools::digest_to_hex(&digest)); > - } > - datastore.insert_chunk(&blob, &digest)?; > - } else if verbose { > - task_log!(worker, "Found existing chunk: {}", proxmox::tools::digest_to_hex(&digest)); > + // check if this is an aborted stream without end marker > + if let Ok(false) = reader.has_end_marker() { > + worker.log("missing stream end marker".to_string()); > + return Ok(None); > } > - } else if verbose { > - task_log!(worker, "Found chunk: {}", proxmox::tools::digest_to_hex(&digest)); > + > + // else the archive is corrupt > + return Err(err); > } > - chunks.push(digest); > - } > - Ok(()) > - }); > + }; > > - match result { > - Ok(()) => Ok(Some(chunks)), > - Err(err) => { > - let reader = decoder.reader(); > + worker.check_abort()?; > > - // check if this stream is marked incomplete > - if let Ok(true) = reader.is_incomplete() { > - return Ok(Some(chunks)); > - } > + if let Some(datastore) = datastore { > + let chunk_exists = datastore.cond_touch_chunk(&digest, false)?; > + if !chunk_exists { > + blob.verify_crc()?; > > - // check if this is an aborted stream without end marker > - if let Ok(false) = reader.has_end_marker() { > - worker.log("missing stream end marker".to_string()); > - return Ok(None); > + if blob.crypt_mode()? == CryptMode::None { > + blob.decode(None, Some(&digest))?; // verify digest > + } > + if verbose { > + task_log!(worker, "Insert chunk: {}", proxmox::tools::digest_to_hex(&digest)); > + } > + datastore.insert_chunk(&blob, &digest)?; > + } else if verbose { > + task_log!(worker, "Found existing chunk: {}", proxmox::tools::digest_to_hex(&digest)); > } > - > - // else the archive is corrupt > - Err(err) > + } else if verbose { > + task_log!(worker, "Found chunk: {}", proxmox::tools::digest_to_hex(&digest)); > } > + chunks.push(digest); > } > + > + Ok(Some(chunks)) > } > > fn restore_snapshot_archive<'a>( > -- > 2.20.1 > > > > _______________________________________________ > pbs-devel mailing list > pbs-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel