From: Robert Obkircher <r.obkircher@proxmox.com>
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 [thread overview]
Message-ID: <20260731142430.289893-9-r.obkircher@proxmox.com> (raw)
In-Reply-To: <20260731142430.289893-1-r.obkircher@proxmox.com>
Reduce the size of the diff in the upcoming mmap changes, where the
index field will be removed.
Signed-off-by: Robert Obkircher <r.obkircher@proxmox.com>
---
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<ChunkReadInfo> {
- 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
next prev parent reply other threads:[~2026-07-31 14:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 14:21 [PATCH proxmox{,-backup} 0/9] support index readers on larger page sizes Robert Obkircher
2026-07-31 14:21 ` [PATCH proxmox 1/9] proxmox-sys: add len and as_non_null method to Mmap Robert Obkircher
2026-07-31 14:21 ` [PATCH proxmox-backup 2/9] datastore: limit scope of mutable reference in FixedIndexWriter::close Robert Obkircher
2026-07-31 14:21 ` [PATCH proxmox-backup 3/9] datastore: add tests for fixed and dynamic index reader Robert Obkircher
2026-07-31 14:21 ` [PATCH proxmox-backup 4/9] datastore: fix inconsistent implementation of index_size method Robert Obkircher
2026-07-31 14:21 ` [PATCH proxmox-backup 5/9] bin: debug: print referenced backup size for index files Robert Obkircher
2026-07-31 14:21 ` [PATCH proxmox-backup 6/9] datastore: check that index files are regular files Robert Obkircher
2026-07-31 14:21 ` [PATCH proxmox-backup 7/9] datastore: simplify FixedIndexReader::chunk_info Robert Obkircher
2026-07-31 14:21 ` Robert Obkircher [this message]
2026-07-31 14:21 ` [PATCH proxmox-backup 9/9] fix #7244: datastore: always mmap index files from offset 0 Robert Obkircher
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=20260731142430.289893-9-r.obkircher@proxmox.com \
--to=r.obkircher@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.