mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-14 11:23:44 +00:00
proxmox-rrd: use syncfs after writing rrd files
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
parent
77c2e4668b
commit
336e8f3e7f
@ -12,6 +12,7 @@ proxmox-router = "1.1"
|
|||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
bitflags = "1.2.1"
|
bitflags = "1.2.1"
|
||||||
crossbeam-channel = "0.5"
|
crossbeam-channel = "0.5"
|
||||||
|
libc = "0.2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
nix = "0.19.1"
|
nix = "0.19.1"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
@ -147,6 +147,10 @@ impl RRDCache {
|
|||||||
Ok(JournalEntry { time, value, dst, rel_path })
|
Ok(JournalEntry { time, value, dst, rel_path })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn sync_journal(&self) -> Result<(), Error> {
|
||||||
|
self.state.read().unwrap().sync_journal()
|
||||||
|
}
|
||||||
|
|
||||||
/// Apply and commit the journal. Should be used at server startup.
|
/// Apply and commit the journal. Should be used at server startup.
|
||||||
pub fn apply_journal(&self) -> Result<bool, Error> {
|
pub fn apply_journal(&self) -> Result<bool, Error> {
|
||||||
let state = Arc::clone(&self.state);
|
let state = Arc::clone(&self.state);
|
||||||
@ -387,6 +391,8 @@ fn commit_journal_impl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state.read().unwrap().syncfs()?;
|
||||||
|
|
||||||
if errors != 0 {
|
if errors != 0 {
|
||||||
bail!("errors during rrd flush - unable to commit rrd journal");
|
bail!("errors during rrd flush - unable to commit rrd journal");
|
||||||
}
|
}
|
||||||
|
11
proxmox-rrd/src/cache/journal.rs
vendored
11
proxmox-rrd/src/cache/journal.rs
vendored
@ -3,6 +3,7 @@ use std::path::PathBuf;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::io::{Write, BufReader};
|
use std::io::{Write, BufReader};
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
|
use std::os::unix::io::AsRawFd;
|
||||||
|
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use nix::fcntl::OFlag;
|
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(
|
pub fn append_journal_entry(
|
||||||
&mut self,
|
&mut self,
|
||||||
time: f64,
|
time: f64,
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use anyhow::{bail, format_err, Error};
|
use anyhow::{bail, format_err, Error};
|
||||||
|
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
|
|
||||||
use proxmox::tools::fs::{replace_file, CreateOptions};
|
use proxmox::tools::fs::{replace_file, CreateOptions};
|
||||||
|
Loading…
Reference in New Issue
Block a user