aboutsummaryrefslogtreecommitdiff
path: root/src/block/layout.rs
blob: cbc326d8f44816038b8a3cc612adadcf52bb7072 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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";
}