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 B4A2E69F51 for ; Tue, 11 Aug 2020 09:53:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A7EF61A680 for ; Tue, 11 Aug 2020 09:53:26 +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 DF6651A676 for ; Tue, 11 Aug 2020 09:53:25 +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 A5A8344594 for ; Tue, 11 Aug 2020 09:53:25 +0200 (CEST) Date: Tue, 11 Aug 2020 09:53:18 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox Backup Server development discussion , Stefan Reiter References: <20200810112509.70129-1-f.gruenbichler@proxmox.com> <20200810112509.70129-2-f.gruenbichler@proxmox.com> In-Reply-To: MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1597132127.pvdvl5iryz.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.043 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] Subject: Re: [pbs-devel] [PATCH proxmox-backup-qemu] adapt to chunk reader changes 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: Tue, 11 Aug 2020 07:53:56 -0000 On August 10, 2020 5:13 pm, Stefan Reiter wrote: > makes sense in general, one comment inline >=20 > On 8/10/20 1:25 PM, Fabian Gr=C3=BCnbichler wrote: >> for verification of chunk crypt mode <=3D> index crypt mode match >>=20 >> Signed-off-by: Fabian Gr=C3=BCnbichler >> --- >> follows patch #4 in proxmox-backup >>=20 >> src/restore.rs | 30 +++++++++++++----------------- >> 1 file changed, 13 insertions(+), 17 deletions(-) >>=20 >> diff --git a/src/restore.rs b/src/restore.rs >> index e43d040..9d8c4a2 100644 >> --- a/src/restore.rs >> +++ b/src/restore.rs >> @@ -1,5 +1,4 @@ >> use std::sync::{Arc, Mutex}; >> -use std::collections::HashMap; >> use std::io::SeekFrom; >> use std::convert::TryInto; >> =20 >> @@ -27,7 +26,6 @@ pub(crate) struct RestoreTask { >> runtime: Arc, >> crypt_config: Option>, >> client: OnceCell>, >> - chunk_reader: OnceCell, >> manifest: OnceCell>, >> image_registry: Arc>>, >> } >> @@ -59,7 +57,6 @@ impl RestoreTask { >> crypt_config, >> client: OnceCell::new(), >> manifest: OnceCell::new(), >> - chunk_reader: OnceCell::new(), >> image_registry: Arc::new(Mutex::new(Registry::::new())), >> }) >> } >> @@ -94,15 +91,6 @@ impl RestoreTask { >> true >> ).await?; >> =20 >> - let chunk_reader =3D RemoteChunkReader::new( >> - client.clone(), >> - self.crypt_config.clone(), >> - HashMap::with_capacity(0), >> - ); >> - >> - self.chunk_reader.set(chunk_reader) >> - .map_err(|_| format_err!("already connected!"))?; >> - >> let (manifest, _) =3D client.download_manifest().await?; >> =20 >> self.manifest.set(Arc::new(manifest)) >> @@ -150,9 +138,12 @@ impl RestoreTask { >> =20 >> let most_used =3D index.find_most_used_chunks(8); >> =20 >> + let file_info =3D manifest.lookup_file_info(&archive_name)?; >> + >> let mut chunk_reader =3D RemoteChunkReader::new( >> client.clone(), >> self.crypt_config.clone(), >> + file_info.chunk_crypt_mode(), >> most_used, >> ); >> =20 >> @@ -219,11 +210,6 @@ impl RestoreTask { >> None =3D> bail!("not connected"), >> }; >> =20 >> - let chunk_reader =3D match self.chunk_reader.get() { >> - Some(chunk_reader) =3D> chunk_reader.clone(), >> - None =3D> bail!("not connected"), >> - }; >> - >> let manifest =3D match self.manifest.get() { >> Some(manifest) =3D> manifest.clone(), >> None =3D> bail!("no manifest"), >> @@ -231,6 +217,16 @@ impl RestoreTask { >> =20 >> let index =3D client.download_fixed_index(&manifest, &archive_= name).await?; >> let archive_size =3D index.index_bytes(); >> + let most_used =3D index.find_most_used_chunks(8); >=20 > You change the cache hint from previously an empty HashMap to the 8=20 > most-used chunks, is that intentional? >=20 > I don't believe that really does anything for a fixed index, and the=20 > AsyncIndexReader already caches the currently accessed chunk. I made it do that same thing that the other RemoteChunkReader in=20 restore.rs does ;) > If anything, maybe add the zero digest here to keep that in cache, or=20 > even better maybe add that to the RemoteChunkReader? yeah, could do that. the restore itself already skips it to write zeroes=20 directly without even asking the chunk reader, so not sure how much we=20 gain by teaching the chunk reader to skip them as well.. >=20 >> + >> + let file_info =3D manifest.lookup_file_info(&archive_name)?; >> + >> + let chunk_reader =3D RemoteChunkReader::new( >> + client.clone(), >> + self.crypt_config.clone(), >> + file_info.chunk_crypt_mode(), >> + most_used, >> + ); >> =20 >> let reader =3D AsyncIndexReader::new(index, chunk_reader); >> =20 >>=20 >=20 =