proxmox-rrd: use syncfs after writing rrd files

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dietmar Maurer
2021-10-18 13:45:30 +02:00
parent bd10af6eda
commit 98eb435d90
6 changed files with 31 additions and 2 deletions

View File

@ -3,6 +3,7 @@ use std::path::PathBuf;
use std::sync::Arc;
use std::io::{Write, BufReader};
use std::ffi::OsStr;
use std::os::unix::io::AsRawFd;
use anyhow::Error;
use nix::fcntl::OFlag;
@ -50,6 +51,16 @@ impl JournalState {
})
}
pub fn sync_journal(&self) -> Result<(), Error> {
nix::unistd::fdatasync(self.journal.as_raw_fd())?;
Ok(())
}
pub fn syncfs(&self) -> Result<(), nix::Error> {
let res = unsafe { libc::syncfs(self.journal.as_raw_fd()) };
nix::errno::Errno::result(res).map(drop)
}
pub fn append_journal_entry(
&mut self,
time: f64,