public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup v3 6/7] datastore: move try_ensure_sync_level() implementation to chunk store
Date: Tue, 12 May 2026 15:10:46 +0200	[thread overview]
Message-ID: <20260512131047.689089-7-c.ebner@proxmox.com> (raw)
In-Reply-To: <20260512131047.689089-1-c.ebner@proxmox.com>

Keep the public interface for the datastore in place, but move the
method to the chunk store, dropping the now unneeded state stored on
DataStoreImpl. The path for the syncfs call does not change by the
move as the previous implementation already passed the chunk store
base path.

While moving, adapt the log message to use the tracing macro.

This is in preparation for fixing the sync level updates not being
propagated to the chunk store.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 pbs-datastore/src/chunk_store.rs | 13 +++++++++++++
 pbs-datastore/src/datastore.rs   | 22 +++++-----------------
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/pbs-datastore/src/chunk_store.rs b/pbs-datastore/src/chunk_store.rs
index 2888dea39..e8c279a62 100644
--- a/pbs-datastore/src/chunk_store.rs
+++ b/pbs-datastore/src/chunk_store.rs
@@ -966,6 +966,19 @@ impl ChunkStore {
         }
         (chunk_path, counter)
     }
+
+    pub(super) fn try_ensure_sync_level(&self) -> Result<(), Error> {
+        if self.sync_level != DatastoreFSyncLevel::Filesystem {
+            return Ok(());
+        }
+        let file = std::fs::File::open(self.base_path())?;
+        let fd = file.as_raw_fd();
+        info!("syncing filesystem");
+        if unsafe { libc::syncfs(fd) } < 0 {
+            bail!("error during syncfs: {}", std::io::Error::last_os_error());
+        }
+        Ok(())
+    }
 }
 
 #[derive(PartialEq)]
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index dbf9e7742..b67ab2f3a 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -32,9 +32,9 @@ use proxmox_worker_task::WorkerTaskContext;
 
 use pbs_api_types::{
     ArchiveType, Authid, BackupGroupDeleteStats, BackupNamespace, BackupType, ChunkOrder,
-    DataStoreConfig, DatastoreBackendConfig, DatastoreBackendType, DatastoreFSyncLevel,
-    GarbageCollectionCacheStats, GarbageCollectionStatus, MaintenanceMode, MaintenanceType,
-    Operation, S3Statistics, MAX_NAMESPACE_DEPTH, UPID,
+    DataStoreConfig, DatastoreBackendConfig, DatastoreBackendType, GarbageCollectionCacheStats,
+    GarbageCollectionStatus, MaintenanceMode, MaintenanceType, Operation, S3Statistics,
+    MAX_NAMESPACE_DEPTH, UPID,
 };
 use pbs_config::s3::S3_CFG_TYPE_ID;
 use pbs_config::{BackupLockGuard, ConfigVersionCache};
@@ -204,7 +204,6 @@ pub struct DataStoreImpl {
     last_gc_status: Mutex<GarbageCollectionStatus>,
     verify_new: bool,
     chunk_order: ChunkOrder,
-    sync_level: DatastoreFSyncLevel,
     backend_config: DatastoreBackendConfig,
     lru_store_caching: Option<LocalDatastoreLruCache>,
     thread_settings: DatastoreThreadSettings,
@@ -225,7 +224,6 @@ impl DataStoreImpl {
             last_gc_status: Mutex::new(GarbageCollectionStatus::default()),
             verify_new: false,
             chunk_order: Default::default(),
-            sync_level: Default::default(),
             backend_config: Default::default(),
             lru_store_caching: None,
             thread_settings: Default::default(),
@@ -775,7 +773,6 @@ impl DataStore {
             last_gc_status: Mutex::new(gc_status),
             verify_new: config.verify_new.unwrap_or(false),
             chunk_order: tuning.chunk_order.unwrap_or_default(),
-            sync_level: tuning.sync_level.unwrap_or_default(),
             backend_config,
             lru_store_caching,
             thread_settings,
@@ -2995,19 +2992,10 @@ impl DataStore {
     }
     */
 
-    /// Syncs the filesystem of the datastore if 'sync_level' is set to
+    /// Syncs the filesystem of the chunk store base path if 'sync_level' is set to
     /// [`DatastoreFSyncLevel::Filesystem`]. Uses syncfs(2).
     pub fn try_ensure_sync_level(&self) -> Result<(), Error> {
-        if self.inner.sync_level != DatastoreFSyncLevel::Filesystem {
-            return Ok(());
-        }
-        let file = std::fs::File::open(self.base_path())?;
-        let fd = file.as_raw_fd();
-        log::info!("syncing filesystem");
-        if unsafe { libc::syncfs(fd) } < 0 {
-            bail!("error during syncfs: {}", std::io::Error::last_os_error());
-        }
-        Ok(())
+        self.inner.chunk_store.try_ensure_sync_level()
     }
 
     /// Destroy a datastore. This requires that there are no active operations on the datastore.
-- 
2.47.3





  parent reply	other threads:[~2026-05-12 13:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 13:10 [PATCH proxmox{,-backup} v3 0/7] fix sync level updates for chunk store Christian Ebner
2026-05-12 13:10 ` [PATCH proxmox v3 1/7] pbs-api-types: derive FromStr for DatastoreTuning parsing Christian Ebner
2026-05-12 13:10 ` [PATCH proxmox-backup v3 2/7] datastore: GC: avoid double parsing of datastore tuning options Christian Ebner
2026-05-12 13:10 ` [PATCH proxmox-backup v3 3/7] pbs-config/datastore: add common helper for parsing " Christian Ebner
2026-05-12 13:10 ` [PATCH proxmox-backup v3 4/7] datastore: restrict chunk store mutex scope to crate only Christian Ebner
2026-05-12 13:10 ` [PATCH proxmox-backup v3 5/7] datastore: avoid useless double borrowing of datastore Christian Ebner
2026-05-12 13:10 ` Christian Ebner [this message]
2026-05-12 13:10 ` [PATCH proxmox-backup v3 7/7] datastore: fix sync level update propagation to chunk store Christian Ebner

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=20260512131047.689089-7-c.ebner@proxmox.com \
    --to=c.ebner@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal