aboutsummaryrefslogtreecommitdiff
path: root/src/block/layout.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-09-04 14:49:49 +0200
committerAlex Auvolat <alex@adnab.me>2023-09-06 16:35:28 +0200
commit71c0188055e25aa1c00d0226f0ca99ce323310a6 (patch)
treee02f35033a601a502672e6c0294e5cc06ff3b563 /src/block/layout.rs
parent4b4f2000f45a83b4dad3f2a8fd8392a245a30286 (diff)
downloadgarage-71c0188055e25aa1c00d0226f0ca99ce323310a6.tar.gz
garage-71c0188055e25aa1c00d0226f0ca99ce323310a6.zip
block manager: skeleton for multi-hdd support
Diffstat (limited to 'src/block/layout.rs')
-rw-r--r--src/block/layout.rs57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/block/layout.rs b/src/block/layout.rs
new file mode 100644
index 00000000..cbc326d8
--- /dev/null
+++ b/src/block/layout.rs
@@ -0,0 +1,57 @@
+use std::path::PathBuf;
+
+use serde::{Deserialize, Serialize};
+
+use garage_util::config::DataDirEnum;
+use garage_util::data::Hash;
+use garage_util::migrate::*;
+
+pub const DRIVE_NPART: usize = 1024;
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub(crate) struct DataLayout {
+ pub(crate) data_dirs: Vec<DataDir>,
+ pub(crate) partitions: Vec<Partition>,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub(crate) struct DataDir {
+ pub(crate) path: PathBuf,
+ pub(crate) state: DataDirState,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub(crate) enum DataDirState {
+ Active { capacity: u64 },
+ ReadOnly,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub(crate) struct Partition {
+ pub(crate) prim: usize,
+ pub(crate) sec: Vec<usize>,
+}
+
+impl DataLayout {
+ pub(crate) fn initialize(dirs: &DataDirEnum) -> Self {
+ todo!()
+ }
+
+ pub(crate) fn update(&mut self, dirs: &DataDirEnum) -> Self {
+ todo!()
+ }
+
+ pub(crate) fn data_dir(&self, hash: &Hash) -> PathBuf {
+ todo!()
+ /*
+ let mut path = self.data_dir.clone();
+ path.push(hex::encode(&hash.as_slice()[0..1]));
+ path.push(hex::encode(&hash.as_slice()[1..2]));
+ path
+ */
+ }
+}
+
+impl InitialFormat for DataLayout {
+ const VERSION_MARKER: &'static [u8] = b"G09bmdl";
+}