Add some comments in the zpool setup code wrt. adding/removing
disks from zpools
This commit is contained in:
parent
3027ff2f1a
commit
dbe31fd176
1 changed files with 33 additions and 0 deletions
|
@ -145,6 +145,7 @@ struct ZpoolStatus {
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct ZpoolStatusPool {
|
struct ZpoolStatusPool {
|
||||||
state: Option<ZpoolState>,
|
state: Option<ZpoolState>,
|
||||||
|
vdevs: HashMap<String, ZpoolStatusVdev>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Deserialize, PartialEq)]
|
#[derive(Clone, Copy, Deserialize, PartialEq)]
|
||||||
|
@ -153,6 +154,29 @@ enum ZpoolState {
|
||||||
Online,
|
Online,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[serde(tag = "vdev_type")]
|
||||||
|
enum ZpoolStatusVdev {
|
||||||
|
#[serde(rename = "root")]
|
||||||
|
Root {
|
||||||
|
name: String,
|
||||||
|
state: ZpoolState,
|
||||||
|
vdevs: HashMap<String, ZpoolStatusVdev>,
|
||||||
|
},
|
||||||
|
#[serde(rename = "disk")]
|
||||||
|
Disk {
|
||||||
|
name: String,
|
||||||
|
state: ZpoolState,
|
||||||
|
path: PathBuf,
|
||||||
|
},
|
||||||
|
#[serde(rename = "mirror")]
|
||||||
|
Mirror {
|
||||||
|
name: String,
|
||||||
|
state: ZpoolState,
|
||||||
|
vdevs: HashMap<String, ZpoolStatusVdev>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn setup_zpool(p: SetupZpool) -> anyhow::Result<()> {
|
fn setup_zpool(p: SetupZpool) -> anyhow::Result<()> {
|
||||||
let disk_mapping_file = common::env::read_path_env("DISK_MAPPING_FILE")?;
|
let disk_mapping_file = common::env::read_path_env("DISK_MAPPING_FILE")?;
|
||||||
let disk_mapping = common::fs::read_to_string(&disk_mapping_file)?;
|
let disk_mapping = common::fs::read_to_string(&disk_mapping_file)?;
|
||||||
|
@ -185,6 +209,13 @@ fn setup_zpool(p: SetupZpool) -> anyhow::Result<()> {
|
||||||
return Err(anyhow::format_err!("Zpool {} is not online", p.pool_name));
|
return Err(anyhow::format_err!("Zpool {} is not online", p.pool_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Run through the existing VDevs and add any missing vdevs, and add any missing disks
|
||||||
|
// as needed to any vdevs. Not exactly sure how this should be coded, but I guess we can utilize
|
||||||
|
// the fact we cannot really change vdev type beyond turning a disk vdev into a mirror vdev,
|
||||||
|
// and any single disk can only belong to one vdev. So we can simply not support moving disks between vdevs.
|
||||||
|
// Also, to begin with, we can simply not support any vdev other than disk vdevs, as it doesn't make much
|
||||||
|
// sense for my use case.
|
||||||
|
|
||||||
for vdev in p.vdevs.iter() {
|
for vdev in p.vdevs.iter() {
|
||||||
for member in vdev.members.iter() {
|
for member in vdev.members.iter() {
|
||||||
let resolved = disk_mapping.resolve(member)?;
|
let resolved = disk_mapping.resolve(member)?;
|
||||||
|
@ -192,6 +223,8 @@ fn setup_zpool(p: SetupZpool) -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: zpool remove any extra vdevs.
|
||||||
|
|
||||||
let mut existing_datasets = zfs::list_datasets(&p.pool_name)?;
|
let mut existing_datasets = zfs::list_datasets(&p.pool_name)?;
|
||||||
log::info!("Existing datasets found: {existing_datasets:?}");
|
log::info!("Existing datasets found: {existing_datasets:?}");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue