Skip to content

Commit

Permalink
Zone bundler
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed Jun 28, 2024
1 parent 83c7cdf commit 6869d92
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sled-agent/src/long_running_tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct LongRunningTaskHandles {
/// for establishing zpools on disks and managing their datasets.
pub storage_manager: StorageHandle,

/// A mehcanism for talking to the [`StorageMonitor`], which reacts to disk
/// A mechanism for talking to the [`StorageMonitor`], which reacts to disk
/// changes and updates the dump devices.
pub storage_monitor_handle: StorageMonitorHandle,

Expand Down
5 changes: 4 additions & 1 deletion sled-agent/src/sled_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,10 @@ impl SledAgent {
// to start using new disks and stop using old ones.
self.inner.storage_monitor.await_generation(*our_gen).await?;

// - TODO: Update Zone bundles?
// Ensure that the ZoneBundler, if it was creating a bundle referencing
// the old U.2s, has stopped using them.
self.inner.zone_bundler.await_completion_of_prior_bundles().await;

// - TODO: Mark probes failed?
// - TODO: Mark instances failed?

Expand Down
15 changes: 15 additions & 0 deletions sled-agent/src/zone_bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ impl Inner {
// exist; and returns those.
async fn bundle_directories(&self) -> Vec<Utf8PathBuf> {
let resources = self.storage_handle.get_latest_disks().await;
// NOTE: These bundle directories are always stored on M.2s, so we don't
// need to worry about synchronizing with U.2 disk expungement at the
// callsite.
let expected = resources.all_zone_bundle_directories();
let mut out = Vec::with_capacity(expected.len());
for each in expected.into_iter() {
Expand Down Expand Up @@ -426,6 +429,10 @@ impl ZoneBundler {
zone: &RunningZone,
cause: ZoneBundleCause,
) -> Result<ZoneBundleMetadata, BundleError> {
// NOTE: [Self::await_completion_of_prior_bundles] relies on this lock
// being held across this whole function. If we want more concurrency,
// we'll need to add a barrier-like mechanism to let callers know when
// prior bundles have completed.
let inner = self.inner.lock().await;
let storage_dirs = inner.bundle_directories().await;
let resources = inner.storage_handle.get_latest_disks().await;
Expand All @@ -443,6 +450,14 @@ impl ZoneBundler {
create(&self.log, zone, &context).await
}

/// Awaits the completion of all prior calls to [ZoneBundler::create].
///
/// This is critical for disk expungement, which wants to ensure that the
/// Sled Agent is no longer using devices after they have been expunged.
pub async fn await_completion_of_prior_bundles(&self) {
let _ = self.inner.lock().await;
}

/// Return the paths for all bundles of the provided zone and ID.
pub async fn bundle_paths(
&self,
Expand Down

0 comments on commit 6869d92

Please sign in to comment.