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 7F4B268B1E for ; Thu, 22 Jul 2021 15:41:08 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6DD3211DA8 for ; Thu, 22 Jul 2021 15:41:08 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 68B7211D7F for ; Thu, 22 Jul 2021 15:41:07 +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 3528042587 for ; Thu, 22 Jul 2021 15:41:07 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Thu, 22 Jul 2021 15:41:00 +0200 Message-Id: <20210722134106.1280517-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210722134106.1280517-1-d.csapak@proxmox.com> References: <20210722134106.1280517-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.530 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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 v2 1/7] tape: media_catalog: improve chunk_archive interface 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: Thu, 22 Jul 2021 13:41:08 -0000 instead of having a public start/end_chunk_archive and register_chunks, simply expose a 'register_chunk_archive' method since we always have a list of chunks anywhere we want to add them Signed-off-by: Dominik Csapak --- src/api2/tape/restore.rs | 7 ++----- src/tape/media_catalog.rs | 22 +++++++++++++++++++--- src/tape/pool_writer/catalog_set.rs | 6 +----- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs index f959a856..1b0bc03f 100644 --- a/src/api2/tape/restore.rs +++ b/src/api2/tape/restore.rs @@ -1121,16 +1121,13 @@ fn restore_archive<'a>( }; if let Some(chunks) = chunks { - catalog.start_chunk_archive( + catalog.register_chunk_archive( Uuid::from(header.uuid), current_file_number, &source_datastore, + &chunks[..], )?; - for digest in chunks.iter() { - catalog.register_chunk(&digest)?; - } task_log!(worker, "register {} chunks", chunks.len()); - catalog.end_chunk_archive()?; catalog.commit_if_large()?; } return Ok(()); diff --git a/src/tape/media_catalog.rs b/src/tape/media_catalog.rs index 65b52a42..086c8a7d 100644 --- a/src/tape/media_catalog.rs +++ b/src/tape/media_catalog.rs @@ -503,10 +503,26 @@ impl MediaCatalog { Ok(()) } + /// Register a chunk archive + pub fn register_chunk_archive( + &mut self, + uuid: Uuid, // Uuid form MediaContentHeader + file_number: u64, + store: &str, + chunk_list: &[[u8; 32]], + ) -> Result<(), Error> { + self.start_chunk_archive(uuid, file_number, store)?; + for digest in chunk_list { + self.register_chunk(digest)?; + } + self.end_chunk_archive()?; + Ok(()) + } + /// Register a chunk /// /// Only valid after start_chunk_archive. - pub fn register_chunk( + fn register_chunk( &mut self, digest: &[u8;32], ) -> Result<(), Error> { @@ -557,7 +573,7 @@ impl MediaCatalog { } /// Start a chunk archive section - pub fn start_chunk_archive( + fn start_chunk_archive( &mut self, uuid: Uuid, // Uuid form MediaContentHeader file_number: u64, @@ -606,7 +622,7 @@ impl MediaCatalog { } /// End a chunk archive section - pub fn end_chunk_archive(&mut self) -> Result<(), Error> { + fn end_chunk_archive(&mut self) -> Result<(), Error> { match self.current_archive.take() { None => bail!("end_chunk_archive failed: not started"), diff --git a/src/tape/pool_writer/catalog_set.rs b/src/tape/pool_writer/catalog_set.rs index fbca3e97..d5903413 100644 --- a/src/tape/pool_writer/catalog_set.rs +++ b/src/tape/pool_writer/catalog_set.rs @@ -97,11 +97,7 @@ impl CatalogSet { ) -> Result<(), Error> { match self.catalog { Some(ref mut catalog) => { - catalog.start_chunk_archive(uuid, file_number, store)?; - for digest in chunk_list { - catalog.register_chunk(digest)?; - } - catalog.end_chunk_archive()?; + catalog.register_chunk_archive(uuid, file_number, store, chunk_list)?; } None => bail!("no catalog loaded - internal error"), } -- 2.30.2