public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH proxmox-backup] pbs-key-config: align fsync behavior when storing new/existing key
@ 2026-03-24 10:04 Christian Ebner
  2026-03-24 13:17 ` Fabian Grünbichler
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Ebner @ 2026-03-24 10:04 UTC (permalink / raw)
  To: pbs-devel

In case a key is stored by replacing the file contents, the file
contents are synced to disk as the corresponding flag is set for
proxmox-sys::fs::replace_file(). When creating a new file however,
fsync is never called.

Align the behaviour by also calling fsync in case of storing the key
to a new file.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
Noticed while evaluating to reuse this method to store key
information to be used by push sync jobs.

 pbs-key-config/src/lib.rs | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pbs-key-config/src/lib.rs b/pbs-key-config/src/lib.rs
index 0bcd5338c..71a49dd78 100644
--- a/pbs-key-config/src/lib.rs
+++ b/pbs-key-config/src/lib.rs
@@ -1,5 +1,6 @@
 use std::io::Write;
 use std::path::Path;
+use std::os::fd::AsRawFd;
 
 use anyhow::{bail, format_err, Context, Error};
 use serde::{Deserialize, Serialize};
@@ -254,6 +255,7 @@ impl KeyConfig {
                     .open(path)?;
 
                 file.write_all(data.as_bytes())?;
+                nix::unistd::fsync(file.as_raw_fd())?;
             }
 
             Ok(())
-- 
2.47.3





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-24 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-24 10:04 [PATCH proxmox-backup] pbs-key-config: align fsync behavior when storing new/existing key Christian Ebner
2026-03-24 13:17 ` Fabian Grünbichler
2026-03-24 13:30   ` Christian Ebner

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