[pbs-devel] [PATCH proxmox-backup v2 3/3] index writers: remove chunk store lock

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Oct 2 09:27:48 CEST 2025


the only user of these (the backup session) now holds its own chunk store lock
for the duration of the backup, like pull and tape already do as well.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---

Notes:
    we could extend the process locker to allow checking whether a certain guard id
    is still valid as a safeguard. passing around references to the guard itself
    from the backup session down here is very cumbersome..

 pbs-datastore/src/datastore.rs     | 2 ++
 pbs-datastore/src/dynamic_index.rs | 6 +-----
 pbs-datastore/src/fixed_index.rs   | 6 +-----
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 319d82faa..34401f231 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -533,6 +533,7 @@ impl DataStore {
         self.inner.chunk_store.get_chunk_iterator()
     }
 
+    // Requires obtaining a shared chunk store lock beforehand
     pub fn create_fixed_writer<P: AsRef<Path>>(
         &self,
         filename: P,
@@ -560,6 +561,7 @@ impl DataStore {
         Ok(index)
     }
 
+    // Requires obtaining a shared chunk store lock beforehand
     pub fn create_dynamic_writer<P: AsRef<Path>>(
         &self,
         filename: P,
diff --git a/pbs-datastore/src/dynamic_index.rs b/pbs-datastore/src/dynamic_index.rs
index 83e13b311..ff6c36782 100644
--- a/pbs-datastore/src/dynamic_index.rs
+++ b/pbs-datastore/src/dynamic_index.rs
@@ -11,7 +11,6 @@ use anyhow::{bail, format_err, Error};
 
 use proxmox_io::ReadExt;
 use proxmox_sys::mmap::Mmap;
-use proxmox_sys::process_locker::ProcessLockSharedGuard;
 use proxmox_uuid::Uuid;
 use pxar::accessor::{MaybeReady, ReadAt, ReadAtOperation};
 
@@ -277,7 +276,6 @@ impl IndexFile for DynamicIndexReader {
 /// Create dynamic index files (`.dixd`)
 pub struct DynamicIndexWriter {
     store: Arc<ChunkStore>,
-    _lock: ProcessLockSharedGuard,
     writer: BufWriter<File>,
     closed: bool,
     filename: PathBuf,
@@ -294,9 +292,8 @@ impl Drop for DynamicIndexWriter {
 }
 
 impl DynamicIndexWriter {
+    // Requires obtaining a shared chunk store lock beforehand
     pub fn create(store: Arc<ChunkStore>, path: &Path) -> Result<Self, Error> {
-        let shared_lock = store.try_shared_lock()?;
-
         let full_path = store.relative_path(path);
         let mut tmp_path = full_path.clone();
         tmp_path.set_extension("tmp_didx");
@@ -325,7 +322,6 @@ impl DynamicIndexWriter {
 
         Ok(Self {
             store,
-            _lock: shared_lock,
             writer,
             closed: false,
             filename: full_path,
diff --git a/pbs-datastore/src/fixed_index.rs b/pbs-datastore/src/fixed_index.rs
index 8d9173e86..0f289543f 100644
--- a/pbs-datastore/src/fixed_index.rs
+++ b/pbs-datastore/src/fixed_index.rs
@@ -9,7 +9,6 @@ use std::sync::Arc;
 use anyhow::{bail, format_err, Error};
 
 use proxmox_io::ReadExt;
-use proxmox_sys::process_locker::ProcessLockSharedGuard;
 use proxmox_uuid::Uuid;
 
 use crate::chunk_stat::ChunkStat;
@@ -218,7 +217,6 @@ impl IndexFile for FixedIndexReader {
 pub struct FixedIndexWriter {
     store: Arc<ChunkStore>,
     file: File,
-    _lock: ProcessLockSharedGuard,
     filename: PathBuf,
     tmp_filename: PathBuf,
     chunk_size: usize,
@@ -243,14 +241,13 @@ impl Drop for FixedIndexWriter {
 
 impl FixedIndexWriter {
     #[allow(clippy::cast_ptr_alignment)]
+    // Requires obtaining a shared chunk store lock beforehand
     pub fn create(
         store: Arc<ChunkStore>,
         path: &Path,
         size: usize,
         chunk_size: usize,
     ) -> Result<Self, Error> {
-        let shared_lock = store.try_shared_lock()?;
-
         let full_path = store.relative_path(path);
         let mut tmp_path = full_path.clone();
         tmp_path.set_extension("tmp_fidx");
@@ -307,7 +304,6 @@ impl FixedIndexWriter {
         Ok(Self {
             store,
             file,
-            _lock: shared_lock,
             filename: full_path,
             tmp_filename: tmp_path,
             chunk_size,
-- 
2.47.3





More information about the pbs-devel mailing list