From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 6BE331FF0ED for ; Fri, 31 Jul 2026 16:25:27 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id A263D2158C; Fri, 31 Jul 2026 16:25:26 +0200 (CEST) From: Robert Obkircher To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup 8/9] datastore: always access dynamic index reader slice through method Date: Fri, 31 Jul 2026 16:21:21 +0200 Message-ID: <20260731142430.289893-9-r.obkircher@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260731142430.289893-1-r.obkircher@proxmox.com> References: <20260731142430.289893-1-r.obkircher@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1785507909777 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.137 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_LOW -0.7 Sender listed at https://www.dnswl.org/, low trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: XOFHRJVTIXV2RLGAQRKILIGCFEKDKYMF X-Message-ID-Hash: XOFHRJVTIXV2RLGAQRKILIGCFEKDKYMF X-MailFrom: r.obkircher@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Reduce the size of the diff in the upcoming mmap changes, where the index field will be removed. Signed-off-by: Robert Obkircher --- pbs-datastore/src/dynamic_index.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pbs-datastore/src/dynamic_index.rs b/pbs-datastore/src/dynamic_index.rs index dd0b86f3f..c03ab6c29 100644 --- a/pbs-datastore/src/dynamic_index.rs +++ b/pbs-datastore/src/dynamic_index.rs @@ -147,18 +147,18 @@ impl DynamicIndexReader { #[inline] pub fn chunk_end(&self, pos: usize) -> u64 { - if pos >= self.index.len() { + if pos >= self.index().len() { panic!("chunk index out of range"); } - self.index[pos].end() + self.index()[pos].end() } #[inline] fn chunk_digest(&self, pos: usize) -> &[u8; 32] { - if pos >= self.index.len() { + if pos >= self.index().len() { panic!("chunk index out of range"); } - &self.index[pos].digest + &self.index()[pos].digest } pub fn binary_search( @@ -189,11 +189,11 @@ impl DynamicIndexReader { impl IndexFile for DynamicIndexReader { fn index_count(&self) -> usize { - self.index.len() + self.index().len() } fn index_digest(&self, pos: usize) -> Option<&[u8; 32]> { - if pos >= self.index.len() { + if pos >= self.index().len() { None } else { Some(self.chunk_digest(pos)) @@ -201,10 +201,10 @@ impl IndexFile for DynamicIndexReader { } fn index_bytes(&self) -> u64 { - if self.index.is_empty() { + if self.index().is_empty() { 0 } else { - self.chunk_end(self.index.len() - 1) + self.chunk_end(self.index().len() - 1) } } @@ -222,20 +222,20 @@ impl IndexFile for DynamicIndexReader { } fn chunk_info(&self, pos: usize) -> Option { - if pos >= self.index.len() { + if pos >= self.index().len() { return None; } let start = if pos == 0 { 0 } else { - self.index[pos - 1].end() + self.index()[pos - 1].end() }; - let end = self.index[pos].end(); + let end = self.index()[pos].end(); Some(ChunkReadInfo { range: start..end, - digest: self.index[pos].digest, + digest: self.index()[pos].digest, }) } @@ -248,7 +248,7 @@ impl IndexFile for DynamicIndexReader { } fn chunk_from_offset(&self, offset: u64) -> Option<(usize, u64)> { - let end_idx = self.index.len() - 1; + let end_idx = self.index().len() - 1; let end = self.chunk_end(end_idx); let found_idx = self.binary_search(0, 0, end_idx, end, offset); let found_idx = match found_idx { -- 2.47.3