From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id A758E1FF13E for ; Fri, 23 Jan 2026 16:43:24 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E7F92116DD; Fri, 23 Jan 2026 16:43:44 +0100 (CET) From: Robert Obkircher To: pbs-devel@lists.proxmox.com Date: Fri, 23 Jan 2026 16:37:17 +0100 Message-ID: <20260123154147.222215-5-r.obkircher@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260123154147.222215-1-r.obkircher@proxmox.com> References: <20260123154147.222215-1-r.obkircher@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1769182932139 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.059 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 v4 proxmox-backup 04/11] api: backup: make fixed index file size optional 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Pass the optional size to the FixedIndexWriter to make it grow as necessary. Signed-off-by: Robert Obkircher --- src/api2/backup/environment.rs | 21 ++++++++++++--------- src/api2/backup/mod.rs | 8 +++----- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/api2/backup/environment.rs b/src/api2/backup/environment.rs index bd9c5211..90a84ed2 100644 --- a/src/api2/backup/environment.rs +++ b/src/api2/backup/environment.rs @@ -67,7 +67,7 @@ struct DynamicWriterState { struct FixedWriterState { name: String, index: FixedIndexWriter, - size: usize, + size: Option, chunk_size: u32, chunk_count: u64, small_chunk_count: usize, // allow 0..1 small chunks (last chunk may be smaller) @@ -349,7 +349,7 @@ impl BackupEnvironment { &self, index: FixedIndexWriter, name: String, - size: usize, + size: Option, chunk_size: u32, incremental: bool, ) -> Result { @@ -443,6 +443,7 @@ impl BackupEnvironment { } let end = (offset as usize) + (size as usize); + data.index.grow_to_size(end)?; let idx = data.index.check_chunk_alignment(end, size as usize)?; data.chunk_count += 1; @@ -624,13 +625,15 @@ impl BackupEnvironment { ); } - if size != (data.size as u64) { - bail!( - "fixed writer '{}' close failed - unexpected file size ({} != {})", - data.name, - data.size, - size - ); + if let Some(known_size) = data.size { + if size != known_size as u64 { + bail!( + "fixed writer '{}' close failed - unexpected file size ({} != {})", + data.name, + known_size, + size, + ); + } } } diff --git a/src/api2/backup/mod.rs b/src/api2/backup/mod.rs index c625a2dc..c2822c18 100644 --- a/src/api2/backup/mod.rs +++ b/src/api2/backup/mod.rs @@ -456,7 +456,7 @@ pub const API_METHOD_CREATE_FIXED_INDEX: ApiMethod = ApiMethod::new( ("archive-name", false, &BACKUP_ARCHIVE_NAME_SCHEMA), ( "size", - false, + true, &IntegerSchema::new("File size.").minimum(1).schema() ), ( @@ -480,7 +480,7 @@ fn create_fixed_index( let env: &BackupEnvironment = rpcenv.as_ref(); let name = required_string_param(¶m, "archive-name")?.to_owned(); - let size = required_integer_param(¶m, "size")? as usize; + let size = param["size"].as_u64().map(usize::try_from).transpose()?; let reuse_csum = param["reuse-csum"].as_str(); let archive_name = name.clone(); @@ -528,9 +528,7 @@ fn create_fixed_index( reader = Some(index); } - let mut writer = env - .datastore - .create_fixed_writer(&path, Some(size), chunk_size)?; + let mut writer = env.datastore.create_fixed_writer(&path, size, chunk_size)?; if let Some(reader) = reader { writer.clone_data_from(&reader)?; -- 2.47.3 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel