aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/system.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-09-11 19:08:24 +0200
committerAlex Auvolat <alex@adnab.me>2023-09-11 19:08:24 +0200
commitd5bb50d738a5ac9a56ed137263b520b2d4135c29 (patch)
tree79d2d2836aea81c42e04331cec05af333205dd6f /src/rpc/system.rs
parentfc635f7072e1def6e45123cd3abc4d267b555fc3 (diff)
downloadgarage-d5bb50d738a5ac9a56ed137263b520b2d4135c29.tar.gz
garage-d5bb50d738a5ac9a56ed137263b520b2d4135c29.zip
use statvfs instead of mount list to determine free data/meta space (fix #611)
Diffstat (limited to 'src/rpc/system.rs')
-rw-r--r--src/rpc/system.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/rpc/system.rs b/src/rpc/system.rs
index b42e49fc..72ce8de9 100644
--- a/src/rpc/system.rs
+++ b/src/rpc/system.rs
@@ -891,15 +891,14 @@ impl NodeStatus {
}
fn update_disk_usage(&mut self, meta_dir: &Path, data_dir: &Path, metrics: &SystemMetrics) {
- use systemstat::{Platform, System};
- let mounts = System::new().mounts().unwrap_or_default();
-
- let mount_avail = |path: &Path| {
- mounts
- .iter()
- .filter(|x| path.starts_with(&x.fs_mounted_on))
- .max_by_key(|x| x.fs_mounted_on.len())
- .map(|x| (x.avail.as_u64(), x.total.as_u64()))
+ use nix::sys::statvfs::statvfs;
+ let mount_avail = |path: &Path| match statvfs(path) {
+ Ok(x) => {
+ let avail = x.blocks_available() * x.fragment_size();
+ let total = x.blocks() * x.fragment_size();
+ Some((avail, total))
+ }
+ Err(_) => None,
};
self.meta_disk_avail = mount_avail(meta_dir);