From: Christian Ebner <c.ebner@proxmox.com>
To: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>,
pbs-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox-backup] pbs-key-config: align fsync behavior when storing new/existing key
Date: Tue, 24 Mar 2026 14:30:03 +0100 [thread overview]
Message-ID: <a2a81d62-0183-47a9-961d-caa6199bb1d4@proxmox.com> (raw)
In-Reply-To: <1774358207.bh0j523o7r.astroid@yuna.none>
On 3/24/26 2:16 PM, Fabian Grünbichler wrote:
> On March 24, 2026 11:04 am, Christian Ebner wrote:
>> 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())?;
>
> LGTM in principle, though we could also switch to
> atomic_open_or_create_file ?
Had a look at that as well, that would however create a tempfile first.
And since we do already have the open file descriptor here and handle
failure on per-existing files here as expected (which would require
adding `OFlag::O_EXCL` in the other case), I did not consider this
further, simply calling fsync seemed the better option for this
particular case.
prev parent reply other threads:[~2026-03-24 13:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 10:04 Christian Ebner
2026-03-24 13:17 ` Fabian Grünbichler
2026-03-24 13:30 ` Christian Ebner [this message]
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=a2a81d62-0183-47a9-961d-caa6199bb1d4@proxmox.com \
--to=c.ebner@proxmox.com \
--cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox