From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup v2 3/4] datastore: move try_ensure_sync_level() implementation to chunk store
Date: Tue, 12 May 2026 10:55:43 +0200 [thread overview]
Message-ID: <20260512085544.255754-4-c.ebner@proxmox.com> (raw)
In-Reply-To: <20260512085544.255754-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>
---
changes since version 1:
- move implementation to chunk store, thereby fixing logic error in
check.
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 bc218cb94..6338298a0 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,
- DatastoreTuning, GarbageCollectionCacheStats, GarbageCollectionStatus, MaintenanceMode,
- MaintenanceType, Operation, S3Statistics, MAX_NAMESPACE_DEPTH, UPID,
+ DataStoreConfig, DatastoreBackendConfig, DatastoreBackendType, DatastoreTuning,
+ 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(),
@@ -785,7 +783,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,
@@ -3012,19 +3009,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
next prev parent reply other threads:[~2026-05-12 8:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 8:55 [PATCH proxmox-backup v2 0/4] fix sync level updates for chunk store Christian Ebner
2026-05-12 8:55 ` [PATCH proxmox-backup v2 1/4] datastore: restrict chunk store mutex scope to crate only Christian Ebner
2026-05-12 8:55 ` [PATCH proxmox-backup v2 2/4] datastore: avoid useless double borrowing of datastore Christian Ebner
2026-05-12 8:55 ` Christian Ebner [this message]
2026-05-12 8:55 ` [PATCH proxmox-backup v2 4/4] 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=20260512085544.255754-4-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