public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Reiter <s.reiter@proxmox.com>
To: "Proxmox Backup Server development discussion"
	<pbs-devel@lists.proxmox.com>,
	"Fabian Grünbichler" <f.gruenbichler@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup-qemu] adapt to chunk reader changes
Date: Mon, 10 Aug 2020 17:13:34 +0200	[thread overview]
Message-ID: <e6a4b229-0ceb-4c5a-31c1-7f2bcfc7c208@proxmox.com> (raw)
In-Reply-To: <20200810112509.70129-2-f.gruenbichler@proxmox.com>

makes sense in general, one comment inline

On 8/10/20 1:25 PM, Fabian Grünbichler wrote:
> for verification of chunk crypt mode <=> index crypt mode match
> 
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
> follows patch #4 in proxmox-backup
> 
>   src/restore.rs | 30 +++++++++++++-----------------
>   1 file changed, 13 insertions(+), 17 deletions(-)
> 
> 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;
>   
> @@ -27,7 +26,6 @@ pub(crate) struct RestoreTask {
>       runtime: Arc<Runtime>,
>       crypt_config: Option<Arc<CryptConfig>>,
>       client: OnceCell<Arc<BackupReader>>,
> -    chunk_reader: OnceCell<RemoteChunkReader>,
>       manifest: OnceCell<Arc<BackupManifest>>,
>       image_registry: Arc<Mutex<Registry<ImageAccessInfo>>>,
>   }
> @@ -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::<ImageAccessInfo>::new())),
>           })
>       }
> @@ -94,15 +91,6 @@ impl RestoreTask {
>               true
>           ).await?;
>   
> -        let chunk_reader = 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, _) = client.download_manifest().await?;
>   
>           self.manifest.set(Arc::new(manifest))
> @@ -150,9 +138,12 @@ impl RestoreTask {
>   
>           let most_used = index.find_most_used_chunks(8);
>   
> +        let file_info = manifest.lookup_file_info(&archive_name)?;
> +
>           let mut chunk_reader = RemoteChunkReader::new(
>               client.clone(),
>               self.crypt_config.clone(),
> +            file_info.chunk_crypt_mode(),
>               most_used,
>           );
>   
> @@ -219,11 +210,6 @@ impl RestoreTask {
>               None => bail!("not connected"),
>           };
>   
> -        let chunk_reader = match self.chunk_reader.get() {
> -            Some(chunk_reader) => chunk_reader.clone(),
> -            None => bail!("not connected"),
> -        };
> -
>           let manifest = match self.manifest.get() {
>               Some(manifest) => manifest.clone(),
>               None => bail!("no manifest"),
> @@ -231,6 +217,16 @@ impl RestoreTask {
>   
>           let index = client.download_fixed_index(&manifest, &archive_name).await?;
>           let archive_size = index.index_bytes();
> +        let most_used = index.find_most_used_chunks(8);

You change the cache hint from previously an empty HashMap to the 8 
most-used chunks, is that intentional?

I don't believe that really does anything for a fixed index, and the 
AsyncIndexReader already caches the currently accessed chunk.

If anything, maybe add the zero digest here to keep that in cache, or 
even better maybe add that to the RemoteChunkReader?

> +
> +        let file_info = manifest.lookup_file_info(&archive_name)?;
> +
> +        let chunk_reader = RemoteChunkReader::new(
> +            client.clone(),
> +            self.crypt_config.clone(),
> +            file_info.chunk_crypt_mode(),
> +            most_used,
> +        );
>   
>           let reader = AsyncIndexReader::new(index, chunk_reader);
>   
> 




  reply	other threads:[~2020-08-10 15:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-10 11:25 [pbs-devel] [PATCH proxmox-backup(-qemu) 0/6] various crpyo/digest enhancements Fabian Grünbichler
2020-08-10 11:25 ` [pbs-devel] [PATCH proxmox-backup-qemu] adapt to chunk reader changes Fabian Grünbichler
2020-08-10 15:13   ` Stefan Reiter [this message]
2020-08-11  7:53     ` Fabian Grünbichler
2020-08-11  8:07       ` Stefan Reiter
2020-08-11  8:55   ` [pbs-devel] applied: " Dietmar Maurer
2020-08-10 11:25 ` [pbs-devel] [PATCH proxmox-backup 1/5] datastore api: only decode unencrypted indices Fabian Grünbichler
2020-08-11  7:57   ` [pbs-devel] applied: " Dietmar Maurer
2020-08-10 11:25 ` [pbs-devel] [PATCH proxmox-backup 2/5] datastore api: verify blob/index csum from manifest Fabian Grünbichler
2020-08-10 11:25 ` [pbs-devel] [PATCH proxmox-backup 3/5] chunk readers: ensure chunk/index CryptMode matches Fabian Grünbichler
2020-08-10 11:25 ` [pbs-devel] [PATCH proxmox-backup 4/5] verify: also check chunk CryptMode Fabian Grünbichler
2020-08-10 11:25 ` [pbs-devel] [RFC proxmox-backup 5/5] mark signed manifests as such Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e6a4b229-0ceb-4c5a-31c1-7f2bcfc7c208@proxmox.com \
    --to=s.reiter@proxmox.com \
    --cc=f.gruenbichler@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal