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 936F562860 for ; Wed, 30 Sep 2020 16:35:33 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8112A1A86B for ; Wed, 30 Sep 2020 16:35:03 +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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id AD85E1A85F for ; Wed, 30 Sep 2020 16:35:01 +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 73C1745996 for ; Wed, 30 Sep 2020 16:35:01 +0200 (CEST) To: Proxmox Backup Server development discussion , Stefan Reiter References: <20200930141601.27233-1-s.reiter@proxmox.com> <20200930141601.27233-2-s.reiter@proxmox.com> From: Thomas Lamprecht Message-ID: <9c7a8d82-3e19-a9bd-d0e4-b1aec6ef092c@proxmox.com> Date: Wed, 30 Sep 2020 16:35:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:82.0) Gecko/20100101 Thunderbird/82.0 MIME-Version: 1.0 In-Reply-To: <20200930141601.27233-2-s.reiter@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL -0.161 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) 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. [environment.rs] Subject: Re: [pbs-devel] [PATCH v2 proxmox-backup 1/5] backup: don't validate chunk existance if base was recently verified 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, 30 Sep 2020 14:35:33 -0000 On 30.09.20 16:15, Stefan Reiter wrote: > If the base was successfully verified within the last 7 days, we assume= > that it is okay and all chunks exist, so we don't have to check. >=20 > Signed-off-by: Stefan Reiter > --- >=20 > v2: > * use proxmox::tools::time >=20 > src/api2/backup/environment.rs | 32 ++++++++++++++++++++++++++++++-- > 1 file changed, 30 insertions(+), 2 deletions(-) >=20 > diff --git a/src/api2/backup/environment.rs b/src/api2/backup/environme= nt.rs > index d515bf30..a8c9ddb4 100644 > --- a/src/api2/backup/environment.rs > +++ b/src/api2/backup/environment.rs > @@ -5,7 +5,7 @@ use std::collections::HashMap; > use ::serde::{Serialize}; > use serde_json::{json, Value}; > =20 > -use proxmox::tools::digest_to_hex; > +use proxmox::tools::{digest_to_hex, time}; > use proxmox::tools::fs::{replace_file, CreateOptions}; > use proxmox::api::{RpcEnvironment, RpcEnvironmentType}; > =20 > @@ -457,6 +457,32 @@ impl BackupEnvironment { > Ok(()) > } > =20 > + fn last_backup_has_recent_verify(&self) -> Result { > + match &self.last_backup { > + Some(last_backup) =3D> { > + let last_dir =3D &last_backup.backup_dir; > + let (manifest, _) =3D self.datastore.load_manifest(las= t_dir)?; > + let verify =3D manifest.unprotected["verify_state"].cl= one(); > + match serde_json::from_value::>(verify) { > + Ok(verify) =3D> match verify { > + Some(verify) =3D> { > + let mut cutoff =3D time::TmEditor::with_ep= och(time::epoch_i64(), false)?; > + cutoff.add_days(-7)?; > + let cutoff =3D cutoff.into_epoch()?; why not just use time::epoch_i64(), avoiding a conversion to tm just to convert it back, this is no time critical check, if there's a leap second or something like that. IMO, below is just more simple and everyone still gets whats meant.. let cutoff =3D time::epoch_i64() - 7 * 24 * 60 * 60; Ok(verify.state =3D=3D VerifyState::Ok && verify.upid.starttime > cutoff)= (but please, if you agree, do not send a v3 with the full series, this ca= n stand as it's own patch - out of the series)