all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 3/3] index writers: remove chunk store lock
Date: Wed,  1 Oct 2025 13:19:11 +0200	[thread overview]
Message-ID: <20251001111915.2001026-4-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20251001111915.2001026-1-f.gruenbichler@proxmox.com>

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@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 c821ac547..79c93fb28 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



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel

  parent reply	other threads:[~2025-10-01 11:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-01 11:19 [pbs-devel] [PATCH proxmox-backup 0/3] rework GC-related locks Fabian Grünbichler
2025-10-01 11:19 ` [pbs-devel] [PATCH proxmox-backup 1/3] GC: rework locking logic Fabian Grünbichler
2025-10-01 13:11   ` Christian Ebner
2025-10-01 11:19 ` [pbs-devel] [PATCH proxmox-backup 2/3] backup env: keep a shared chunk store lock for duration of backup Fabian Grünbichler
2025-10-01 11:19 ` Fabian Grünbichler [this message]
2025-10-02  7:29 ` [pbs-devel] superseded: [PATCH proxmox-backup 0/3] rework GC-related locks Fabian Grünbichler

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=20251001111915.2001026-4-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal