Skip to content

Commit

Permalink
WIP expose disk firmware in inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
papertigers committed May 6, 2024
1 parent 472d9f7 commit c356cc6
Show file tree
Hide file tree
Showing 11 changed files with 365 additions and 31 deletions.
21 changes: 18 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ key-manager = { path = "key-manager" }
kstat-rs = "0.2.3"
libc = "0.2.153"
libfalcon = { git = "https://github.com/oxidecomputer/falcon", rev = "e69694a1f7cc9fe31fab27f321017280531fb5f7" }
libnvme = { git = "https://github.com/oxidecomputer/libnvme", rev = "6fffcc81d2c423ed2d2e6c5c2827485554c4ecbe" }
libnvme = { git = "https://github.com/oxidecomputer/libnvme", rev = "0eed4e4929fc2311326646e818e065823ac9a695" }
linear-map = "1.2.0"
macaddr = { version = "1.0.1", features = ["serde_std"] }
maplit = "1.0.2"
Expand Down
2 changes: 1 addition & 1 deletion installinator/src/hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Hardware {
})?;

let disks: Vec<RawDisk> =
hardware.disks().into_iter().map(|disk| disk.into()).collect();
hardware.disks().into_iter().map(|(_, disk)| disk.into()).collect();

info!(
log, "found gimlet hardware";
Expand Down
14 changes: 13 additions & 1 deletion sled-agent/src/hardware_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ impl HardwareMonitor {
.detected_raw_disk_removal(disk.into())
.await;
}
HardwareUpdate::DiskUpdated(disk) => {
// We notify the storage manager of the hardware, but do not need to
// wait for the result to be fully processed.
#[allow(clippy::let_underscore_future)]
let _ = self
.storage_manager
.detected_raw_disk_update(disk.into())
.await;
}
},
Err(broadcast::error::RecvError::Lagged(count)) => {
warn!(self.log, "Hardware monitor missed {count} messages");
Expand Down Expand Up @@ -277,7 +286,10 @@ impl HardwareMonitor {
let _ = self
.storage_manager
.ensure_using_exactly_these_disks(
self.hardware_manager.disks().into_iter().map(RawDisk::from),
self.hardware_manager
.disks()
.into_iter()
.map(|(_, disk)| RawDisk::from(disk)),
)
.await;
}
Expand Down
49 changes: 49 additions & 0 deletions sled-hardware/src/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,46 @@ impl DiskPaths {
}
}

// XXX MTZ: Make this an enum with DiskFirmware::Nvme?
#[derive(
Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd, Deserialize, Serialize,
)]
pub struct DiskFirmware {
active_slot: u8,
next_active_slot: Option<u8>,
slot1_read_only: bool,
slots: Vec<Option<String>>,
}

impl DiskFirmware {
pub fn active_slot(&self) -> u8 {
self.active_slot
}

pub fn next_active_slot(&self) -> Option<u8> {
self.next_active_slot
}

pub fn slot1_read_only(&self) -> bool {
self.slot1_read_only
}

pub fn slots(&self) -> &[Option<String>] {
self.slots.as_slice()
}
}

impl DiskFirmware {
pub fn new(
active_slot: u8,
next_active_slot: Option<u8>,
slot1_read_only: bool,
slots: Vec<Option<String>>,
) -> Self {
Self { active_slot, next_active_slot, slot1_read_only, slots }
}
}

/// A disk which has been observed by monitoring hardware.
///
/// No guarantees are made about the partitions which exist within this disk.
Expand All @@ -147,6 +187,7 @@ pub struct UnparsedDisk {
variant: DiskVariant,
identity: DiskIdentity,
is_boot_disk: bool,
firmware: DiskFirmware,
}

impl UnparsedDisk {
Expand All @@ -157,13 +198,15 @@ impl UnparsedDisk {
variant: DiskVariant,
identity: DiskIdentity,
is_boot_disk: bool,
firmware: DiskFirmware,
) -> Self {
Self {
paths: DiskPaths { devfs_path, dev_path },
slot,
variant,
identity,
is_boot_disk,
firmware,
}
}

Expand All @@ -190,6 +233,10 @@ impl UnparsedDisk {
pub fn slot(&self) -> i64 {
self.slot
}

pub fn firmware(&self) -> &DiskFirmware {
&self.firmware
}
}

/// A physical disk that is partitioned to contain exactly one zpool
Expand All @@ -212,6 +259,7 @@ pub struct PooledDisk {
// This embeds the assumtion that there is exactly one parsed zpool per
// disk.
pub zpool_name: ZpoolName,
pub firmware: DiskFirmware,
}

impl PooledDisk {
Expand Down Expand Up @@ -252,6 +300,7 @@ impl PooledDisk {
is_boot_disk: unparsed_disk.is_boot_disk,
partitions,
zpool_name,
firmware: unparsed_disk.firmware,
})
}
}
Expand Down
Loading

0 comments on commit c356cc6

Please sign in to comment.