diff options
author | Alex Auvolat <alex@adnab.me> | 2023-09-04 14:49:49 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-09-06 16:35:28 +0200 |
commit | 71c0188055e25aa1c00d0226f0ca99ce323310a6 (patch) | |
tree | e02f35033a601a502672e6c0294e5cc06ff3b563 /src/rpc | |
parent | 4b4f2000f45a83b4dad3f2a8fd8392a245a30286 (diff) | |
download | garage-71c0188055e25aa1c00d0226f0ca99ce323310a6.tar.gz garage-71c0188055e25aa1c00d0226f0ca99ce323310a6.zip |
block manager: skeleton for multi-hdd support
Diffstat (limited to 'src/rpc')
-rw-r--r-- | src/rpc/system.rs | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/rpc/system.rs b/src/rpc/system.rs index 1675e70e..c5751d5d 100644 --- a/src/rpc/system.rs +++ b/src/rpc/system.rs @@ -22,9 +22,9 @@ use netapp::peering::fullmesh::FullMeshPeeringStrategy; use netapp::util::parse_and_resolve_peer_addr_async; use netapp::{NetApp, NetworkKey, NodeID, NodeKey}; -use garage_util::config::Config; #[cfg(feature = "kubernetes-discovery")] use garage_util::config::KubernetesDiscoveryConfig; +use garage_util::config::{Config, DataDirEnum}; use garage_util::data::*; use garage_util::error::*; use garage_util::persister::Persister; @@ -119,7 +119,7 @@ pub struct System { /// Path to metadata directory pub metadata_dir: PathBuf, /// Path to data directory - pub data_dir: PathBuf, + pub data_dir: DataDirEnum, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -890,7 +890,12 @@ impl NodeStatus { } } - fn update_disk_usage(&mut self, meta_dir: &Path, data_dir: &Path, metrics: &SystemMetrics) { + fn update_disk_usage( + &mut self, + meta_dir: &Path, + data_dir: &DataDirEnum, + metrics: &SystemMetrics, + ) { use systemstat::{Platform, System}; let mounts = System::new().mounts().unwrap_or_default(); @@ -903,7 +908,17 @@ impl NodeStatus { }; self.meta_disk_avail = mount_avail(meta_dir); - self.data_disk_avail = mount_avail(data_dir); + self.data_disk_avail = match data_dir { + DataDirEnum::Single(dir) => mount_avail(dir), + DataDirEnum::Multiple(dirs) => { + dirs.iter() + .map(|d| mount_avail(&d.path)) + .fold(Some((0, 0)), |acc, cur| match (acc, cur) { + (Some((x, y)), Some((a, b))) => Some((x + a, y + b)), + _ => None, + }) + } + }; if let Some((avail, total)) = self.meta_disk_avail { metrics |