diff --git a/agent-antagonist/Cargo.toml b/agent-antagonist/Cargo.toml index 41096ca77..e6423666b 100644 --- a/agent-antagonist/Cargo.toml +++ b/agent-antagonist/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "agent-antagonist" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/agent-antagonist/src/main.rs b/agent-antagonist/src/main.rs index a33eeb29e..92dac1078 100644 --- a/agent-antagonist/src/main.rs +++ b/agent-antagonist/src/main.rs @@ -1,5 +1,5 @@ -use anyhow::bail; use anyhow::Result; +use anyhow::bail; use clap::Parser; use crucible_common::build_logger; use futures::StreamExt; @@ -11,14 +11,14 @@ use slog::{info, warn}; use std::net::SocketAddr; use std::process::Command; use std::sync::{ - atomic::{AtomicBool, Ordering}, Arc, + atomic::{AtomicBool, Ordering}, }; use uuid::Uuid; use crucible_agent_client::{ - types::{CreateRegion, RegionId, State as RegionState}, Client as CrucibleAgentClient, + types::{CreateRegion, RegionId, State as RegionState}, }; #[derive(Debug, Parser)] diff --git a/agent-client/Cargo.toml b/agent-client/Cargo.toml index 68a801c3d..4a729f976 100644 --- a/agent-client/Cargo.toml +++ b/agent-client/Cargo.toml @@ -2,7 +2,7 @@ name = "crucible-agent-client" version = "0.0.1" license = "MPL-2.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/agent/Cargo.toml b/agent/Cargo.toml index bafc4e2e3..41fb206e3 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -2,7 +2,7 @@ name = "crucible-agent" version = "0.0.1" license = "MPL-2.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/agent/src/datafile.rs b/agent/src/datafile.rs index 5ef0faa0d..d3bbb8d12 100644 --- a/agent/src/datafile.rs +++ b/agent/src/datafile.rs @@ -1,19 +1,19 @@ // Copyright 2021 Oxide Computer Company -use anyhow::{anyhow, bail, Result}; +use anyhow::{Result, anyhow, bail}; use crucible_agent_types::{region::*, snapshot::*}; use crucible_common::write_json; use serde::{Deserialize, Serialize}; -use slog::{crit, error, info, Logger}; +use slog::{Logger, crit, error, info}; use std::collections::BTreeMap; use std::net::SocketAddr; use std::path::Path; use std::path::PathBuf; use std::sync::{Arc, Condvar, Mutex, MutexGuard}; +use crate::ZFSDataset; use crate::resource::Resource; use crate::snapshot_interface::SnapshotInterface; -use crate::ZFSDataset; pub struct DataFile { log: Logger, @@ -434,31 +434,29 @@ impl DataFile { */ if let Some(running_snapshots) = inner.running_snapshots.get(&request.id) + && let Some(running_snapshot) = running_snapshots.get(&request.name) { - if let Some(running_snapshot) = running_snapshots.get(&request.name) - { - match running_snapshot.state { - State::Requested | State::Created | State::Tombstoned => { - bail!( - "read-only downstairs running for region {} snapshot {}", - request.id.0, - request.name - ); - } + match running_snapshot.state { + State::Requested | State::Created | State::Tombstoned => { + bail!( + "read-only downstairs running for region {} snapshot {}", + request.id.0, + request.name + ); + } - State::Destroyed => { - // ok to delete - } + State::Destroyed => { + // ok to delete + } - State::Failed => { - // Something has set the running snapshot to state - // failed, so we can't delete this snapshot. - bail!( - "read-only downstairs state set to failed for region {} snapshot {}", - request.id.0, - request.name - ); - } + State::Failed => { + // Something has set the running snapshot to state + // failed, so we can't delete this snapshot. + bail!( + "read-only downstairs state set to failed for region {} snapshot {}", + request.id.0, + request.name + ); } } } @@ -489,7 +487,10 @@ impl DataFile { // This is a bug: according to the agent's datafile, // the region exists, but according to zfs list, it // does not - bail!("Agent thinks region {} exists but zfs list does not! {e}", request.id.0); + bail!( + "Agent thinks region {} exists but zfs list does not! {e}", + request.id.0 + ); } State::Failed => { @@ -503,7 +504,11 @@ impl DataFile { } } else { // In here, the region never existed! - bail!("Inside region {} snapshot {} delete, region never existed! {e}", request.id.0, request.name); + bail!( + "Inside region {} snapshot {} delete, region never existed! {e}", + request.id.0, + request.name + ); } } }; @@ -863,7 +868,7 @@ impl DataFile { #[cfg(test)] mod test { - use anyhow::{bail, Result}; + use anyhow::{Result, bail}; use chrono::{DateTime, TimeZone, Utc}; use std::process::Command; @@ -901,9 +906,8 @@ mod test { let cmd_stdout = String::from_utf8_lossy(&cmd.stdout); // Remove newline - let cmd_stdout = cmd_stdout.trim_end().to_string(); - cmd_stdout + cmd_stdout.trim_end().to_string() }; let _date = Utc.timestamp_opt(cmd_stdout.parse()?, 0).unwrap(); diff --git a/agent/src/main.rs b/agent/src/main.rs index 6d0c48ae7..666a081d2 100644 --- a/agent/src/main.rs +++ b/agent/src/main.rs @@ -1,10 +1,10 @@ // Copyright 2021 Oxide Computer Company -use anyhow::{anyhow, bail, Result}; +use anyhow::{Result, anyhow, bail}; use clap::Parser; use crucible_agent_types::smf::SmfProperty; use dropshot::{ConfigLogging, ConfigLoggingIfExists, ConfigLoggingLevel}; -use slog::{debug, error, info, o, Logger}; +use slog::{Logger, debug, error, info, o}; use std::collections::HashSet; use std::net::SocketAddr; use std::path::{Path, PathBuf}; @@ -1195,7 +1195,7 @@ mod test { use crate::snapshot_interface::TestSnapshotInterface; use crucible_agent_types::{region::*, snapshot::*}; - use slog::{o, Drain, Logger}; + use slog::{Drain, Logger, o}; use std::collections::BTreeMap; use tempfile::*; use uuid::Uuid; diff --git a/agent/src/server.rs b/agent/src/server.rs index 397816d0f..9984b03b0 100644 --- a/agent/src/server.rs +++ b/agent/src/server.rs @@ -1,6 +1,6 @@ // Copyright 2024 Oxide Computer Company use super::datafile::DataFile; -use anyhow::{anyhow, Result}; +use anyhow::{Result, anyhow}; use crucible_agent_api::*; use crucible_agent_types::{region, snapshot}; use dropshot::{ @@ -8,7 +8,7 @@ use dropshot::{ HttpResponseDeleted, HttpResponseOk, Path as TypedPath, RequestContext, TypedBody, VersionPolicy, }; -use slog::{o, Logger}; +use slog::{Logger, o}; use std::net::SocketAddr; use std::result::Result as SResult; use std::sync::Arc; diff --git a/agent/src/snapshot_interface.rs b/agent/src/snapshot_interface.rs index 4b3c1e1e0..9053d4383 100644 --- a/agent/src/snapshot_interface.rs +++ b/agent/src/snapshot_interface.rs @@ -1,8 +1,8 @@ // Copyright 2023 Oxide Computer Company -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use crucible_agent_types::snapshot::Snapshot; -use slog::{error, info, Logger}; +use slog::{Logger, error, info}; #[cfg(test)] use std::collections::HashSet; use std::process::Command; @@ -113,9 +113,8 @@ impl SnapshotInterface for ZfsSnapshotInterface { let cmd_stdout = String::from_utf8_lossy(&cmd.stdout); // Remove newline - let cmd_stdout = cmd_stdout.trim_end().to_string(); - cmd_stdout + cmd_stdout.trim_end().to_string() }; if !cmd.status.success() { diff --git a/cmon/Cargo.toml b/cmon/Cargo.toml index adfb21c48..8b30a5ad0 100644 --- a/cmon/Cargo.toml +++ b/cmon/Cargo.toml @@ -2,7 +2,7 @@ name = "cmon" version = "0.1.0" license = "MPL-2.0" -edition = "2021" +edition = "2024" [dependencies] clap.workspace = true diff --git a/cmon/src/main.rs b/cmon/src/main.rs index 3d2c44a9d..bcf3987da 100644 --- a/cmon/src/main.rs +++ b/cmon/src/main.rs @@ -6,7 +6,7 @@ use std::fmt; use std::io::{self, BufRead}; use strum::IntoEnumIterator; use strum_macros::EnumIter; -use tokio::time::{sleep, Duration}; +use tokio::time::{Duration, sleep}; use crucible::DtraceInfo; diff --git a/common/Cargo.toml b/common/Cargo.toml index 9f1d2f520..8267ec8bb 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -3,7 +3,7 @@ name = "crucible-common" version = "0.0.1" authors = ["Joshua M. Clulow ", "Alan Hanson "] license = "MPL-2.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/common/src/impacted_blocks.rs b/common/src/impacted_blocks.rs index 8bf4fe937..e5389cf40 100644 --- a/common/src/impacted_blocks.rs +++ b/common/src/impacted_blocks.rs @@ -135,7 +135,7 @@ impl ImpactedBlocks { pub fn extents( &self, ddef: &RegionDefinition, - ) -> impl Iterator { + ) -> impl Iterator + use<'_> { let blocks_per_extent = ddef.extent_size().value; match self { ImpactedBlocks::Empty => None, /* empty range */ @@ -222,7 +222,7 @@ mod test { use proptest::prelude::*; use std::panic; use std::panic::UnwindSafe; - use test_strategy::{proptest, Arbitrary}; + use test_strategy::{Arbitrary, proptest}; fn basic_region_definition( extent_size: u32, @@ -574,8 +574,8 @@ mod test { /// Generate a random region definition, and a single ImpactedBlocks range /// within it. - fn region_and_impacted_blocks_strategy( - ) -> impl Strategy { + fn region_and_impacted_blocks_strategy() + -> impl Strategy { any::<(ArbitraryRegionDefinition, ArbitraryImpactedBlocks)>().prop_map( |(test_ddef, test_iblocks)| { let ddef = reify_region_definition(test_ddef); diff --git a/common/src/lib.rs b/common/src/lib.rs index 826485a86..9aa5f8edc 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -7,7 +7,7 @@ use std::path::Path; use ErrorKind::NotFound; -use anyhow::{anyhow, bail, Context, Result}; +use anyhow::{Context, Result, anyhow, bail}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use slog::Drain; @@ -16,9 +16,9 @@ use tokio::time::Duration; mod region; pub use region::{ - config_path, Block, BlockIndex, BlockOffset, ExtentId, RegionDefinition, - RegionOptions, DATABASE_READ_VERSION, DATABASE_WRITE_VERSION, - MAX_BLOCK_SIZE, MAX_SHIFT, MIN_BLOCK_SIZE, MIN_SHIFT, + Block, BlockIndex, BlockOffset, DATABASE_READ_VERSION, + DATABASE_WRITE_VERSION, ExtentId, MAX_BLOCK_SIZE, MAX_SHIFT, + MIN_BLOCK_SIZE, MIN_SHIFT, RegionDefinition, RegionOptions, config_path, }; pub mod impacted_blocks; @@ -225,9 +225,7 @@ pub enum NegotiationError { )] EncryptionMismatch { expected: bool, actual: bool }, - #[error( - "Incompatible read-only settings: wanted {expected}, got {actual}" - )] + #[error("Incompatible read-only settings: wanted {expected}, got {actual}")] ReadOnlyMismatch { expected: bool, actual: bool }, #[error("Incompatible upstairs ID: wanted {expected}, got {actual}")] diff --git a/common/src/region.rs b/common/src/region.rs index 2f8532681..7bdf2bbd1 100644 --- a/common/src/region.rs +++ b/common/src/region.rs @@ -1,5 +1,5 @@ // Copyright 2021 Oxide Computer Company -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; diff --git a/control-client/Cargo.toml b/control-client/Cargo.toml index 0bd3aed41..00828c3ec 100644 --- a/control-client/Cargo.toml +++ b/control-client/Cargo.toml @@ -2,7 +2,7 @@ name = "crucible-control-client" version = "0.0.1" license = "MPL-2.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/crucible-client-types/Cargo.toml b/crucible-client-types/Cargo.toml index 6394e3af0..a39499da2 100644 --- a/crucible-client-types/Cargo.toml +++ b/crucible-client-types/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "crucible-client-types" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] base64.workspace = true diff --git a/crucible-client-types/src/lib.rs b/crucible-client-types/src/lib.rs index c0158c385..254346677 100644 --- a/crucible-client-types/src/lib.rs +++ b/crucible-client-types/src/lib.rs @@ -1,6 +1,6 @@ // Copyright 2022 Oxide Computer Company -use base64::{engine, Engine}; +use base64::{Engine, engine}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::fmt; @@ -29,7 +29,8 @@ pub enum VolumeConstructionRequest { blocks_per_extent: u64, extent_count: u32, opts: CrucibleOpts, - gen: u64, + #[serde(rename = "gen")] + generation: u64, }, File { id: Uuid, diff --git a/crudd/Cargo.toml b/crudd/Cargo.toml index 134b22404..25d1759b9 100644 --- a/crudd/Cargo.toml +++ b/crudd/Cargo.toml @@ -3,7 +3,7 @@ name = "crudd" version = "0.1.0" authors = ["Artemis Everfree "] license = "MPL-2.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/crudd/src/main.rs b/crudd/src/main.rs index 1e3f5988c..5f36560de 100644 --- a/crudd/src/main.rs +++ b/crudd/src/main.rs @@ -8,7 +8,7 @@ use std::os::unix::io::FromRawFd; use std::sync::Arc; use std::{cmp, io}; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::Parser; use futures::stream::StreamExt; use itertools::Itertools; @@ -41,7 +41,7 @@ pub struct Opt { /// Generation #[clap(short, long, default_value = "0", action)] - gen: u64, + generation: u64, /// TLS certificate #[clap(long, action)] @@ -564,7 +564,7 @@ async fn main() -> Result<()> { let (guest, io) = Guest::new(None); let guest = Arc::new(guest); - let _join_handle = up_main(crucible_opts, opt.gen, None, io, None)?; + let _join_handle = up_main(crucible_opts, opt.generation, None, io, None)?; eprintln!("Crucible runtime is spawned"); // IO time @@ -596,7 +596,10 @@ async fn main() -> Result<()> { } } Err(e) => { - eprintln!("Encountered error while performing IO: {}. gracefully cleaning up.", e); + eprintln!( + "Encountered error while performing IO: {}. gracefully cleaning up.", + e + ); } }; diff --git a/crutest/Cargo.toml b/crutest/Cargo.toml index a0aac6a7b..9316c3850 100644 --- a/crutest/Cargo.toml +++ b/crutest/Cargo.toml @@ -3,7 +3,7 @@ name = "crutest" version = "0.1.0" authors = ["Joshua M. Clulow ", "Alan Hanson , ) -> Result<()> { match cmd { - CliCommand::Activate { gen } => { - fw.send(CliMessage::Activate(gen)).await?; + CliCommand::Activate { generation } => { + fw.send(CliMessage::Activate(generation)).await?; } - CliCommand::ActivateRequest { gen } => { - fw.send(CliMessage::ActivateRequest(gen)).await?; + CliCommand::ActivateRequest { generation } => { + fw.send(CliMessage::ActivateRequest(generation)).await?; } CliCommand::Commit => { fw.send(CliMessage::Commit).await?; @@ -742,16 +742,16 @@ async fn process_cli_command( verify_output: Option, ) -> Result<()> { match cmd { - CliMessage::Activate(gen) => { - match volume.activate_with_gen(gen).await { + CliMessage::Activate(generation) => { + match volume.activate_with_gen(generation).await { Ok(_) => fw.send(CliMessage::DoneOk).await, Err(e) => fw.send(CliMessage::Error(e)).await, } } - CliMessage::ActivateRequest(gen) => { + CliMessage::ActivateRequest(generation) => { let gc = volume.clone(); let _handle = tokio::spawn(async move { - match gc.activate_with_gen(gen).await { + match gc.activate_with_gen(generation).await { Ok(_) => { println!("Activate Successful"); } @@ -901,12 +901,9 @@ async fn process_cli_command( * seems like once we go active we won't need to run * it again. */ - if !*wc_filled { - if let Some(vi) = verify_input { - load_write_log(volume, &mut new_di, vi, false) - .await?; - *wc_filled = true; - } + if !*wc_filled && let Some(vi) = verify_input { + load_write_log(volume, &mut new_di, vi, false).await?; + *wc_filled = true; } *di_option = Some(new_di.clone()); fw.send(CliMessage::Info(new_di.volume_info)).await diff --git a/crutest/src/main.rs b/crutest/src/main.rs index 9fcbbe539..24e5990b8 100644 --- a/crutest/src/main.rs +++ b/crutest/src/main.rs @@ -1,9 +1,9 @@ // Copyright 2023 Oxide Computer Company -use anyhow::{anyhow, bail, Result}; +use anyhow::{Result, anyhow, bail}; use bytes::Bytes; use clap::Parser; -use futures::stream::FuturesOrdered; use futures::StreamExt; +use futures::stream::FuturesOrdered; use human_bytes::human_bytes; use indicatif::{ProgressBar, ProgressStyle}; use oximeter::types::ProducerRegistry; @@ -12,15 +12,15 @@ use rand_chacha::rand_core::SeedableRng; use serde::{Deserialize, Serialize}; use signal_hook::consts::signal::*; use signal_hook_tokio::Signals; -use slog::{info, o, warn, Logger}; +use slog::{Logger, info, o, warn}; use std::fmt; use std::io::Write; use std::net::{IpAddr, SocketAddr}; use std::num::NonZeroU64; use std::path::PathBuf; use std::sync::{ - atomic::{AtomicBool, AtomicUsize, Ordering}, Arc, + atomic::{AtomicBool, AtomicUsize, Ordering}, }; use tokio::sync::mpsc; use tokio::time::{Duration, Instant}; @@ -36,7 +36,7 @@ use crucible::volume::{VolumeBuilder, VolumeInfo}; use crucible::*; use crucible_client_types::RegionExtentInfo; use crucible_protocol::CRUCIBLE_MESSAGE_VERSION; -use dsc_client::{types::DownstairsState, Client}; +use dsc_client::{Client, types::DownstairsState}; use repair_client::Client as repair_client; /* @@ -175,7 +175,7 @@ pub struct Opt { flush_timeout: Option, #[clap(short, global = true, long, default_value_t = 0, action)] - gen: u64, + generation: u64, /// The key for an encrypted downstairs. #[clap(short, global = true, long, action)] @@ -670,10 +670,8 @@ async fn load_write_log( /* * Only verify the volume if requested. */ - if verify { - if let Err(e) = verify_volume(volume, di, false).await { - bail!("Initial volume verify failed: {:?}", e) - } + if verify && let Err(e) = verify_volume(volume, di, false).await { + bail!("Initial volume verify failed: {:?}", e) } Ok(()) } @@ -766,7 +764,7 @@ async fn make_a_volume( }; info!(test_log, "Using VCR: {:?}", vcr); - if opt.gen != 0 { + if opt.generation != 0 { warn!(test_log, "gen option is ignored when VCR is provided"); } if !opt.target.is_empty() { @@ -845,7 +843,7 @@ async fn make_a_volume( .add_subvolume_create_guest( crucible_opts.clone(), extent_info.clone(), - opt.gen, + opt.generation, pr.clone(), ) .await @@ -903,7 +901,7 @@ async fn make_a_volume( .add_subvolume_create_guest( crucible_opts.clone(), extent_info, - opt.gen, + opt.generation, pr, ) .await @@ -1015,13 +1013,13 @@ async fn main() -> Result<()> { } if opt.retry_activate { - while let Err(e) = volume.activate_with_gen(opt.gen).await { + while let Err(e) = volume.activate_with_gen(opt.generation).await { println!("Activate returns: {:#} Retrying", e); tokio::time::sleep(tokio::time::Duration::from_secs(2)).await; } println!("Activate successful"); } else { - volume.activate_with_gen(opt.gen).await?; + volume.activate_with_gen(opt.generation).await?; } println!("Wait for a query_work_queue command to finish before sending IO"); @@ -1111,7 +1109,7 @@ async fn main() -> Result<()> { */ let count = opt.count.unwrap_or(5); println!("Run deactivate test"); - deactivate_workload(&volume, count, &mut disk_info, opt.gen) + deactivate_workload(&volume, count, &mut disk_info, opt.generation) .await?; } Workload::Demo => { @@ -1359,7 +1357,7 @@ async fn main() -> Result<()> { &mut disk_info, targets, dsc_client, - opt.gen, + opt.generation, test_log, ) .await?; @@ -1405,7 +1403,7 @@ async fn main() -> Result<()> { &mut disk_info, targets, dsc_client, - opt.gen, + opt.generation, test_log, ) .await?; @@ -1477,10 +1475,10 @@ async fn main() -> Result<()> { } } - if opt.verify_at_end { - if let Err(e) = verify_volume(&volume, &mut disk_info, false).await { - bail!("Final volume verify failed: {:?}", e) - } + if opt.verify_at_end + && let Err(e) = verify_volume(&volume, &mut disk_info, false).await + { + bail!("Final volume verify failed: {:?}", e) } if let Some(vo) = &opt.verify_out { @@ -2355,7 +2353,8 @@ async fn yolo_workload( // this is an error. if !range { eprintln!( - "Verify Error out of range at {block_index} len:{data_len}"); + "Verify Error out of range at {block_index} len:{data_len}" + ); verify_errors += 1; } } @@ -2494,7 +2493,7 @@ async fn replace_while_reconcile( di: &mut DiskInfo, targets: Vec, dsc_client: Client, - mut gen: u64, + mut generation: u64, log: Logger, ) -> Result<()> { assert!(targets.len() % 3 == 1); @@ -2555,10 +2554,10 @@ async fn replace_while_reconcile( info!(log, "[{c}] Request the upstairs activate"); // Spawn a task to re-activate, this will not finish till all three // downstairs have reconciled. - gen += 1; + generation += 1; let gc = volume.clone(); let handle = - tokio::spawn(async move { gc.activate_with_gen(gen).await }); + tokio::spawn(async move { gc.activate_with_gen(generation).await }); info!(log, "[{c}] wait {active_wait} for reconcile to start"); tokio::time::sleep(tokio::time::Duration::from_secs(active_wait)).await; @@ -2691,7 +2690,7 @@ async fn replace_before_active( di: &mut DiskInfo, targets: Vec, dsc_client: Client, - mut gen: u64, + mut generation: u64, log: Logger, ) -> Result<()> { assert!(targets.len() % 3 == 1); @@ -2734,10 +2733,10 @@ async fn replace_before_active( info!(log, "[{c}] Request the upstairs activate"); // Spawn a task to re-activate, this will not finish till all three // downstairs respond. - gen += 1; + generation += 1; let gc = volume.clone(); let handle = - tokio::spawn(async move { gc.activate_with_gen(gen).await }); + tokio::spawn(async move { gc.activate_with_gen(generation).await }); // Give the activation request time to percolate in the upstairs. tokio::time::sleep(tokio::time::Duration::from_secs(4)).await; @@ -2925,11 +2924,11 @@ async fn replace_workload( break; } // See (if provided) we have reached a requested number of loops - if let Some(stop_at) = stop_at { - if c >= stop_at { - println!("[{c}] Replace task ends as count was reached"); - break; - } + if let Some(stop_at) = stop_at + && c >= stop_at + { + println!("[{c}] Replace task ends as count was reached"); + break; } // No stopping yet, let's do another loop. @@ -3449,7 +3448,7 @@ async fn deactivate_workload( volume: &Volume, count: usize, di: &mut DiskInfo, - mut gen: u64, + mut generation: u64, ) -> Result<()> { let count_width = count.to_string().len(); for c in 1..=count { @@ -3490,8 +3489,8 @@ async fn deactivate_workload( width = count_width ); let mut retry = 1; - gen += 1; - while let Err(e) = volume.activate_with_gen(gen).await { + generation += 1; + while let Err(e) = volume.activate_with_gen(generation).await { println!( "{:>0width$}/{:>0width$}, Retry:{} activate {:?}", c, diff --git a/crutest/src/stats.rs b/crutest/src/stats.rs index de7947804..7375b054c 100644 --- a/crutest/src/stats.rs +++ b/crutest/src/stats.rs @@ -1,6 +1,6 @@ // Copyright 2024 Oxide Computer Company -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use omicron_common::api::internal::nexus::ProducerEndpoint; use omicron_common::api::internal::nexus::ProducerKind; use oximeter_producer::{ diff --git a/downstairs-api/Cargo.toml b/downstairs-api/Cargo.toml index 45a5ea008..6c56edfbe 100644 --- a/downstairs-api/Cargo.toml +++ b/downstairs-api/Cargo.toml @@ -2,8 +2,8 @@ name = "crucible-downstairs-api" version = "0.1.0" license = "MPL-2.0" -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" [dependencies] crucible-common.workspace = true diff --git a/downstairs-types/Cargo.toml b/downstairs-types/Cargo.toml index 915949933..df7e62b62 100644 --- a/downstairs-types/Cargo.toml +++ b/downstairs-types/Cargo.toml @@ -2,8 +2,8 @@ name = "crucible-downstairs-types" version = "0.1.0" license = "MPL-2.0" -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" [dependencies] crucible-common.workspace = true diff --git a/downstairs/Cargo.toml b/downstairs/Cargo.toml index be1cc5da4..f8425beb0 100644 --- a/downstairs/Cargo.toml +++ b/downstairs/Cargo.toml @@ -3,8 +3,8 @@ name = "crucible-downstairs" version = "0.0.1" authors = ["Joshua M. Clulow ", "Alan Hanson Result<(u64, u64, bool), CrucibleError> { - let gen = self.inner.gen_number().unwrap(); + let generation = self.inner.gen_number().unwrap(); let flush = self.inner.flush_number().unwrap(); let dirty = self.inner.dirty().unwrap(); - Ok((gen, flush, dirty)) + Ok((generation, flush, dirty)) } /// Validates the extent data diff --git a/downstairs/src/extent_inner_raw.rs b/downstairs/src/extent_inner_raw.rs index b67e1bce6..fa3c04fbe 100644 --- a/downstairs/src/extent_inner_raw.rs +++ b/downstairs/src/extent_inner_raw.rs @@ -1,23 +1,22 @@ // Copyright 2023 Oxide Computer Company use crate::{ - cdt, + Block, CrucibleError, ExtentReadRequest, ExtentReadResponse, ExtentWrite, + JobId, RegionDefinition, cdt, extent::{ - check_input, extent_path, DownstairsBlockContext, ExtentInner, - EXTENT_META_RAW, + DownstairsBlockContext, EXTENT_META_RAW, ExtentInner, check_input, + extent_path, }, extent_inner_raw_common::{ - pread_all, pwrite_all, OnDiskMeta, BLOCK_META_SIZE_BYTES, + BLOCK_META_SIZE_BYTES, OnDiskMeta, pread_all, pwrite_all, }, integrity_hash, mkdir_for_file, region::JobOrReconciliationId, - Block, CrucibleError, ExtentReadRequest, ExtentReadResponse, ExtentWrite, - JobId, RegionDefinition, }; use crucible_common::ExtentId; use crucible_protocol::ReadBlockContext; use itertools::Itertools; -use slog::{error, Logger}; +use slog::{Logger, error}; use std::collections::HashSet; use std::fs::{File, OpenOptions}; @@ -27,7 +26,7 @@ use std::path::Path; // Re-exports pub use crucible_raw_extent::{ - OnDiskDownstairsBlockContext, BLOCK_CONTEXT_SLOT_SIZE_BYTES, + BLOCK_CONTEXT_SLOT_SIZE_BYTES, OnDiskDownstairsBlockContext, }; /// Number of extra syscalls per read / write that triggers defragmentation @@ -697,7 +696,7 @@ impl RawInner { layout.write_context_slots_contiguous( file, 0, - std::iter::repeat(None).take(block_count), + std::iter::repeat_n(None, block_count), ContextSlot::B, 0, )?; diff --git a/downstairs/src/extent_inner_raw_common.rs b/downstairs/src/extent_inner_raw_common.rs index 90381bdd3..34546315e 100644 --- a/downstairs/src/extent_inner_raw_common.rs +++ b/downstairs/src/extent_inner_raw_common.rs @@ -1,7 +1,7 @@ use std::os::fd::AsFd; // Re-export from `crucible_raw_extent` -pub use crucible_raw_extent::{OnDiskMeta, BLOCK_META_SIZE_BYTES}; +pub use crucible_raw_extent::{BLOCK_META_SIZE_BYTES, OnDiskMeta}; /// Call `pread` repeatedly to read an entire buffer /// diff --git a/downstairs/src/extent_inner_sqlite.rs b/downstairs/src/extent_inner_sqlite.rs index c9bdec223..61b4964bd 100644 --- a/downstairs/src/extent_inner_sqlite.rs +++ b/downstairs/src/extent_inner_sqlite.rs @@ -1,20 +1,19 @@ // Copyright 2023 Oxide Computer Company use crate::{ - cdt, - extent::{check_input, extent_path, DownstairsBlockContext, ExtentInner}, + Block, BlockContext, CrucibleError, ExtentReadRequest, ExtentReadResponse, + ExtentWrite, JobId, RegionDefinition, cdt, + extent::{DownstairsBlockContext, ExtentInner, check_input, extent_path}, extent_inner_raw_common::pwrite_all, integrity_hash, region::JobOrReconciliationId, - Block, BlockContext, CrucibleError, ExtentReadRequest, ExtentReadResponse, - ExtentWrite, JobId, RegionDefinition, }; -use crucible_common::{crucible_bail, ExtentId}; +use crucible_common::{ExtentId, crucible_bail}; use crucible_protocol::{EncryptionContext, ReadBlockContext}; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use itertools::Itertools; -use rusqlite::{params, Connection, Transaction}; -use slog::{error, Logger}; +use rusqlite::{Connection, Transaction, params}; +use slog::{Logger, error}; use std::collections::{BTreeMap, HashSet}; use std::fs::{File, OpenOptions}; @@ -668,8 +667,7 @@ impl SqliteMoreInner { block: u64, count: u64, ) -> Result>, SqliteMoreInnerError> { - let stmt = - "SELECT block, hash, nonce, tag, on_disk_hash FROM block_context \ + let stmt = "SELECT block, hash, nonce, tag, on_disk_hash FROM block_context \ WHERE block BETWEEN ?1 AND ?2"; let mut stmt = self.metadb.prepare_cached(stmt)?; @@ -785,7 +783,7 @@ impl SqliteMoreInner { extent_number: ExtentId, ) -> Result { use crate::{ - extent::{ExtentMeta, EXTENT_META_SQLITE}, + extent::{EXTENT_META_SQLITE, ExtentMeta}, mkdir_for_file, }; let mut path = extent_path(dir, extent_number); @@ -1024,8 +1022,7 @@ impl SqliteMoreInner { &self, block_context: &DownstairsBlockContext, ) -> Result<(), SqliteMoreInnerError> { - let stmt = - "INSERT OR IGNORE INTO block_context (block, hash, nonce, tag, on_disk_hash) \ + let stmt = "INSERT OR IGNORE INTO block_context (block, hash, nonce, tag, on_disk_hash) \ VALUES (?1, ?2, ?3, ?4, ?5)"; let (nonce, tag) = if let Some(encryption_context) = @@ -1600,8 +1597,8 @@ mod test { /// We should never add contexts for blocks that haven't been written by /// an upstairs. #[test] - fn test_fully_rehash_and_clean_does_not_mark_blocks_as_written( - ) -> Result<()> { + fn test_fully_rehash_and_clean_does_not_mark_blocks_as_written() + -> Result<()> { let dir = tempdir()?; let mut inner = SqliteInner::create( dir.as_ref(), @@ -1697,8 +1694,8 @@ mod test { /// but is distinct in that it call fully_rehash directly, without closing /// and re-opening the extent. #[test] - fn test_fully_rehash_marks_blocks_unwritten_if_data_never_hit_disk( - ) -> Result<()> { + fn test_fully_rehash_marks_blocks_unwritten_if_data_never_hit_disk() + -> Result<()> { let dir = tempdir()?; let mut inner = SqliteInner::create( dir.as_ref(), diff --git a/downstairs/src/lib.rs b/downstairs/src/lib.rs index 87b56c499..683e925a7 100644 --- a/downstairs/src/lib.rs +++ b/downstairs/src/lib.rs @@ -12,22 +12,21 @@ use std::sync::Arc; use std::time::Duration; use crucible_common::{ - build_logger, integrity_hash, mkdir_for_file, Block, BlockIndex, - BlockOffset, CrucibleError, ExtentId, RegionDefinition, VerboseTimeout, - MAX_BLOCK_SIZE, + Block, BlockIndex, BlockOffset, CrucibleError, ExtentId, MAX_BLOCK_SIZE, + RegionDefinition, VerboseTimeout, build_logger, integrity_hash, + mkdir_for_file, }; use crucible_protocol::{ - BlockContext, CrucibleDecoder, JobId, Message, MessageWriter, - ReadBlockContext, ReconciliationId, SnapshotDetails, - CRUCIBLE_MESSAGE_VERSION, + BlockContext, CRUCIBLE_MESSAGE_VERSION, CrucibleDecoder, JobId, Message, + MessageWriter, ReadBlockContext, ReconciliationId, SnapshotDetails, }; use repair_client::Client; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use bytes::BytesMut; use futures::StreamExt; use rand::prelude::*; -use slog::{debug, error, info, o, warn, Logger}; +use slog::{Logger, debug, error, info, o, warn}; use tokio::net::TcpListener; use tokio::sync::{mpsc, oneshot}; use tokio::time::Instant; @@ -863,7 +862,7 @@ async fn proc_stream( pub struct UpstairsConnection { upstairs_id: Uuid, session_id: Uuid, - gen: u64, + generation: u64, } /// Unique ID identifying a single connection @@ -1728,8 +1727,12 @@ impl ActiveConnection { debug!( self.log, "Flush :{} extent_limit {:?} deps:{:?} res:{} f:{} g:{}", - job_id, extent_limit, dependencies, result.is_ok(), - flush_number, gen_number, + job_id, + extent_limit, + dependencies, + result.is_ok(), + flush_number, + gen_number, ); Message::FlushAck { @@ -2449,8 +2452,8 @@ impl Downstairs { // Compare the new generaion number to what the existing // connection is and take action based on that. match upstairs_connection - .gen - .cmp(&active_upstairs_connection.gen) + .generation + .cmp(&active_upstairs_connection.generation) { Ordering::Less => { // If the new connection has a lower generation @@ -2458,8 +2461,8 @@ impl Downstairs { // allow it to take over. bail!( "Current gen {} is > requested gen of {}", - active_upstairs_connection.gen, - upstairs_connection.gen, + active_upstairs_connection.generation, + upstairs_connection.generation, ); } Ordering::Equal => { @@ -2732,7 +2735,7 @@ impl Downstairs { version, upstairs_id, session_id, - gen, + generation, read_only, encrypted, alternate_versions, @@ -2817,7 +2820,7 @@ impl Downstairs { let upstairs_connection = UpstairsConnection { upstairs_id, session_id, - gen, + generation, }; // Steal data from the connection state @@ -2844,7 +2847,7 @@ impl Downstairs { Message::PromoteToActive { upstairs_id, session_id, - gen, + generation, } => { let ConnectionState::Negotiating { negotiated, @@ -2880,16 +2883,16 @@ impl Downstairs { session_id ); } else { - if upstairs_connection.gen != gen { + if upstairs_connection.generation != generation { warn!( self.log, "warning: generation number at negotiation was {} \ and {} at activation, updating", - upstairs_connection.gen, - gen, + upstairs_connection.generation, + generation, ); - // Reborrow to update `upstairs_connection.gen` + // Reborrow to update `upstairs_connection.generation` let ConnectionState::Negotiating { upstairs_connection, .. @@ -2897,7 +2900,7 @@ impl Downstairs { else { unreachable!() }; - upstairs_connection.gen = gen; + upstairs_connection.generation = generation; } self.promote_to_active(upstairs_connection, conn_id)?; @@ -2915,12 +2918,12 @@ impl Downstairs { unreachable!(); }; *negotiated = NegotiationState::PromotedToActive; - upstairs_connection.gen = gen; + upstairs_connection.generation = generation; if let Err(e) = state.reply(Message::YouAreNowActive { upstairs_id, session_id, - gen, + generation, }) { bail!("Failed sending YouAreNewActive: {}", e); } @@ -3199,7 +3202,7 @@ impl Downstairs { if let Err(e) = state.reply(Message::YouAreNoLongerActive { new_upstairs_id: new_upstairs_connection.upstairs_id, new_session_id: new_upstairs_connection.session_id, - new_gen: new_upstairs_connection.gen, + new_gen: new_upstairs_connection.generation, }) { warn!(self.log, "Failed sending YouAreNoLongerActive: {e}"); } @@ -3762,7 +3765,7 @@ mod test { use bytes::Bytes; use rand_chacha::ChaCha20Rng; use std::net::Ipv4Addr; - use tempfile::{tempdir, TempDir}; + use tempfile::{TempDir, tempdir}; use tokio::net::TcpSocket; // Create a simple logger @@ -3811,10 +3814,11 @@ mod test { fn complete(work: &mut Work, ds_id: JobId, job: IOop) { // validate that deps are done - assert!(job - .deps() - .iter() - .all(|dep| work.completed.is_complete(*dep))); + assert!( + job.deps() + .iter() + .all(|dep| work.completed.is_complete(*dep)) + ); // Flushes and barriers both guarantee that no future jobs will depend // on jobs that preceded them, so we reset the completed jobs list to @@ -3887,7 +3891,7 @@ mod test { let upstairs_connection = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 10, + generation: 10, }; // Dummy connection id @@ -3982,7 +3986,7 @@ mod test { let upstairs_connection = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 10, + generation: 10, }; // Dummy ConnectionId @@ -4055,7 +4059,7 @@ mod test { let block_size: u64 = 512; let extent_size = 4; let dir = tempdir()?; - let gen = 10; + let generation = 10; let mut ds = create_test_downstairs(block_size, extent_size, 5, &dir)?; @@ -4063,7 +4067,7 @@ mod test { let upstairs_connection = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen, + generation, }; // Dummy ConnectionId @@ -4081,7 +4085,7 @@ mod test { dependencies: vec![], extent: ExtentId(1), flush_number: 1, - gen_number: gen, + gen_number: generation, }; ds.active_mut(conn_id).add_work(JobId(1001), rio); @@ -4223,14 +4227,14 @@ mod test { let block_size: u64 = 512; let extent_size = 4; let dir = tempdir()?; - let gen = 10; + let generation = 10; let mut ds = create_test_downstairs(block_size, extent_size, 5, &dir)?; let upstairs_connection = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen, + generation, }; let conn_id = ConnectionId(0); @@ -4251,7 +4255,7 @@ mod test { let rio = IOop::Flush { dependencies: vec![JobId(1000)], flush_number: 3, - gen_number: gen, + gen_number: generation, snapshot_details: None, extent_limit: None, }; @@ -4331,14 +4335,14 @@ mod test { let block_size: u64 = 512; let extent_size = 4; let dir = tempdir()?; - let gen = 10; + let generation = 10; let mut ds = create_test_downstairs(block_size, extent_size, 5, &dir)?; let upstairs_connection = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen, + generation, }; let conn_id = ConnectionId(0); @@ -4434,7 +4438,7 @@ mod test { let block_size: u64 = 512; let extent_size = 4; let dir = tempdir()?; - let gen = 10; + let generation = 10; let mut ds = create_test_downstairs(block_size, extent_size, 5, &dir)?; @@ -4442,7 +4446,7 @@ mod test { let upstairs_connection = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen, + generation, }; // Dummy ConnectionId @@ -4464,7 +4468,7 @@ mod test { dependencies: vec![JobId(1000)], extent: eid, flush_number: 3, - gen_number: gen, + gen_number: generation, }; ds.active_mut(conn_id).add_work(JobId(1001), rio); @@ -4516,7 +4520,7 @@ mod test { assert_eq!(session_id, upstairs_connection.session_id); assert_eq!(job_id, JobId(1001)); let (g, f, d) = result.as_ref().unwrap(); - assert_eq!(*g, gen); + assert_eq!(*g, generation); assert_eq!(*f, 3); assert!(!*d); } @@ -4543,13 +4547,13 @@ mod test { let block_size: u64 = 512; let extent_size = 4; let dir = tempdir()?; - let gen = 10; + let generation = 10; let mut ds = create_test_downstairs(block_size, extent_size, 5, &dir)?; let upstairs_connection = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen, + generation, }; let conn_id = ConnectionId(0); @@ -4580,7 +4584,7 @@ mod test { dependencies: vec![JobId(1000)], extent: eid_one, flush_number: 6, - gen_number: gen, + gen_number: generation, }; ds.active_mut(conn_id).add_work(JobId(1002), rio); @@ -4622,7 +4626,7 @@ mod test { assert_eq!(session_id, upstairs_connection.session_id); assert_eq!(job_id, JobId(1002)); let (g, f, d) = result.as_ref().unwrap(); - assert_eq!(*g, gen); + assert_eq!(*g, generation); assert_eq!(*f, 6); assert!(!*d); } @@ -5563,7 +5567,7 @@ mod test { let upstairs_connection = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, }; ds.add_fake_connection(upstairs_connection, ConnectionId(0)); @@ -5581,7 +5585,7 @@ mod test { let upstairs_connection = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, }; ds.add_fake_connection(upstairs_connection, ConnectionId(0)); @@ -5593,8 +5597,8 @@ mod test { } #[test] - fn test_promote_to_active_multi_read_write_different_uuid_same_gen( - ) -> Result<()> { + fn test_promote_to_active_multi_read_write_different_uuid_same_gen() + -> Result<()> { // Attempting to activate multiple read-write (where it's different // Upstairs) but with the same gen should be blocked let mut ds = build_test_downstairs(false)?; @@ -5602,13 +5606,13 @@ mod test { let upstairs_connection_1 = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, }; let upstairs_connection_2 = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, }; let id1 = ConnectionId(1); @@ -5638,8 +5642,8 @@ mod test { } #[test] - fn test_promote_to_active_multi_read_write_different_uuid_lower_gen( - ) -> Result<()> { + fn test_promote_to_active_multi_read_write_different_uuid_lower_gen() + -> Result<()> { // Attempting to activate multiple read-write (where it's different // Upstairs) but with a lower gen should be blocked. let mut ds = build_test_downstairs(false)?; @@ -5647,13 +5651,13 @@ mod test { let upstairs_connection_1 = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 2, + generation: 2, }; let upstairs_connection_2 = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, }; println!("ds1: {:?}", ds); @@ -5696,13 +5700,13 @@ mod test { let upstairs_connection_1 = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, }; let upstairs_connection_2 = UpstairsConnection { upstairs_id: upstairs_connection_1.upstairs_id, session_id: Uuid::new_v4(), - gen: 1, + generation: 1, }; let id1 = ConnectionId(1); @@ -5731,8 +5735,8 @@ mod test { } #[test] - fn test_promote_to_active_multi_read_write_same_uuid_larger_gen( - ) -> Result<()> { + fn test_promote_to_active_multi_read_write_same_uuid_larger_gen() + -> Result<()> { // Attempting to activate multiple read-write where it's the same // Upstairs, but a different session, and with a larger generation // should allow the new connection to take over. @@ -5741,13 +5745,13 @@ mod test { let upstairs_connection_1 = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, }; let upstairs_connection_2 = UpstairsConnection { upstairs_id: upstairs_connection_1.upstairs_id, session_id: Uuid::new_v4(), - gen: 2, + generation: 2, }; let id1 = ConnectionId(1); @@ -5783,13 +5787,13 @@ mod test { let upstairs_connection_1 = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, }; let upstairs_connection_2 = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, }; let id1 = ConnectionId(1); @@ -5824,13 +5828,13 @@ mod test { let upstairs_connection_1 = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, }; let upstairs_connection_2 = UpstairsConnection { upstairs_id: upstairs_connection_1.upstairs_id, session_id: Uuid::new_v4(), - gen: 1, + generation: 1, }; let id1 = ConnectionId(1); @@ -5865,13 +5869,13 @@ mod test { let upstairs_connection_1 = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, }; let upstairs_connection_2 = UpstairsConnection { upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, }; let id1 = ConnectionId(1); @@ -5977,7 +5981,7 @@ mod test { version: CRUCIBLE_MESSAGE_VERSION, upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, read_only: false, encrypted: false, alternate_versions: Vec::new(), @@ -6015,7 +6019,7 @@ mod test { version: CRUCIBLE_MESSAGE_VERSION - 1, upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, read_only: false, encrypted: false, alternate_versions: vec![CRUCIBLE_MESSAGE_VERSION - 1], @@ -6049,7 +6053,7 @@ mod test { version: CRUCIBLE_MESSAGE_VERSION + 1, upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, read_only: false, encrypted: false, alternate_versions: vec![CRUCIBLE_MESSAGE_VERSION + 1], @@ -6083,7 +6087,7 @@ mod test { version: CRUCIBLE_MESSAGE_VERSION + 1, upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, read_only: false, encrypted: false, alternate_versions: vec![ @@ -6124,7 +6128,7 @@ mod test { version: CRUCIBLE_MESSAGE_VERSION + 4, upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, read_only: false, encrypted: false, alternate_versions: vec![ @@ -6231,7 +6235,7 @@ mod test { version: CRUCIBLE_MESSAGE_VERSION, upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 1, + generation: 1, read_only: false, encrypted: false, alternate_versions: Vec::new(), diff --git a/downstairs/src/main.rs b/downstairs/src/main.rs index 93ae96fe1..f681dd417 100644 --- a/downstairs/src/main.rs +++ b/downstairs/src/main.rs @@ -3,17 +3,17 @@ use std::net::{IpAddr, SocketAddr}; use std::path::PathBuf; use std::time::Duration; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::Parser; use slog::info; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; use uuid::Uuid; -use crucible_common::{build_logger, ExtentId}; +use crucible_common::{ExtentId, build_logger}; use crucible_downstairs::admin::*; use crucible_downstairs::*; -use crucible_protocol::{JobId, CRUCIBLE_MESSAGE_VERSION}; +use crucible_protocol::{CRUCIBLE_MESSAGE_VERSION, JobId}; #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, Debug, PartialEq)] diff --git a/downstairs/src/region.rs b/downstairs/src/region.rs index f265c38d2..32b09aea0 100644 --- a/downstairs/src/region.rs +++ b/downstairs/src/region.rs @@ -1,11 +1,11 @@ use std::collections::{BTreeSet, HashSet}; use std::fmt::Debug; -use std::fs::{rename, File, OpenOptions}; +use std::fs::{File, OpenOptions, rename}; use std::io::Write; use std::net::SocketAddr; use std::path::{Path, PathBuf}; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use futures::TryStreamExt; use tracing::instrument; @@ -30,8 +30,8 @@ const MIN_BLOCKING_SIZE: usize = 64 * 1024; // 64 KiB use super::*; use crate::extent::{ - copy_dir, extent_dir, extent_file_name, move_replacement_extent, - replace_dir, sync_path, Extent, ExtentMeta, ExtentState, ExtentType, + Extent, ExtentMeta, ExtentState, ExtentType, copy_dir, extent_dir, + extent_file_name, move_replacement_extent, replace_dir, sync_path, }; /// Validate files for a repair or clone operation @@ -1222,7 +1222,7 @@ impl Region { } #[cfg(feature = "omicron-build")] -extern "C" { +unsafe extern "C" { fn syncfs(fd: std::ffi::c_int) -> std::ffi::c_int; } @@ -1272,8 +1272,8 @@ pub(crate) mod test { use crate::dump::dump_region; use crate::extent::{ - completed_dir, copy_dir, extent_path, remove_copy_cleanup_dir, - DownstairsBlockContext, + DownstairsBlockContext, completed_dir, copy_dir, extent_path, + remove_copy_cleanup_dir, }; use super::*; @@ -1433,12 +1433,13 @@ pub(crate) mod test { region.extend(3, backend).unwrap(); // Close extent 1 - let (gen, flush, dirty) = region.close_extent(ExtentId(1)).unwrap(); + let (generation, flush, dirty) = + region.close_extent(ExtentId(1)).unwrap(); // Verify inner is gone, and we returned the expected gen, flush // and dirty values for a new unwritten extent. assert!(matches!(region.extents[1], ExtentState::Closed)); - assert_eq!(gen, 0); + assert_eq!(generation, 0); assert_eq!(flush, 0); assert!(!dirty); @@ -2288,9 +2289,11 @@ pub(crate) mod test { // Assert that the .db files still exist for i in (0..3).map(ExtentId) { - assert!(extent_dir(&dir, i) - .join(extent_file_name(i, ExtentType::Db)) - .exists()); + assert!( + extent_dir(&dir, i) + .join(extent_file_name(i, ExtentType::Db)) + .exists() + ); } // read all using region_read @@ -2310,9 +2313,11 @@ pub(crate) mod test { // Assert that the .db files have been deleted during the migration for i in (0..3).map(ExtentId) { - assert!(!extent_dir(&dir, i) - .join(extent_file_name(i, ExtentType::Db)) - .exists()); + assert!( + !extent_dir(&dir, i) + .join(extent_file_name(i, ExtentType::Db)) + .exists() + ); } let read_from_region = region.region_read(&req, JobId(0))?.data; @@ -3153,9 +3158,11 @@ pub(crate) mod test { region.extend(1, backend).unwrap(); // Call flush with an invalid extent - assert!(region - .region_flush(1, 2, &None, JobId(3), Some(ExtentId(2))) - .is_err()); + assert!( + region + .region_flush(1, 2, &None, JobId(3), Some(ExtentId(2))) + .is_err() + ); } fn test_extent_write_flush_close(backend: Backend) { @@ -3201,11 +3208,11 @@ pub(crate) mod test { region.region_flush_extent(eid, 3, 2, JobId(1)).unwrap(); // Close extent 0 - let (gen, flush, dirty) = region.close_extent(eid).unwrap(); + let (generation, flush, dirty) = region.close_extent(eid).unwrap(); // Verify inner is gone, and we returned the expected gen, flush // and dirty values for the write that should be flushed now. - assert_eq!(gen, 3); + assert_eq!(generation, 3); assert_eq!(flush, 2); assert!(!dirty); } @@ -3250,11 +3257,11 @@ pub(crate) mod test { .unwrap(); // Close extent 0 without a flush - let (gen, flush, dirty) = region.close_extent(eid).unwrap(); + let (generation, flush, dirty) = region.close_extent(eid).unwrap(); // Because we did not flush yet, this extent should still have // the values for an unwritten extent, except for the dirty bit. - assert_eq!(gen, 0); + assert_eq!(generation, 0); assert_eq!(flush, 0); assert!(dirty); @@ -3263,10 +3270,10 @@ pub(crate) mod test { // dirty). region.reopen_extent(eid).unwrap(); - let (gen, flush, dirty) = region.close_extent(eid).unwrap(); + let (generation, flush, dirty) = region.close_extent(eid).unwrap(); // Verify everything is the same, and dirty is still set. - assert_eq!(gen, 0); + assert_eq!(generation, 0); assert_eq!(flush, 0); assert!(dirty); @@ -3274,11 +3281,11 @@ pub(crate) mod test { region.reopen_extent(eid).unwrap(); region.region_flush_extent(eid, 4, 9, JobId(1)).unwrap(); - let (gen, flush, dirty) = region.close_extent(eid).unwrap(); + let (generation, flush, dirty) = region.close_extent(eid).unwrap(); // Verify after flush that g,f are updated, and that dirty // is no longer set. - assert_eq!(gen, 4); + assert_eq!(generation, 4); assert_eq!(flush, 9); assert!(!dirty); } diff --git a/downstairs/src/repair.rs b/downstairs/src/repair.rs index 5ed42de6b..28138b9f6 100644 --- a/downstairs/src/repair.rs +++ b/downstairs/src/repair.rs @@ -11,7 +11,7 @@ use dropshot::{ use hyper::{Response, StatusCode}; use super::*; -use crate::extent::{extent_dir, extent_file_name, extent_path, ExtentType}; +use crate::extent::{ExtentType, extent_dir, extent_file_name, extent_path}; /** * Our context is the root of the region we want to serve. diff --git a/downstairs/src/stats.rs b/downstairs/src/stats.rs index 231f32732..558a13be8 100644 --- a/downstairs/src/stats.rs +++ b/downstairs/src/stats.rs @@ -5,8 +5,8 @@ use super::*; use omicron_common::api::internal::nexus::ProducerEndpoint; use omicron_common::api::internal::nexus::ProducerKind; use oximeter::{ - types::{Cumulative, Sample}, Metric, MetricsError, Producer, Target, + types::{Cumulative, Sample}, }; use oximeter_producer::{ Config, ConfigLogging, ConfigLoggingIfExists, ConfigLoggingLevel, diff --git a/dsc-client/Cargo.toml b/dsc-client/Cargo.toml index 4fd6d0223..6f8bb6f98 100644 --- a/dsc-client/Cargo.toml +++ b/dsc-client/Cargo.toml @@ -2,7 +2,7 @@ name = "dsc-client" version = "0.0.1" license = "MPL-2.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/dsc/Cargo.toml b/dsc/Cargo.toml index ae038f720..1045bfe66 100644 --- a/dsc/Cargo.toml +++ b/dsc/Cargo.toml @@ -2,7 +2,7 @@ name = "dsc" version = "0.1.0" license = "MPL-2.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/dsc/src/control.rs b/dsc/src/control.rs index 968f20286..87e258ea6 100644 --- a/dsc/src/control.rs +++ b/dsc/src/control.rs @@ -1,5 +1,4 @@ // Copyright 2022 Oxide Computer Company -use dropshot::endpoint; use dropshot::ApiDescription; use dropshot::ConfigDropshot; use dropshot::ConfigLogging; @@ -9,6 +8,7 @@ use dropshot::HttpError; use dropshot::HttpServerStarter; use dropshot::Path; use dropshot::RequestContext; +use dropshot::endpoint; use dropshot::{HttpResponseOk, HttpResponseUpdatedNoContent}; use schemars::JsonSchema; use serde::Deserialize; diff --git a/dsc/src/main.rs b/dsc/src/main.rs index db49a79a6..a5fd03f7e 100644 --- a/dsc/src/main.rs +++ b/dsc/src/main.rs @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf}; use std::process::Stdio; use std::sync::Arc; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use byte_unit::Byte; use clap::{Parser, Subcommand}; use csv::WriterBuilder; @@ -18,15 +18,15 @@ use serde::Deserialize; use serde::Serialize; use tokio::process::{Child, Command}; use tokio::runtime::Builder; -use tokio::sync::{mpsc, watch, Mutex}; -use tokio::time::{sleep_until, Duration, Instant}; +use tokio::sync::{Mutex, mpsc, watch}; +use tokio::time::{Duration, Instant, sleep_until}; use uuid::Uuid; pub mod client; pub mod control; -use client::{client_main, ClientCommand}; +use client::{ClientCommand, client_main}; use crucible_client_types::RegionExtentInfo; -use crucible_common::{config_path, read_json, RegionDefinition}; +use crucible_common::{RegionDefinition, config_path, read_json}; /// dsc DownStairs Controller #[derive(Debug, Parser)] @@ -1654,7 +1654,7 @@ fn main() -> Result<()> { #[cfg(test)] mod test { use super::*; - use tempfile::{tempdir, NamedTempFile}; + use tempfile::{NamedTempFile, tempdir}; // Create a temporary file. Close the file but return the path // so it won't be deleted. diff --git a/hammer/Cargo.toml b/hammer/Cargo.toml index 6c7371566..333c6922e 100644 --- a/hammer/Cargo.toml +++ b/hammer/Cargo.toml @@ -2,7 +2,7 @@ name = "crucible-hammer" version = "0.1.0" license = "MPL-2.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/hammer/src/main.rs b/hammer/src/main.rs index 531a994a9..07d3ce45b 100644 --- a/hammer/src/main.rs +++ b/hammer/src/main.rs @@ -2,7 +2,7 @@ use std::net::SocketAddr; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::Parser; use uuid::Uuid; @@ -38,7 +38,7 @@ pub struct Opt { key: Option, #[clap(short, long, default_value = "1", action)] - gen: u64, + generation: u64, /* * Number of upstairs to sequentially activate and handoff to @@ -121,8 +121,9 @@ async fn main() -> Result<()> { */ let (guest, io) = Guest::new(None); - let gen: u64 = i as u64 + opt.gen; - let _join_handle = up_main(crucible_opts.clone(), gen, None, io, None)?; + let generation: u64 = i as u64 + opt.generation; + let _join_handle = + up_main(crucible_opts.clone(), generation, None, io, None)?; println!("Crucible runtime is spawned"); cpfs.push(crucible::CruciblePseudoFile::from(guest)?); diff --git a/integration_tests/Cargo.toml b/integration_tests/Cargo.toml index c20e30b3d..ec30e211a 100644 --- a/integration_tests/Cargo.toml +++ b/integration_tests/Cargo.toml @@ -7,7 +7,7 @@ authors = [ "James MacMahon " ] license = "MPL-2.0" -edition = "2021" +edition = "2024" [dev-dependencies] anyhow.workspace = true diff --git a/integration_tests/src/lib.rs b/integration_tests/src/lib.rs index d1b260285..9da0acbf3 100644 --- a/integration_tests/src/lib.rs +++ b/integration_tests/src/lib.rs @@ -8,7 +8,7 @@ mod integration_tests { use std::sync::Arc; use anyhow::*; - use base64::{engine, Engine}; + use base64::{Engine, engine}; use crucible::volume::VolumeBuilder; use crucible::*; use crucible_client_types::RegionExtentInfo; @@ -16,10 +16,10 @@ mod integration_tests { use crucible_downstairs::*; use crucible_pantry::pantry::Pantry; use crucible_pantry_client::Client as CruciblePantryClient; - use httptest::{matchers::*, responders::*, Expectation, Server}; + use httptest::{Expectation, Server, matchers::*, responders::*}; use repair_client::Client; use sha2::Digest; - use slog::{info, o, warn, Drain, Logger}; + use slog::{Drain, Logger, info, o, warn}; use tempfile::*; use tokio::sync::mpsc; use uuid::*; @@ -351,14 +351,14 @@ mod integration_tests { impl Drop for TestDownstairs { fn drop(&mut self) { - if self.dataset.stop_downstairs_during_drop() { - if let Some(downstairs) = self.downstairs.take() { - tokio::task::block_in_place(move || { - tokio::runtime::Handle::current() - .block_on(async move { downstairs.stop().await }) - .unwrap(); - }); - } + if self.dataset.stop_downstairs_during_drop() + && let Some(downstairs) = self.downstairs.take() + { + tokio::task::block_in_place(move || { + tokio::runtime::Handle::current() + .block_on(async move { downstairs.stop().await }) + .unwrap(); + }); } } } @@ -744,7 +744,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 1, + generation: 1, }], read_only_parent: None, }; @@ -793,7 +793,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 1, + generation: 1, }], read_only_parent: None, }; @@ -849,7 +849,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 1, + generation: 1, }], read_only_parent: None, }; @@ -1000,7 +1000,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 1, + generation: 1, }], read_only_parent: None, }; @@ -1080,7 +1080,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 1, + generation: 1, }], read_only_parent: Some(Box::new( VolumeConstructionRequest::Volume { @@ -1139,7 +1139,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 1, + generation: 1, }, )), }; @@ -1183,7 +1183,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 1, + generation: 1, }], read_only_parent: None, }; @@ -1249,7 +1249,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 1, + generation: 1, }], read_only_parent: None, }; @@ -1317,7 +1317,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 1, + generation: 1, }], read_only_parent: None, }; @@ -1382,7 +1382,7 @@ mod integration_tests { blocks_per_extent: tds1.blocks_per_extent(), extent_count: tds1.extent_count(), opts, - gen: 1, + generation: 1, }); let tds2 = DefaultTestDownstairsSet::small(false).await?; let opts = tds2.opts(); @@ -1391,7 +1391,7 @@ mod integration_tests { blocks_per_extent: tds2.blocks_per_extent(), extent_count: tds2.extent_count(), opts, - gen: 1, + generation: 1, }); let vcr = VolumeConstructionRequest::Volume { @@ -1439,8 +1439,8 @@ mod integration_tests { } #[tokio::test] - async fn integration_test_volume_write_unwritten_subvols_sparse( - ) -> Result<()> { + async fn integration_test_volume_write_unwritten_subvols_sparse() + -> Result<()> { // Test a single layer volume with two subvolumes, // verify a first write_unwritten that crosses the subvols // works as expected. @@ -1464,7 +1464,7 @@ mod integration_tests { blocks_per_extent: tds1.blocks_per_extent(), extent_count: tds1.extent_count(), opts, - gen: 1, + generation: 1, }); let tds2 = DefaultTestDownstairsSet::small(false).await?; let opts = tds2.opts(); @@ -1473,7 +1473,7 @@ mod integration_tests { blocks_per_extent: tds2.blocks_per_extent(), extent_count: tds2.extent_count(), opts, - gen: 1, + generation: 1, }); let vcr = VolumeConstructionRequest::Volume { @@ -1565,7 +1565,7 @@ mod integration_tests { blocks_per_extent: tds1.blocks_per_extent(), extent_count: tds1.extent_count(), opts, - gen: 1, + generation: 1, }); let tds2 = DefaultTestDownstairsSet::small(false).await?; let opts = tds2.opts(); @@ -1574,7 +1574,7 @@ mod integration_tests { blocks_per_extent: tds2.blocks_per_extent(), extent_count: tds2.extent_count(), opts, - gen: 1, + generation: 1, }); let vcr = VolumeConstructionRequest::Volume { @@ -2112,7 +2112,7 @@ mod integration_tests { blocks_per_extent: tds1.blocks_per_extent(), extent_count: tds1.extent_count(), opts, - gen: 1, + generation: 1, }); let tds2 = DefaultTestDownstairsSet::small(false).await?; let opts = tds2.opts(); @@ -2121,7 +2121,7 @@ mod integration_tests { blocks_per_extent: tds2.blocks_per_extent(), extent_count: tds2.extent_count(), opts, - gen: 1, + generation: 1, }); let vcr = VolumeConstructionRequest::Volume { @@ -2192,8 +2192,8 @@ mod integration_tests { } #[tokio::test] - async fn integration_test_volume_subvols_parent_scrub_sparse_2( - ) -> Result<()> { + async fn integration_test_volume_subvols_parent_scrub_sparse_2() + -> Result<()> { // Test a volume with two sub volumes, and 3/4th RO parent // Write a few spots, one spanning the sub vols. // Verify scrubber and everything works as expected. @@ -2236,7 +2236,7 @@ mod integration_tests { blocks_per_extent: tds1.blocks_per_extent(), extent_count: tds1.extent_count(), opts, - gen: 1, + generation: 1, }); let tds2 = DefaultTestDownstairsSet::small(false).await?; let opts = tds2.opts(); @@ -2245,7 +2245,7 @@ mod integration_tests { blocks_per_extent: tds2.blocks_per_extent(), extent_count: tds2.extent_count(), opts, - gen: 1, + generation: 1, }); let vcr = VolumeConstructionRequest::Volume { @@ -2348,7 +2348,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts: opts.clone(), - gen: 1, + generation: 1, }, )), }; @@ -2366,7 +2366,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 1, + generation: 1, }, )), }; @@ -2532,13 +2532,15 @@ mod integration_tests { assert_eq!(&buffer[..], random_buffer); - assert!(volume - .write( - BlockIndex(0), - BytesMut::from(vec![0u8; BLOCK_SIZE].as_slice()), - ) - .await - .is_err()); + assert!( + volume + .write( + BlockIndex(0), + BytesMut::from(vec![0u8; BLOCK_SIZE].as_slice()), + ) + .await + .is_err() + ); volume.flush(None).await?; } @@ -2557,7 +2559,7 @@ mod integration_tests { blocks_per_extent: top_layer_tds.blocks_per_extent(), extent_count: top_layer_tds.extent_count(), opts: top_layer_opts, - gen: 3, + generation: 3, }], read_only_parent: Some(Box::new( VolumeConstructionRequest::Volume { @@ -2569,7 +2571,7 @@ mod integration_tests { .blocks_per_extent(), extent_count: test_downstairs_set.extent_count(), opts: bottom_layer_opts, - gen: 3, + generation: 3, }], read_only_parent: None, }, @@ -2628,12 +2630,14 @@ mod integration_tests { DefaultTestDownstairsSet::small_sqlite(false).await?; // This must be a SQLite extent! - assert!(test_downstairs_set - .downstairs1 - .path() - .unwrap() - .join("00/000/000.db") - .exists()); + assert!( + test_downstairs_set + .downstairs1 + .path() + .unwrap() + .join("00/000/000.db") + .exists() + ); let mut builder = VolumeBuilder::new(BLOCK_SIZE as u64, csl()); builder @@ -2670,12 +2674,14 @@ mod integration_tests { test_downstairs_set.reboot_read_only().await?; // This must still be a SQLite backend! - assert!(test_downstairs_set - .downstairs1 - .path() - .unwrap() - .join("00/000/000.db") - .exists()); + assert!( + test_downstairs_set + .downstairs1 + .path() + .unwrap() + .join("00/000/000.db") + .exists() + ); // Validate that this now accepts reads and flushes, but rejects writes { @@ -2704,13 +2710,15 @@ mod integration_tests { assert_eq!(&buffer[..], random_buffer); - assert!(volume - .write( - BlockIndex(0), - BytesMut::from(vec![0u8; BLOCK_SIZE].as_slice()), - ) - .await - .is_err()); + assert!( + volume + .write( + BlockIndex(0), + BytesMut::from(vec![0u8; BLOCK_SIZE].as_slice()), + ) + .await + .is_err() + ); volume.flush(None).await?; } @@ -2722,12 +2730,14 @@ mod integration_tests { let bottom_layer_opts = test_downstairs_set.opts(); // The new volume is **not** using the SQLite backend! - assert!(!top_layer_tds - .downstairs1 - .path() - .unwrap() - .join("00/000/000.db") - .exists()); + assert!( + !top_layer_tds + .downstairs1 + .path() + .unwrap() + .join("00/000/000.db") + .exists() + ); let vcr = VolumeConstructionRequest::Volume { id: Uuid::new_v4(), @@ -2737,7 +2747,7 @@ mod integration_tests { blocks_per_extent: top_layer_tds.blocks_per_extent(), extent_count: top_layer_tds.extent_count(), opts: top_layer_opts, - gen: 3, + generation: 3, }], read_only_parent: Some(Box::new( VolumeConstructionRequest::Volume { @@ -2749,7 +2759,7 @@ mod integration_tests { .blocks_per_extent(), extent_count: test_downstairs_set.extent_count(), opts: bottom_layer_opts, - gen: 3, + generation: 3, }], read_only_parent: None, }, @@ -2805,12 +2815,14 @@ mod integration_tests { let mut test_downstairs_set = DefaultTestDownstairsSet::small_sqlite(false).await?; // This must be a SQLite extent! - assert!(test_downstairs_set - .downstairs1 - .path() - .unwrap() - .join("00/000/000.db") - .exists()); + assert!( + test_downstairs_set + .downstairs1 + .path() + .unwrap() + .join("00/000/000.db") + .exists() + ); let mut builder = VolumeBuilder::new(BLOCK_SIZE as u64, csl()); builder @@ -2845,21 +2857,25 @@ mod integration_tests { drop(volume); // This must still be a SQLite extent! - assert!(test_downstairs_set - .downstairs1 - .path() - .unwrap() - .join("00/000/000.db") - .exists()); + assert!( + test_downstairs_set + .downstairs1 + .path() + .unwrap() + .join("00/000/000.db") + .exists() + ); test_downstairs_set.reboot_read_write().await?; // This should now be migrated, and the DB file should be deleted - assert!(!test_downstairs_set - .downstairs1 - .path() - .unwrap() - .join("00/000/000.db") - .exists()); + assert!( + !test_downstairs_set + .downstairs1 + .path() + .unwrap() + .join("00/000/000.db") + .exists() + ); let mut builder = VolumeBuilder::new(BLOCK_SIZE as u64, csl()); builder @@ -3060,12 +3076,14 @@ mod integration_tests { DefaultTestDownstairsSet::small_sqlite(false).await?; // This must be a SQLite extent! - assert!(test_downstairs_set - .downstairs1 - .path() - .unwrap() - .join("00/000/000.db") - .exists()); + assert!( + test_downstairs_set + .downstairs1 + .path() + .unwrap() + .join("00/000/000.db") + .exists() + ); let mut builder = VolumeBuilder::new(BLOCK_SIZE as u64, csl()); builder @@ -3794,8 +3812,8 @@ mod integration_tests { } #[tokio::test] - async fn integration_test_volume_replace_downstairs_then_takeover( - ) -> Result<()> { + async fn integration_test_volume_replace_downstairs_then_takeover() + -> Result<()> { let log = csl(); // Replace a downstairs with a new one which will kick off // LiveRepair. Then spin up a new Upstairs with a newer @@ -4515,8 +4533,8 @@ mod integration_tests { } #[tokio::test] - async fn integration_test_guest_downstairs_unwritten_sparse_mid( - ) -> Result<()> { + async fn integration_test_guest_downstairs_unwritten_sparse_mid() + -> Result<()> { // Test using the guest layer to verify a new region is // what we expect, and a write_unwritten and read work as expected, // this time with sparse writes where the middle block is written @@ -4572,8 +4590,8 @@ mod integration_tests { } #[tokio::test] - async fn integration_test_guest_downstairs_unwritten_sparse_end( - ) -> Result<()> { + async fn integration_test_guest_downstairs_unwritten_sparse_end() + -> Result<()> { // Test write_unwritten and read work as expected, // this time with sparse writes where the last block is written const BLOCK_SIZE: usize = 512; @@ -4821,7 +4839,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts: opts.clone(), - gen: 1, + generation: 1, }], read_only_parent: None, }; @@ -4924,7 +4942,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts: opts.clone(), - gen: 2, + generation: 2, }], read_only_parent: None, }; @@ -5024,7 +5042,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts: opts.clone(), - gen: 1, + generation: 1, }], read_only_parent: None, }; @@ -5077,7 +5095,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 3, + generation: 3, }], read_only_parent: None, }; @@ -5161,7 +5179,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 2, + generation: 2, }], read_only_parent: None, }; @@ -5220,7 +5238,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 2, + generation: 2, }], read_only_parent: None, }; @@ -5356,7 +5374,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts: opts.clone(), - gen: 1, + generation: 1, }], read_only_parent: read_only_parent.clone(), }; @@ -5398,7 +5416,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts: opts.clone(), - gen: 2, + generation: 2, }], read_only_parent, }; @@ -5447,7 +5465,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 3, + generation: 3, }], read_only_parent: None, }; @@ -5925,7 +5943,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts: opts.clone(), - gen: 2, + generation: 2, }], read_only_parent: None, }; @@ -5969,7 +5987,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts: new_opts.clone(), - gen: 3, + generation: 3, }], read_only_parent: None, }; @@ -6003,7 +6021,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts: opts.clone(), - gen: 1, + generation: 1, }], read_only_parent: None, }; @@ -6044,7 +6062,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts: opts.clone(), - gen: 2, + generation: 2, }); let new_sub_vol = vec![VolumeConstructionRequest::Region { @@ -6052,7 +6070,7 @@ mod integration_tests { blocks_per_extent: sv_tds.blocks_per_extent(), extent_count: sv_tds.extent_count(), opts: sv_opts.clone(), - gen: 1, + generation: 1, }]; let new_vol = VolumeConstructionRequest::Volume { @@ -6081,7 +6099,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts: new_opts.clone(), - gen: 3, + generation: 3, }); // Our "new" VCR must have a new downstairs in the opts, and have @@ -6143,7 +6161,7 @@ mod integration_tests { blocks_per_extent: tds.blocks_per_extent(), extent_count: tds.extent_count(), opts, - gen: 2, + generation: 2, }], read_only_parent: None, }; @@ -6179,7 +6197,7 @@ mod integration_tests { blocks_per_extent: child.blocks_per_extent(), extent_count: child.extent_count(), opts: child.opts(), - gen: 2, + generation: 2, }], read_only_parent: None, }; @@ -6217,7 +6235,7 @@ mod integration_tests { blocks_per_extent: child.blocks_per_extent(), extent_count: child.extent_count(), opts: child.opts(), - gen: 2, + generation: 2, }], read_only_parent: None, }; diff --git a/measure_iops/Cargo.toml b/measure_iops/Cargo.toml index 854e6f385..d2dc6f339 100644 --- a/measure_iops/Cargo.toml +++ b/measure_iops/Cargo.toml @@ -2,7 +2,7 @@ name = "measure-iops" version = "0.0.1" license = "MPL-2.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/measure_iops/src/main.rs b/measure_iops/src/main.rs index d2dffdddb..4ecd8f0f4 100644 --- a/measure_iops/src/main.rs +++ b/measure_iops/src/main.rs @@ -3,7 +3,7 @@ use std::net::SocketAddr; use std::sync::Arc; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::Parser; use rand::Rng; use tokio::time::{Duration, Instant}; @@ -22,7 +22,7 @@ pub struct Opt { key: Option, #[clap(short, long, default_value = "0", action)] - gen: u64, + generation: u64, #[clap(long, action)] cert_pem: Option, @@ -82,7 +82,7 @@ async fn main() -> Result<()> { let (guest, io) = Guest::new(None); let guest = Arc::new(guest); - let _join_handle = up_main(crucible_opts, opt.gen, None, io, None)?; + let _join_handle = up_main(crucible_opts, opt.generation, None, io, None)?; println!("Crucible runtime is spawned"); guest.activate().await?; diff --git a/nbd_server/Cargo.toml b/nbd_server/Cargo.toml index b60983ce5..5d09d5205 100644 --- a/nbd_server/Cargo.toml +++ b/nbd_server/Cargo.toml @@ -3,7 +3,7 @@ name = "crucible-nbd-server" version = "0.1.0" authors = ["Joshua M. Clulow ", "Alan Hanson ", "James MacMahon "] license = "MPL-2.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/nbd_server/src/main.rs b/nbd_server/src/main.rs index 611e88bfd..738d38859 100644 --- a/nbd_server/src/main.rs +++ b/nbd_server/src/main.rs @@ -1,12 +1,12 @@ // Copyright 2021 Oxide Computer Company use std::net::SocketAddr; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::Parser; use crucible::*; -use nbd::server::{handshake, transmission, Export}; +use nbd::server::{Export, handshake, transmission}; use std::net::{TcpListener, TcpStream as NetTcpStream}; /* @@ -38,7 +38,7 @@ pub struct Opt { key: Option, #[clap(short, long, default_value = "0", action)] - gen: u64, + generation: u64, // TLS options #[clap(long, action)] @@ -92,7 +92,7 @@ async fn main() -> Result<()> { */ let (guest, io) = Guest::new(None); - let _join_handle = up_main(crucible_opts, opt.gen, None, io, None)?; + let _join_handle = up_main(crucible_opts, opt.generation, None, io, None)?; println!("Crucible runtime is spawned"); // NBD server diff --git a/package/Cargo.toml b/package/Cargo.toml index b8d6c2d21..e4f56e8a9 100644 --- a/package/Cargo.toml +++ b/package/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "crucible-package" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/pantry-api/Cargo.toml b/pantry-api/Cargo.toml index df6692f4e..8a8da76d2 100644 --- a/pantry-api/Cargo.toml +++ b/pantry-api/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "crucible-pantry-api" version = "0.1.0" -edition = "2021" +edition = "2024" license = "MPL-2.0" [dependencies] diff --git a/pantry-client/Cargo.toml b/pantry-client/Cargo.toml index 446120cea..15dc70e10 100644 --- a/pantry-client/Cargo.toml +++ b/pantry-client/Cargo.toml @@ -2,7 +2,7 @@ name = "crucible-pantry-client" version = "0.0.1" license = "MPL-2.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/pantry-types/Cargo.toml b/pantry-types/Cargo.toml index 1345916ce..66995a1a4 100644 --- a/pantry-types/Cargo.toml +++ b/pantry-types/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "crucible-pantry-types" version = "0.1.0" -edition = "2021" +edition = "2024" license = "MPL-2.0" [dependencies] diff --git a/pantry/Cargo.toml b/pantry/Cargo.toml index 1e9ea8c9f..41131459f 100644 --- a/pantry/Cargo.toml +++ b/pantry/Cargo.toml @@ -2,7 +2,7 @@ name = "crucible-pantry" version = "0.0.1" license = "MPL-2.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/pantry/src/lib.rs b/pantry/src/lib.rs index 68173d1a6..f42a25ebb 100644 --- a/pantry/src/lib.rs +++ b/pantry/src/lib.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use anyhow::Result; use dropshot::{ConfigLogging, ConfigLoggingIfExists, ConfigLoggingLevel}; -use slog::{info, o, Logger}; +use slog::{Logger, info, o}; pub const PROG: &str = "crucible-pantry"; diff --git a/pantry/src/main.rs b/pantry/src/main.rs index ef675b4bf..c54e818ec 100644 --- a/pantry/src/main.rs +++ b/pantry/src/main.rs @@ -1,6 +1,6 @@ // Copyright 2022 Oxide Computer Company -use anyhow::{anyhow, Result}; +use anyhow::{Result, anyhow}; use clap::Parser; use std::net::SocketAddr; diff --git a/pantry/src/pantry.rs b/pantry/src/pantry.rs index 04c84bc3b..d61397447 100644 --- a/pantry/src/pantry.rs +++ b/pantry/src/pantry.rs @@ -6,16 +6,16 @@ use std::future::Future; use std::str::FromStr; use std::sync::Arc; -use anyhow::anyhow; use anyhow::Result; +use anyhow::anyhow; use bytes::{Bytes, BytesMut}; use dropshot::HttpError; use sha2::Digest; use sha2::Sha256; +use slog::Logger; use slog::error; use slog::info; use slog::o; -use slog::Logger; use tokio::sync::Mutex; use tokio::task::JoinHandle; use uuid::Uuid; @@ -25,8 +25,8 @@ use crucible::ReplaceResult; use crucible::SnapshotDetails; use crucible::Volume; use crucible::VolumeConstructionRequest; -use crucible_common::crucible_bail; use crucible_common::CrucibleError; +use crucible_common::crucible_bail; use crucible_pantry_types::{ExpectedDigest, PantryStatus, VolumeStatus}; pub enum ActiveObservation { diff --git a/pantry/src/server.rs b/pantry/src/server.rs index 21d39a239..5059106cb 100644 --- a/pantry/src/server.rs +++ b/pantry/src/server.rs @@ -4,8 +4,8 @@ use super::pantry::Pantry; use std::net::SocketAddr; use std::sync::Arc; -use anyhow::{anyhow, Result}; -use base64::{engine, Engine}; +use anyhow::{Result, anyhow}; +use base64::{Engine, engine}; use crucible_pantry_api::*; use crucible_pantry_types::*; use dropshot::{ @@ -13,7 +13,7 @@ use dropshot::{ HttpResponseDeleted, HttpResponseOk, HttpResponseUpdatedNoContent, Path as TypedPath, RequestContext, TypedBody, VersionPolicy, }; -use slog::{info, o, Logger}; +use slog::{Logger, info, o}; use std::result::Result as SResult; #[derive(Debug)] diff --git a/protocol/Cargo.toml b/protocol/Cargo.toml index d774c60dd..c3c9bc53b 100644 --- a/protocol/Cargo.toml +++ b/protocol/Cargo.toml @@ -3,7 +3,7 @@ name = "crucible-protocol" version = "0.0.0" authors = ["Joshua M. Clulow "] license = "MPL-2.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/protocol/src/lib.rs b/protocol/src/lib.rs index d187e7941..6ef3f5d47 100644 --- a/protocol/src/lib.rs +++ b/protocol/src/lib.rs @@ -248,7 +248,7 @@ pub enum Message { // The unique UUID just for this running upstairs session session_id: Uuid, // Generation number (IGNORED) - gen: u64, + generation: u64, // If we expect the region to be read-only. read_only: bool, // If we expect the region to be encrypted. @@ -291,12 +291,12 @@ pub enum Message { PromoteToActive { upstairs_id: Uuid, session_id: Uuid, - gen: u64, + generation: u64, }, YouAreNowActive { upstairs_id: Uuid, session_id: Uuid, - gen: u64, + generation: u64, }, YouAreNoLongerActive { new_upstairs_id: Uuid, @@ -1142,7 +1142,7 @@ mod tests { version: 2, upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 123, + generation: 123, read_only: false, encrypted: true, alternate_versions: Vec::new(), @@ -1213,7 +1213,7 @@ mod tests { version: 0, upstairs_id: Uuid::new_v4(), session_id: Uuid::new_v4(), - gen: 23849183, + generation: 23849183, read_only: true, encrypted: false, alternate_versions: Vec::new(), @@ -1285,7 +1285,7 @@ mod tests { version: 123, upstairs_id, session_id, - gen: 567, + generation: 567, read_only: true, encrypted: false, alternate_versions: vec![8, 9], diff --git a/repair-client/Cargo.toml b/repair-client/Cargo.toml index 5ec7db161..5dd9c6e01 100644 --- a/repair-client/Cargo.toml +++ b/repair-client/Cargo.toml @@ -2,7 +2,7 @@ name = "repair-client" version = "0.0.1" license = "MPL-2.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/rustfmt.toml b/rustfmt.toml index 296a70865..4cca3bdfe 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1,2 @@ max_width = 80 -edition = "2021" +edition = "2024" diff --git a/smf/Cargo.toml b/smf/Cargo.toml index 052c466f6..477836a37 100644 --- a/smf/Cargo.toml +++ b/smf/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "crucible-smf" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] libc.workspace = true diff --git a/smf/src/instance.rs b/smf/src/instance.rs index 1c4d9bd7d..698f777ac 100644 --- a/smf/src/instance.rs +++ b/smf/src/instance.rs @@ -5,8 +5,8 @@ use std::ptr::NonNull; use super::scf_sys::*; use super::{ - buf_for, str_from, Iter, PropertyGroup, PropertyGroups, Result, Scf, - ScfError, Service, Snapshot, Snapshots, + Iter, PropertyGroup, PropertyGroups, Result, Scf, ScfError, Service, + Snapshot, Snapshots, buf_for, str_from, }; #[derive(Debug)] diff --git a/smf/src/lib.rs b/smf/src/lib.rs index 4072762f4..d0bd28c89 100644 --- a/smf/src/lib.rs +++ b/smf/src/lib.rs @@ -97,8 +97,8 @@ pub enum ScfError { impl From for ScfError { fn from(error: u32) -> Self { - use scf_error_t::*; use ScfError::*; + use scf_error_t::*; match scf_error_t::from_u32(error) { Some(SCF_ERROR_NONE) => None, diff --git a/smf/src/property.rs b/smf/src/property.rs index 05b4f80bb..ae3025132 100644 --- a/smf/src/property.rs +++ b/smf/src/property.rs @@ -4,8 +4,8 @@ use std::ptr::NonNull; use super::scf_sys::*; use super::{ - buf_for, str_from, Iter, PropertyGroup, Result, Scf, ScfError, Value, - Values, + Iter, PropertyGroup, Result, Scf, ScfError, Value, Values, buf_for, + str_from, }; #[derive(Debug)] diff --git a/smf/src/propertygroup.rs b/smf/src/propertygroup.rs index fb2797087..53c7b4267 100644 --- a/smf/src/propertygroup.rs +++ b/smf/src/propertygroup.rs @@ -5,8 +5,8 @@ use std::ptr::NonNull; use super::scf_sys::*; use super::{ - buf_for, str_from, Instance, Iter, Properties, Property, Result, Scf, - ScfError, Service, Snapshot, Transaction, + Instance, Iter, Properties, Property, Result, Scf, ScfError, Service, + Snapshot, Transaction, buf_for, str_from, }; #[derive(Debug)] diff --git a/smf/src/scf_sys.rs b/smf/src/scf_sys.rs index 8f7c2da5f..7129878df 100644 --- a/smf/src/scf_sys.rs +++ b/smf/src/scf_sys.rs @@ -120,7 +120,7 @@ pub const SCF_DECODE_FMRI_REQUIRE_NO_INSTANCE: c_int = 0x00000008; #[cfg(target_os = "illumos")] #[link(name = "scf")] -extern "C" { +unsafe extern "C" { pub fn scf_handle_create(version: scf_version_t) -> *mut scf_handle_t; pub fn scf_handle_destroy(handle: *mut scf_handle_t); pub fn scf_handle_bind(handle: *mut scf_handle_t) -> c_int; @@ -293,7 +293,7 @@ extern "C" { ) -> c_int; pub fn scf_pg_create(handle: *mut scf_handle_t) - -> *mut scf_propertygroup_t; + -> *mut scf_propertygroup_t; pub fn scf_pg_destroy(pg: *mut scf_propertygroup_t); pub fn scf_pg_get_name( @@ -420,7 +420,7 @@ extern "C" { ) -> c_int; pub fn smf_disable_instance(instance: *const c_char, flags: c_int) - -> c_int; + -> c_int; pub fn smf_enable_instance(instance: *const c_char, flags: c_int) -> c_int; pub fn smf_refresh_instance(instance: *const c_char) -> c_int; diff --git a/smf/src/scope.rs b/smf/src/scope.rs index 325cf2b7b..b81c3cdff 100644 --- a/smf/src/scope.rs +++ b/smf/src/scope.rs @@ -5,7 +5,7 @@ use std::ptr::NonNull; use super::scf_sys::*; use super::{ - buf_for, str_from, Iter, Result, Scf, ScfError, Service, Services, + Iter, Result, Scf, ScfError, Service, Services, buf_for, str_from, }; #[derive(Debug)] diff --git a/smf/src/service.rs b/smf/src/service.rs index c6b95c0db..8575df8c9 100644 --- a/smf/src/service.rs +++ b/smf/src/service.rs @@ -5,8 +5,8 @@ use std::ptr::NonNull; use super::scf_sys::*; use super::{ - buf_for, str_from, Instance, Instances, Iter, PropertyGroups, Result, Scf, - ScfError, Scope, + Instance, Instances, Iter, PropertyGroups, Result, Scf, ScfError, Scope, + buf_for, str_from, }; #[derive(Debug)] diff --git a/smf/src/snapshot.rs b/smf/src/snapshot.rs index 4c7ac77a9..6bea18a5c 100644 --- a/smf/src/snapshot.rs +++ b/smf/src/snapshot.rs @@ -5,8 +5,8 @@ use std::ptr::NonNull; use super::scf_sys::*; use super::{ - buf_for, str_from, Instance, Iter, PropertyGroup, PropertyGroups, Result, - ScfError, + Instance, Iter, PropertyGroup, PropertyGroups, Result, ScfError, buf_for, + str_from, }; #[derive(Debug)] diff --git a/smf/src/value.rs b/smf/src/value.rs index f9471c9e4..1b8e034ac 100644 --- a/smf/src/value.rs +++ b/smf/src/value.rs @@ -6,7 +6,7 @@ use std::ptr::NonNull; use num_traits::cast::FromPrimitive; use super::scf_sys::*; -use super::{buf_for, str_from, Iter, Property, Result, Scf, ScfError}; +use super::{Iter, Property, Result, Scf, ScfError, buf_for, str_from}; #[derive(Debug)] pub struct Value<'a> { diff --git a/upstairs/Cargo.toml b/upstairs/Cargo.toml index 7c07b99c2..6a19575b0 100644 --- a/upstairs/Cargo.toml +++ b/upstairs/Cargo.toml @@ -3,8 +3,8 @@ name = "crucible" version = "0.0.1" authors = ["Joshua M. Clulow ", "Alan Hanson { if !matches!(state, NegotiationStateData::WaitForPromote) { error!( @@ -1383,16 +1383,16 @@ impl DownstairsClient { }); } let upstairs_gen = self.cfg.generation(); - if upstairs_gen != gen { + if upstairs_gen != generation { error!( self.log, "generation mismatch in YouAreNowActive: {} != {}", upstairs_gen, - gen + generation, ); err = Some(NegotiationError::GenerationNumberTooLow { requested: upstairs_gen, - actual: gen, + actual: generation, }); } if let Some(e) = err { @@ -2586,10 +2586,10 @@ fn update_net_start_probes(m: &Message, cid: ClientId) { Message::ReadRequest { job_id, .. } => { cdt::ds__read__net__start!(|| (job_id.0, cid.get())); } - Message::Write { ref header, .. } => { + Message::Write { header, .. } => { cdt::ds__write__net__start!(|| (header.job_id.0, cid.get())); } - Message::WriteUnwritten { ref header, .. } => { + Message::WriteUnwritten { header, .. } => { cdt::ds__write__unwritten__net__start!(|| ( header.job_id.0, cid.get() @@ -2603,7 +2603,7 @@ fn update_net_start_probes(m: &Message, cid: ClientId) { } fn update_net_done_probes(m: &Message, cid: ClientId) { match m { - Message::ReadResponse { ref header, .. } => { + Message::ReadResponse { header, .. } => { cdt::ds__read__net__done!(|| (header.job_id.0, cid.get())); } Message::WriteAck { job_id, .. } => { diff --git a/upstairs/src/control.rs b/upstairs/src/control.rs index cddf43de0..6133eb087 100644 --- a/upstairs/src/control.rs +++ b/upstairs/src/control.rs @@ -1,5 +1,4 @@ // Copyright 2022 Oxide Computer Company -use dropshot::endpoint; use dropshot::ApiDescription; use dropshot::ConfigDropshot; use dropshot::HandlerTaskMode; @@ -7,6 +6,7 @@ use dropshot::HttpError; use dropshot::HttpResponseOk; use dropshot::HttpServerStarter; use dropshot::RequestContext; +use dropshot::endpoint; use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; diff --git a/upstairs/src/deferred.rs b/upstairs/src/deferred.rs index 9b0235375..7b589e688 100644 --- a/upstairs/src/deferred.rs +++ b/upstairs/src/deferred.rs @@ -3,18 +3,18 @@ use std::sync::Arc; use crate::{ - client::ConnectionId, io_limits::IOLimitGuard, upstairs::UpstairsConfig, BlockContext, BlockOp, ClientId, ImpactedBlocks, Message, RawWrite, + client::ConnectionId, io_limits::IOLimitGuard, upstairs::UpstairsConfig, }; use bytes::BytesMut; -use crucible_common::{integrity_hash, CrucibleError, RegionDefinition}; +use crucible_common::{CrucibleError, RegionDefinition, integrity_hash}; use crucible_protocol::{ReadBlockContext, ReadResponseHeader}; use futures::{ - future::{ready, Either, Ready}, - stream::FuturesOrdered, StreamExt, + future::{Either, Ready, ready}, + stream::FuturesOrdered, }; -use slog::{error, Logger}; +use slog::{Logger, error}; use tokio::sync::oneshot; /// Future stored in a [`DeferredQueue`] diff --git a/upstairs/src/downstairs.rs b/upstairs/src/downstairs.rs index c4fad6c3c..a7f1b113e 100644 --- a/upstairs/src/downstairs.rs +++ b/upstairs/src/downstairs.rs @@ -7,7 +7,13 @@ use std::{ }; use crate::{ - cdt, + AckStatus, ActiveJobs, AllocRingBuffer, BlockRes, Buffer, ClientData, + ClientIOStateCount, ClientId, ClientMap, ConnectionMode, CrucibleError, + DownstairsIO, DownstairsMend, DsState, DsStateData, ExtentFix, + ExtentRepairIDs, IOState, IOStateCount, IOop, ImpactedBlocks, JobId, + Message, NegotiationState, RawReadResponse, RawWrite, ReconcileIO, + ReconciliationId, RegionDefinition, RegionMetadata, ReplaceResult, + SnapshotDetails, WorkSummary, cdt, client::{ ClientAction, ClientFaultReason, ClientNegotiationFailed, ClientRunResult, ClientStopReason, DownstairsClient, EnqueueResult, @@ -20,19 +26,12 @@ use crate::{ notify::{NotifyQueue, NotifyRequest}, stats::DownstairsStatOuter, upstairs::{UpstairsConfig, UpstairsState}, - AckStatus, ActiveJobs, AllocRingBuffer, BlockRes, Buffer, ClientData, - ClientIOStateCount, ClientId, ClientMap, ConnectionMode, CrucibleError, - DownstairsIO, DownstairsMend, DsState, DsStateData, ExtentFix, - ExtentRepairIDs, IOState, IOStateCount, IOop, ImpactedBlocks, JobId, - Message, NegotiationState, RawReadResponse, RawWrite, ReconcileIO, - ReconciliationId, RegionDefinition, RegionMetadata, ReplaceResult, - SnapshotDetails, WorkSummary, }; use crucible_common::{BlockIndex, ExtentId, NegotiationError}; use crucible_protocol::WriteHeader; use ringbuffer::RingBuffer; -use slog::{debug, error, info, o, warn, Logger}; +use slog::{Logger, debug, error, info, o, warn}; use uuid::Uuid; /// Downstairs data @@ -935,10 +934,10 @@ impl Downstairs { for (i, m) in rec.iter().enumerate() { max_flush = max_flush.max(m.flush + 1); - max_gen = max_gen.max(m.gen + 1); + max_gen = max_gen.max(m.generation + 1); if i < MAX_LOG { flush_log.push(m.flush); - gen_log.push(m.gen); + gen_log.push(m.generation); dirty_log.push(m.dirty); } } @@ -1004,7 +1003,7 @@ impl Downstairs { }; for m in data.iter() { max_flush = max_flush.max(m.flush + 1); - max_gen = max_gen.max(m.gen + 1); + max_gen = max_gen.max(m.generation + 1); } } self.start_reconciliation(CollateData { max_gen, max_flush }, |data| { @@ -4071,13 +4070,13 @@ pub(crate) mod test { NegotiationStateData, PendingJob, }; use crate::{ - downstairs::{LiveRepairData, LiveRepairState, ReconcileData}, - live_repair::ExtentInfo, - upstairs::UpstairsState, BlockOpWaiter, BlockRes, ClientId, CrucibleError, DsStateData, ExtentFix, ExtentRepairIDs, IOState, IOop, ImpactedBlocks, JobId, RawReadResponse, ReconcileIO, ReconcileIOState, ReconciliationId, RegionMetadata, SnapshotDetails, + downstairs::{LiveRepairData, LiveRepairState, ReconcileData}, + live_repair::ExtentInfo, + upstairs::UpstairsState, }; use bytes::BytesMut; @@ -6537,9 +6536,11 @@ pub(crate) mod test { // The last skipped flush should still be on the skipped list assert_eq!(ds.clients[ClientId::new(0)].skipped_jobs.len(), 1); - assert!(ds.clients[ClientId::new(0)] - .skipped_jobs - .contains(&JobId(1002))); + assert!( + ds.clients[ClientId::new(0)] + .skipped_jobs + .contains(&JobId(1002)) + ); assert_eq!(ds.clients[ClientId::new(1)].skipped_jobs.len(), 0); assert_eq!(ds.clients[ClientId::new(2)].skipped_jobs.len(), 0); } @@ -6714,9 +6715,11 @@ pub(crate) mod test { // One downstairs should have a skipped job on its list. assert_eq!(ds.clients[ClientId::new(0)].skipped_jobs.len(), 0); assert_eq!(ds.clients[ClientId::new(1)].skipped_jobs.len(), 1); - assert!(ds.clients[ClientId::new(1)] - .skipped_jobs - .contains(&JobId(1001))); + assert!( + ds.clients[ClientId::new(1)] + .skipped_jobs + .contains(&JobId(1001)) + ); assert_eq!(ds.clients[ClientId::new(2)].skipped_jobs.len(), 0); // Enqueue the flush. @@ -6752,9 +6755,11 @@ pub(crate) mod test { // Only the skipped flush should remain. assert_eq!(ds.clients[ClientId::new(0)].skipped_jobs.len(), 0); assert_eq!(ds.clients[ClientId::new(1)].skipped_jobs.len(), 1); - assert!(ds.clients[ClientId::new(1)] - .skipped_jobs - .contains(&JobId(1002))); + assert!( + ds.clients[ClientId::new(1)] + .skipped_jobs + .contains(&JobId(1002)) + ); assert_eq!(ds.clients[ClientId::new(2)].skipped_jobs.len(), 0); } @@ -7234,9 +7239,11 @@ pub(crate) mod test { // Skipped jobs just has the flush assert_eq!(ds.clients[ClientId::new(0)].skipped_jobs.len(), 1); - assert!(ds.clients[ClientId::new(0)] - .skipped_jobs - .contains(&JobId(1002))); + assert!( + ds.clients[ClientId::new(0)] + .skipped_jobs + .contains(&JobId(1002)) + ); // The writes, the read, and the flush should be completed. assert_eq!(ds.completed().len(), 3); @@ -7328,13 +7335,17 @@ pub(crate) mod test { // Skipped jobs now just have the flush. assert_eq!(ds.clients[ClientId::new(0)].skipped_jobs.len(), 1); - assert!(ds.clients[ClientId::new(0)] - .skipped_jobs - .contains(&JobId(1002))); + assert!( + ds.clients[ClientId::new(0)] + .skipped_jobs + .contains(&JobId(1002)) + ); assert_eq!(ds.clients[ClientId::new(2)].skipped_jobs.len(), 1); - assert!(ds.clients[ClientId::new(2)] - .skipped_jobs - .contains(&JobId(1002))); + assert!( + ds.clients[ClientId::new(2)] + .skipped_jobs + .contains(&JobId(1002)) + ); // The writes, the read, and the flush should be completed. assert_eq!(ds.completed().len(), 3); @@ -7580,18 +7591,24 @@ pub(crate) mod test { flush_number: 3, dirty: false, }; - assert!(ds.clients[ClientId::new(0)] - .repair_info - .replace(ei) - .is_none()); - assert!(ds.clients[ClientId::new(1)] - .repair_info - .replace(ei) - .is_none()); - assert!(ds.clients[ClientId::new(2)] - .repair_info - .replace(ei) - .is_none()); + assert!( + ds.clients[ClientId::new(0)] + .repair_info + .replace(ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(1)] + .repair_info + .replace(ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(2)] + .repair_info + .replace(ei) + .is_none() + ); let repair_extent = if source == ClientId::new(0) { vec![ClientId::new(1), ClientId::new(2)] @@ -7679,32 +7696,44 @@ pub(crate) mod test { // is the source. // First try one source, one repair let repair = if source == ClientId::new(0) { - assert!(ds.clients[ClientId::new(0)] - .repair_info - .replace(good_ei) - .is_none()); - assert!(ds.clients[ClientId::new(1)] - .repair_info - .replace(bad_ei) - .is_none()); - assert!(ds.clients[ClientId::new(2)] - .repair_info - .replace(good_ei) - .is_none()); + assert!( + ds.clients[ClientId::new(0)] + .repair_info + .replace(good_ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(1)] + .repair_info + .replace(bad_ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(2)] + .repair_info + .replace(good_ei) + .is_none() + ); vec![ClientId::new(1)] } else { - assert!(ds.clients[ClientId::new(0)] - .repair_info - .replace(bad_ei) - .is_none()); - assert!(ds.clients[ClientId::new(1)] - .repair_info - .replace(good_ei) - .is_none()); - assert!(ds.clients[ClientId::new(2)] - .repair_info - .replace(good_ei) - .is_none()); + assert!( + ds.clients[ClientId::new(0)] + .repair_info + .replace(bad_ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(1)] + .repair_info + .replace(good_ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(2)] + .repair_info + .replace(good_ei) + .is_none() + ); vec![ClientId::new(0)] }; @@ -7713,32 +7742,44 @@ pub(crate) mod test { // Next try the other downstairs to repair. let repair = if source == ClientId::new(2) { - assert!(ds.clients[ClientId::new(0)] - .repair_info - .replace(good_ei) - .is_none()); - assert!(ds.clients[ClientId::new(1)] - .repair_info - .replace(bad_ei) - .is_none()); - assert!(ds.clients[ClientId::new(2)] - .repair_info - .replace(good_ei) - .is_none()); + assert!( + ds.clients[ClientId::new(0)] + .repair_info + .replace(good_ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(1)] + .repair_info + .replace(bad_ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(2)] + .repair_info + .replace(good_ei) + .is_none() + ); vec![ClientId::new(1)] } else { - assert!(ds.clients[ClientId::new(0)] - .repair_info - .replace(good_ei) - .is_none()); - assert!(ds.clients[ClientId::new(1)] - .repair_info - .replace(good_ei) - .is_none()); - assert!(ds.clients[ClientId::new(2)] - .repair_info - .replace(bad_ei) - .is_none()); + assert!( + ds.clients[ClientId::new(0)] + .repair_info + .replace(good_ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(1)] + .repair_info + .replace(good_ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(2)] + .repair_info + .replace(bad_ei) + .is_none() + ); vec![ClientId::new(2)] }; @@ -7765,46 +7806,64 @@ pub(crate) mod test { // is the source. // One source, two repair let repair = if source == ClientId::new(0) { - assert!(ds.clients[ClientId::new(0)] - .repair_info - .replace(good_ei) - .is_none()); - assert!(ds.clients[ClientId::new(1)] - .repair_info - .replace(bad_ei) - .is_none()); - assert!(ds.clients[ClientId::new(2)] - .repair_info - .replace(bad_ei) - .is_none()); + assert!( + ds.clients[ClientId::new(0)] + .repair_info + .replace(good_ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(1)] + .repair_info + .replace(bad_ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(2)] + .repair_info + .replace(bad_ei) + .is_none() + ); vec![ClientId::new(1), ClientId::new(2)] } else if source == ClientId::new(1) { - assert!(ds.clients[ClientId::new(0)] - .repair_info - .replace(bad_ei) - .is_none()); - assert!(ds.clients[ClientId::new(1)] - .repair_info - .replace(good_ei) - .is_none()); - assert!(ds.clients[ClientId::new(2)] - .repair_info - .replace(bad_ei) - .is_none()); + assert!( + ds.clients[ClientId::new(0)] + .repair_info + .replace(bad_ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(1)] + .repair_info + .replace(good_ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(2)] + .repair_info + .replace(bad_ei) + .is_none() + ); vec![ClientId::new(0), ClientId::new(2)] } else { - assert!(ds.clients[ClientId::new(0)] - .repair_info - .replace(bad_ei) - .is_none()); - assert!(ds.clients[ClientId::new(1)] - .repair_info - .replace(bad_ei) - .is_none()); - assert!(ds.clients[ClientId::new(2)] - .repair_info - .replace(good_ei) - .is_none()); + assert!( + ds.clients[ClientId::new(0)] + .repair_info + .replace(bad_ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(1)] + .repair_info + .replace(bad_ei) + .is_none() + ); + assert!( + ds.clients[ClientId::new(2)] + .repair_info + .replace(good_ei) + .is_none() + ); vec![ClientId::new(0), ClientId::new(1)] }; diff --git a/upstairs/src/dummy_downstairs_tests.rs b/upstairs/src/dummy_downstairs_tests.rs index 0e9904fcc..7547f83de 100644 --- a/upstairs/src/dummy_downstairs_tests.rs +++ b/upstairs/src/dummy_downstairs_tests.rs @@ -7,9 +7,6 @@ use std::collections::VecDeque; use std::sync::Arc; use std::time::Duration; -use crate::client::{CLIENT_RECONNECT_DELAY, CLIENT_TIMEOUT}; -use crate::guest::Guest; -use crate::up_main; use crate::BlockIO; use crate::Buffer; use crate::ClientFaultReason; @@ -18,6 +15,9 @@ use crate::ConnectionMode; use crate::CrucibleError; use crate::DsState; use crate::NegotiationState; +use crate::client::{CLIENT_RECONNECT_DELAY, CLIENT_TIMEOUT}; +use crate::guest::Guest; +use crate::up_main; use crate::{ IO_CACHED_MAX_BYTES, IO_CACHED_MAX_JOBS, IO_OUTSTANDING_MAX_BYTES, IO_OUTSTANDING_MAX_JOBS, @@ -41,12 +41,12 @@ use crucible_protocol::WriteHeader; use bytes::BytesMut; use futures::SinkExt; use futures::StreamExt; +use slog::Drain; +use slog::Logger; use slog::error; use slog::info; use slog::o; use slog::warn; -use slog::Drain; -use slog::Logger; use std::net::SocketAddr; use std::sync::atomic::AtomicU8; use std::sync::atomic::Ordering; @@ -167,10 +167,10 @@ impl DownstairsHandle { if let Message::PromoteToActive { upstairs_id, session_id, - gen, + generation, } = &packet { - assert!(*gen == 1); + assert!(*generation == 1); info!(self.log, "negotiate packet {:?}", packet); @@ -180,7 +180,7 @@ impl DownstairsHandle { self.send(Message::YouAreNowActive { upstairs_id: *upstairs_id, session_id: *session_id, - gen: *gen, + generation: *generation, }) .unwrap(); } else { @@ -906,25 +906,37 @@ async fn run_live_repair(mut harness: TestHarness) { ds3_buffered_messages.push(harness.ds3.recv().await.unwrap()); } - assert!(ds1_buffered_messages - .iter() - .any(|m| matches!(m, Message::ExtentLiveClose { .. }))); - assert!(ds2_buffered_messages - .iter() - .any(|m| matches!(m, Message::ExtentLiveFlushClose { .. }))); - assert!(ds3_buffered_messages - .iter() - .any(|m| matches!(m, Message::ExtentLiveFlushClose { .. }))); + assert!( + ds1_buffered_messages + .iter() + .any(|m| matches!(m, Message::ExtentLiveClose { .. })) + ); + assert!( + ds2_buffered_messages + .iter() + .any(|m| matches!(m, Message::ExtentLiveFlushClose { .. })) + ); + assert!( + ds3_buffered_messages + .iter() + .any(|m| matches!(m, Message::ExtentLiveFlushClose { .. })) + ); - assert!(ds1_buffered_messages - .iter() - .any(|m| matches!(m, Message::ExtentLiveReopen { .. }))); - assert!(ds2_buffered_messages - .iter() - .any(|m| matches!(m, Message::ExtentLiveReopen { .. }))); - assert!(ds3_buffered_messages - .iter() - .any(|m| matches!(m, Message::ExtentLiveReopen { .. }))); + assert!( + ds1_buffered_messages + .iter() + .any(|m| matches!(m, Message::ExtentLiveReopen { .. })) + ); + assert!( + ds2_buffered_messages + .iter() + .any(|m| matches!(m, Message::ExtentLiveReopen { .. })) + ); + assert!( + ds3_buffered_messages + .iter() + .any(|m| matches!(m, Message::ExtentLiveReopen { .. })) + ); // This is the reopen job id for extent eid @@ -1208,7 +1220,7 @@ async fn run_live_repair(mut harness: TestHarness) { assert!(*extent_id == eid); // ds1 didn't get the flush, it was set to faulted - let gen = 1; + let generation = 1; let flush = 0; let dirty = false; @@ -1218,7 +1230,7 @@ async fn run_live_repair(mut harness: TestHarness) { upstairs_id: *upstairs_id, session_id: *session_id, job_id: *job_id, - result: Ok((gen, flush, dirty)), + result: Ok((generation, flush, dirty)), }) .unwrap(); } @@ -1236,7 +1248,7 @@ async fn run_live_repair(mut harness: TestHarness) { assert!(*extent_id == eid); // ds2 and ds3 did get a flush - let gen = 0; + let generation = 0; let flush = 2; let dirty = false; @@ -1246,7 +1258,7 @@ async fn run_live_repair(mut harness: TestHarness) { upstairs_id: *upstairs_id, session_id: *session_id, job_id: *job_id, - result: Ok((gen, flush, dirty)), + result: Ok((generation, flush, dirty)), }) .unwrap() } @@ -1264,7 +1276,7 @@ async fn run_live_repair(mut harness: TestHarness) { assert!(*extent_id == eid); // ds2 and ds3 did get a flush - let gen = 0; + let generation = 0; let flush = 2; let dirty = false; @@ -1274,7 +1286,7 @@ async fn run_live_repair(mut harness: TestHarness) { upstairs_id: *upstairs_id, session_id: *session_id, job_id: *job_id, - result: Ok((gen, flush, dirty)), + result: Ok((generation, flush, dirty)), }) .unwrap() } @@ -2253,25 +2265,37 @@ async fn test_error_during_live_repair_no_halt() { ds3_buffered_messages.push(harness.ds3.recv().await.unwrap()); } - assert!(ds1_buffered_messages - .iter() - .any(|m| matches!(m, Message::ExtentLiveClose { .. }))); - assert!(ds2_buffered_messages - .iter() - .any(|m| matches!(m, Message::ExtentLiveFlushClose { .. }))); - assert!(ds3_buffered_messages - .iter() - .any(|m| matches!(m, Message::ExtentLiveFlushClose { .. }))); - - assert!(ds1_buffered_messages - .iter() - .any(|m| matches!(m, Message::ExtentLiveReopen { .. }))); - assert!(ds2_buffered_messages - .iter() - .any(|m| matches!(m, Message::ExtentLiveReopen { .. }))); - assert!(ds3_buffered_messages - .iter() - .any(|m| matches!(m, Message::ExtentLiveReopen { .. }))); + assert!( + ds1_buffered_messages + .iter() + .any(|m| matches!(m, Message::ExtentLiveClose { .. })) + ); + assert!( + ds2_buffered_messages + .iter() + .any(|m| matches!(m, Message::ExtentLiveFlushClose { .. })) + ); + assert!( + ds3_buffered_messages + .iter() + .any(|m| matches!(m, Message::ExtentLiveFlushClose { .. })) + ); + + assert!( + ds1_buffered_messages + .iter() + .any(|m| matches!(m, Message::ExtentLiveReopen { .. })) + ); + assert!( + ds2_buffered_messages + .iter() + .any(|m| matches!(m, Message::ExtentLiveReopen { .. })) + ); + assert!( + ds3_buffered_messages + .iter() + .any(|m| matches!(m, Message::ExtentLiveReopen { .. })) + ); // The repair task then waits for the close responses. @@ -2299,7 +2323,7 @@ async fn test_error_during_live_repair_no_halt() { assert!(*extent_id == ExtentId(0)); // ds1 didn't get the flush, it was set to faulted - let gen = 1; + let generation = 1; let flush = 0; let dirty = false; @@ -2309,7 +2333,7 @@ async fn test_error_during_live_repair_no_halt() { upstairs_id: *upstairs_id, session_id: *session_id, job_id: *job_id, - result: Ok((gen, flush, dirty)), + result: Ok((generation, flush, dirty)), }) .unwrap(); } @@ -2327,7 +2351,7 @@ async fn test_error_during_live_repair_no_halt() { assert!(*extent_id == ExtentId(0)); // ds2 and ds3 did get a flush - let gen = 0; + let generation = 0; let flush = 2; let dirty = false; @@ -2337,7 +2361,7 @@ async fn test_error_during_live_repair_no_halt() { upstairs_id: *upstairs_id, session_id: *session_id, job_id: *job_id, - result: Ok((gen, flush, dirty)), + result: Ok((generation, flush, dirty)), }) .unwrap() } @@ -2355,7 +2379,7 @@ async fn test_error_during_live_repair_no_halt() { assert!(*extent_id == ExtentId(0)); // ds2 and ds3 did get a flush - let gen = 0; + let generation = 0; let flush = 2; let dirty = false; @@ -2365,7 +2389,7 @@ async fn test_error_during_live_repair_no_halt() { upstairs_id: *upstairs_id, session_id: *session_id, job_id: *job_id, - result: Ok((gen, flush, dirty)), + result: Ok((generation, flush, dirty)), }) .unwrap() } diff --git a/upstairs/src/guest.rs b/upstairs/src/guest.rs index da14210fa..20489d29b 100644 --- a/upstairs/src/guest.rs +++ b/upstairs/src/guest.rs @@ -5,19 +5,19 @@ use std::{ }; use crate::{ - io_limits::{IOLimitView, IOLimits}, BlockIO, BlockOp, BlockOpWaiter, BlockRes, Buffer, ReadBlockContext, ReplaceResult, UpstairsAction, + io_limits::{IOLimitView, IOLimits}, }; use crucible_client_types::RegionExtentInfo; -use crucible_common::{build_logger, BlockIndex, CrucibleError}; +use crucible_common::{BlockIndex, CrucibleError, build_logger}; use crucible_protocol::SnapshotDetails; use async_trait::async_trait; use bytes::BytesMut; -use slog::{info, warn, Logger}; +use slog::{Logger, info, warn}; use tokio::sync::mpsc; -use tracing::{instrument, span, Level}; +use tracing::{Level, instrument, span}; use uuid::Uuid; #[derive(Debug)] @@ -228,19 +228,23 @@ impl BlockIO for Guest { Ok(()) } - async fn activate_with_gen(&self, gen: u64) -> Result<(), CrucibleError> { + async fn activate_with_gen( + &self, + generation: u64, + ) -> Result<(), CrucibleError> { let (rx, done) = BlockOpWaiter::pair(); - self.send(BlockOp::GoActiveWithGen { gen, done }).await; + self.send(BlockOp::GoActiveWithGen { generation, done }) + .await; info!( self.log, - "The guest has requested activation with gen:{}", gen + "The guest has requested activation with gen:{generation}" ); rx.wait().await?; info!( self.log, - "The guest has finished waiting for activation with:{}", gen + "The guest has finished waiting for activation with:{generation}" ); Ok(()) diff --git a/upstairs/src/lib.rs b/upstairs/src/lib.rs index 857ee6341..df6363312 100644 --- a/upstairs/src/lib.rs +++ b/upstairs/src/lib.rs @@ -17,14 +17,14 @@ pub use crucible_client_types::{ pub use crucible_common::*; pub use crucible_protocol::*; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; pub use bytes::{Bytes, BytesMut}; use oximeter::types::ProducerRegistry; use ringbuffer::AllocRingBuffer; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use slog::{error, info, o, warn, Logger}; -use tokio::sync::{mpsc, oneshot, Mutex, RwLock}; +use slog::{Logger, error, info, o, warn}; +use tokio::sync::{Mutex, RwLock, mpsc, oneshot}; use tracing::instrument; use usdt::register_probes; use uuid::Uuid; @@ -128,7 +128,10 @@ pub mod testing { #[async_trait] pub trait BlockIO: Sync { async fn activate(&self) -> Result<(), CrucibleError>; - async fn activate_with_gen(&self, gen: u64) -> Result<(), CrucibleError>; + async fn activate_with_gen( + &self, + generation: u64, + ) -> Result<(), CrucibleError>; async fn deactivate(&self) -> Result<(), CrucibleError>; @@ -484,7 +487,7 @@ impl ClientMap { } pub fn iter(&self) -> impl DoubleEndedIterator { self.0 - .0 + .0 .iter() .enumerate() .flat_map(|(i, v)| v.as_ref().map(|v| (ClientId::new(i as u8), v))) @@ -583,10 +586,9 @@ impl EncryptionContext { ]; // macos' and illumos' libc contain this - extern "C" { + unsafe extern "C" { pub fn arc4random_buf(buf: *mut libc::c_void, nbytes: libc::size_t); } - unsafe { arc4random_buf(random_iv.as_mut_ptr() as *mut libc::c_void, 12) } @@ -1510,7 +1512,7 @@ pub(crate) enum BlockOp { done: BlockRes, }, GoActiveWithGen { - gen: u64, + generation: u64, done: BlockRes, }, Deactivate { @@ -1626,7 +1628,7 @@ pub(crate) fn format_job_list(ids: &[JobId]) -> String { */ pub fn up_main( opt: CrucibleOpts, - gen: u64, + generation: u64, region_def: Option, guest: GuestIoHandle, producer_registry: Option, @@ -1668,8 +1670,13 @@ pub fn up_main( * Build the Upstairs struct that we use to share data between * the different async tasks */ - let mut up = - upstairs::Upstairs::new(&opt, gen, region_def, guest, tls_context); + let mut up = upstairs::Upstairs::new( + &opt, + generation, + region_def, + guest, + tls_context, + ); #[cfg(test)] if disable_backpressure { diff --git a/upstairs/src/live_repair.rs b/upstairs/src/live_repair.rs index a5e7e2ab3..3bab3e6c7 100644 --- a/upstairs/src/live_repair.rs +++ b/upstairs/src/live_repair.rs @@ -89,10 +89,10 @@ pub mod repair_test { client::ClientAction, downstairs::DownstairsAction, upstairs::{ + Upstairs, UpstairsAction, test::{ create_test_upstairs, start_up_and_repair, to_live_repair_ready, }, - Upstairs, UpstairsAction, }, }; diff --git a/upstairs/src/mend.rs b/upstairs/src/mend.rs index 00182a4d7..5a24254a6 100644 --- a/upstairs/src/mend.rs +++ b/upstairs/src/mend.rs @@ -25,7 +25,7 @@ impl RegionMetadata { .iter() .enumerate() .map(|(i, g)| ExtentMetadata { - gen: *g, + generation: *g, flush: flush_numbers[i], dirty: dirty[i], }) @@ -56,7 +56,7 @@ impl RegionMetadata { /// works to pick the highest-priority extent. #[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq)] pub(crate) struct ExtentMetadata { - pub gen: u64, + pub generation: u64, pub flush: u64, pub dirty: bool, } @@ -123,11 +123,7 @@ impl DownstairsMend { } } - if dsm.mend.is_empty() { - None - } else { - Some(dsm) - } + if dsm.mend.is_empty() { None } else { Some(dsm) } } } @@ -1156,7 +1152,7 @@ mod test { // first and second rows with a 1 in the third row. // Generation and dirty bits are the same for all downstairs. - let gen = vec![1, 1, 1, 1, 1, 1, 1, 1, 1]; + let gens = vec![1, 1, 1, 1, 1, 1, 1, 1, 1]; // Extent -------- 0 1 2 3 4 5 6 7 8 let flush0 = vec![1, 2, 3, 1, 2, 3, 1, 2, 3]; @@ -1167,9 +1163,9 @@ mod test { false, false, false, false, false, false, false, false, false, ]; - let d0 = RegionMetadata::new(&gen, &flush0, &dirty); - let d1 = RegionMetadata::new(&gen, &flush1, &dirty); - let d2 = RegionMetadata::new(&gen, &flush2, &dirty); + let d0 = RegionMetadata::new(&gens, &flush0, &dirty); + let d1 = RegionMetadata::new(&gens, &flush1, &dirty); + let d2 = RegionMetadata::new(&gens, &flush2, &dirty); let mut meta = ClientMap::new(); meta.insert(ClientId::new(0), &d0); @@ -1248,7 +1244,7 @@ mod test { // first and second rows with a 2 in the third row. // Generation and dirty bits are the same for all downstairs. - let gen = vec![1, 1, 1, 1, 1, 1, 1, 1, 1]; + let gens = vec![1, 1, 1, 1, 1, 1, 1, 1, 1]; // Extent --------- 0 1 2 3 4 5 6 7 8 let flush0 = vec![1, 2, 3, 1, 2, 3, 1, 2, 3]; let flush1 = vec![1, 1, 1, 2, 2, 2, 3, 3, 3]; @@ -1258,9 +1254,9 @@ mod test { false, false, false, false, false, false, false, false, false, ]; - let d0 = RegionMetadata::new(&gen, &flush0, &dirty); - let d1 = RegionMetadata::new(&gen, &flush1, &dirty); - let d2 = RegionMetadata::new(&gen, &flush2, &dirty); + let d0 = RegionMetadata::new(&gens, &flush0, &dirty); + let d1 = RegionMetadata::new(&gens, &flush1, &dirty); + let d2 = RegionMetadata::new(&gens, &flush2, &dirty); let mut meta = ClientMap::new(); meta.insert(ClientId::new(0), &d0); @@ -1339,7 +1335,7 @@ mod test { // first and second rows with 3 in the third row. // Generation and dirty bits are the same for all downstairs. - let gen = vec![1, 1, 1, 1, 1, 1, 1, 1, 1]; + let gens = vec![1, 1, 1, 1, 1, 1, 1, 1, 1]; // Extent --------- 0 1 2 3 4 5 6 7 8 let flush0 = vec![1, 2, 3, 1, 2, 3, 1, 2, 3]; @@ -1350,9 +1346,9 @@ mod test { false, false, false, false, false, false, false, false, false, ]; - let d0 = RegionMetadata::new(&gen, &flush0, &dirty); - let d1 = RegionMetadata::new(&gen, &flush1, &dirty); - let d2 = RegionMetadata::new(&gen, &flush2, &dirty); + let d0 = RegionMetadata::new(&gens, &flush0, &dirty); + let d1 = RegionMetadata::new(&gens, &flush1, &dirty); + let d2 = RegionMetadata::new(&gens, &flush2, &dirty); let mut meta = ClientMap::new(); meta.insert(ClientId::new(0), &d0); diff --git a/upstairs/src/notify.rs b/upstairs/src/notify.rs index 039b1c8da..3fba18b58 100644 --- a/upstairs/src/notify.rs +++ b/upstairs/src/notify.rs @@ -6,7 +6,7 @@ use chrono::{DateTime, Utc}; use rand::prelude::*; -use slog::{debug, error, info, o, warn, Logger}; +use slog::{Logger, debug, error, info, o, warn}; use std::net::{Ipv6Addr, SocketAddr}; use tokio::sync::mpsc; use uuid::Uuid; @@ -251,13 +251,13 @@ async fn notify_task_nexus( upstairs_id, repair_id, session_id, - ref repairs, + repairs, } | NotifyRequest::ReconcileStart { upstairs_id, repair_id, session_id, - ref repairs, + repairs, } => { let upstairs_id = TypedUuid::from_untyped_uuid(*upstairs_id); let (description, repair_type) = @@ -332,14 +332,14 @@ async fn notify_task_nexus( repair_id, session_id, aborted, - ref repairs, + repairs, } | NotifyRequest::ReconcileFinish { upstairs_id, repair_id, session_id, aborted, - ref repairs, + repairs, } => { let upstairs_id = TypedUuid::from_untyped_uuid(*upstairs_id); let (description, repair_type) = diff --git a/upstairs/src/pseudo_file.rs b/upstairs/src/pseudo_file.rs index 2b7f9c564..35f4e1e9f 100644 --- a/upstairs/src/pseudo_file.rs +++ b/upstairs/src/pseudo_file.rs @@ -212,9 +212,9 @@ impl CruciblePseudoFile { } pub async fn activate_with_gen( &mut self, - gen: u64, + generation: u64, ) -> Result<(), CrucibleError> { - self.block_io.activate_with_gen(gen).await?; + self.block_io.activate_with_gen(generation).await?; self.sz = self.block_io.total_size().await?; self.block_size = self.block_io.get_block_size().await?; self.uuid = self.block_io.get_uuid().await?; diff --git a/upstairs/src/stats.rs b/upstairs/src/stats.rs index bfe97c6a4..3b8d3b11f 100644 --- a/upstairs/src/stats.rs +++ b/upstairs/src/stats.rs @@ -2,8 +2,8 @@ use super::*; use oximeter::{ - types::{Cumulative, Sample}, Metric, MetricsError, Producer, Target, + types::{Cumulative, Sample}, }; // These structs are used to construct the desired stats for Oximeter. diff --git a/upstairs/src/test.rs b/upstairs/src/test.rs index ac98aec5f..bd6bb6d77 100644 --- a/upstairs/src/test.rs +++ b/upstairs/src/test.rs @@ -51,7 +51,7 @@ pub(crate) mod up_test { upstairs::Upstairs, }; - use base64::{engine, Engine}; + use base64::{Engine, engine}; use pseudo_file::IOSpan; // Create a simple logger @@ -398,8 +398,8 @@ pub(crate) mod up_test { // Validate that reading a blank block works #[test] - pub fn test_upstairs_validate_encrypted_read_response_blank_block( - ) -> Result<()> { + pub fn test_upstairs_validate_encrypted_read_response_blank_block() + -> Result<()> { // Set up the encryption context let mut key = vec![0u8; 32]; rand::fill(&mut key[..]); @@ -446,8 +446,8 @@ pub(crate) mod up_test { } #[test] - pub fn test_upstairs_validate_unencrypted_read_response_blank_block( - ) -> Result<()> { + pub fn test_upstairs_validate_unencrypted_read_response_blank_block() + -> Result<()> { let mut data = BytesMut::with_capacity(512); data.resize(512, 0u8); diff --git a/upstairs/src/upstairs.rs b/upstairs/src/upstairs.rs index a289fae75..33a956712 100644 --- a/upstairs/src/upstairs.rs +++ b/upstairs/src/upstairs.rs @@ -1,7 +1,9 @@ // Copyright 2023 Oxide Computer Company //! Data structures specific to Crucible's `struct Upstairs` use crate::{ - cdt, + BlockOp, BlockRes, Buffer, ClientId, ClientMap, ConnectionMode, + CrucibleOpts, DsState, EncryptionContext, GuestIoHandle, Message, + RegionDefinition, RegionDefinitionStatus, SnapshotDetails, WQCounts, cdt, client::{ ClientAction, ClientNegotiationFailed, ClientRunResult, ClientStopReason, NegotiationResult, NegotiationState, @@ -15,9 +17,6 @@ use crate::{ extent_from_offset, io_limits::IOLimitGuard, stats::UpStatOuter, - BlockOp, BlockRes, Buffer, ClientId, ClientMap, ConnectionMode, - CrucibleOpts, DsState, EncryptionContext, GuestIoHandle, Message, - RegionDefinition, RegionDefinitionStatus, SnapshotDetails, WQCounts, }; use crucible_client_types::RegionExtentInfo; use crucible_common::{BlockIndex, CrucibleError}; @@ -25,17 +24,17 @@ use serde::{Deserialize, Serialize}; use std::{ sync::{ - atomic::{AtomicU64, Ordering}, Arc, + atomic::{AtomicU64, Ordering}, }, time::Duration, }; use bytes::BytesMut; -use slog::{debug, error, info, o, warn, Logger}; +use slog::{Logger, debug, error, info, o, warn}; use tokio::{ sync::mpsc, - time::{sleep_until, Instant}, + time::{Instant, sleep_until}, }; use uuid::Uuid; @@ -314,7 +313,7 @@ impl UpstairsConfig { impl Upstairs { pub(crate) fn new( opt: &CrucibleOpts, - gen: u64, + generation: u64, expected_region_def: Option, guest: GuestIoHandle, tls_context: Option>, @@ -376,7 +375,7 @@ impl Upstairs { encryption_context, upstairs_id: uuid, session_id, - generation: AtomicU64::new(gen), + generation: AtomicU64::new(generation), read_only: opt.read_only, }); @@ -1018,12 +1017,12 @@ impl Upstairs { BlockOp::GoActive { done } => { self.set_active_request(done); } - BlockOp::GoActiveWithGen { gen, done } => { + BlockOp::GoActiveWithGen { generation, done } => { // We allow this if we are not active yet, or we are active // with the requested generation number. match &self.state { UpstairsState::Active | UpstairsState::GoActive(..) => { - if self.cfg.generation() == gen { + if self.cfg.generation() == generation { // Okay, we want to activate with what we already // have, that's valid; let the set_active_request // handle things. @@ -1044,7 +1043,9 @@ impl Upstairs { | UpstairsState::Disabled(..) => { // This case, we update our generation and then // let set_active_request handle the rest. - self.cfg.generation.store(gen, Ordering::Release); + self.cfg + .generation + .store(generation, Ordering::Release); self.set_active_request(done); } } @@ -2249,10 +2250,10 @@ impl Upstairs { pub(crate) mod test { use super::*; use crate::{ - client::{ClientFaultReason, ClientStopReason}, - test::{make_encrypted_upstairs, make_upstairs}, Block, BlockOp, BlockOpWaiter, DsStateData, JobId, NegotiationStateData, RegionMetadata, + client::{ClientFaultReason, ClientStopReason}, + test::{make_encrypted_upstairs, make_upstairs}, }; use bytes::BytesMut; use crucible_common::integrity_hash; diff --git a/upstairs/src/volume.rs b/upstairs/src/volume.rs index f83bcbab4..3fc5e3374 100644 --- a/upstairs/src/volume.rs +++ b/upstairs/src/volume.rs @@ -193,14 +193,14 @@ impl VolumeBuilder { &mut self, opts: CrucibleOpts, extent_info: RegionExtentInfo, - gen: u64, + generation: u64, producer_registry: Option, ) -> Result<(), CrucibleError> { let region_def = build_region_definition(&extent_info, &opts)?; let (guest, io) = Guest::new(Some(self.0.log.clone())); let _join_handle = - up_main(opts, gen, Some(region_def), io, producer_registry)?; + up_main(opts, generation, Some(region_def), io, producer_registry)?; self.add_subvolume(Arc::new(guest)).await } @@ -670,7 +670,7 @@ impl BlockIO for VolumeInner { } } - if let Some(ref read_only_parent) = &self.read_only_parent { + if let Some(read_only_parent) = &self.read_only_parent { read_only_parent.activate().await?; info!( self.log, @@ -681,9 +681,12 @@ impl BlockIO for VolumeInner { Ok(()) } - async fn activate_with_gen(&self, gen: u64) -> Result<(), CrucibleError> { + async fn activate_with_gen( + &self, + generation: u64, + ) -> Result<(), CrucibleError> { for sub_volume in &self.sub_volumes { - sub_volume.activate_with_gen(gen).await?; + sub_volume.activate_with_gen(generation).await?; info!( self.log, "Activated sub_volume {}", @@ -698,8 +701,8 @@ impl BlockIO for VolumeInner { } } - if let Some(ref read_only_parent) = &self.read_only_parent { - read_only_parent.activate_with_gen(gen).await?; + if let Some(read_only_parent) = &self.read_only_parent { + read_only_parent.activate_with_gen(generation).await?; info!( self.log, "Activated read_only_parent {}", @@ -728,7 +731,7 @@ impl BlockIO for VolumeInner { all_wq.active_count += sv_wq.active_count; } - if let Some(ref read_only_parent) = &self.read_only_parent { + if let Some(read_only_parent) = &self.read_only_parent { let rop_wq = read_only_parent.query_work_queue().await?; all_wq.up_count += rop_wq.up_count; all_wq.ds_count += rop_wq.ds_count; @@ -753,7 +756,7 @@ impl BlockIO for VolumeInner { sub_volume.deactivate().await?; } - if let Some(ref read_only_parent) = &self.read_only_parent { + if let Some(read_only_parent) = &self.read_only_parent { read_only_parent.deactivate().await?; } @@ -767,7 +770,7 @@ impl BlockIO for VolumeInner { } } - if let Some(ref read_only_parent) = &self.read_only_parent { + if let Some(read_only_parent) = &self.read_only_parent { if !read_only_parent.query_is_active().await? { return Ok(false); } @@ -788,7 +791,7 @@ impl BlockIO for VolumeInner { } Ok(total_blocks * self.block_size) - } else if let Some(ref read_only_parent) = &self.read_only_parent { + } else if let Some(read_only_parent) = &self.read_only_parent { // If this volume only has a read only parent, report that size for // total size let total_blocks = read_only_parent.lba_range.end @@ -824,7 +827,7 @@ impl BlockIO for VolumeInner { } if self.sub_volumes.is_empty() { - if let Some(ref read_only_parent) = &self.read_only_parent { + if let Some(read_only_parent) = &self.read_only_parent { let res = read_only_parent.read(offset, data).await; cdt::volume__read__done!(|| (cc, self.uuid)); return res; @@ -956,7 +959,7 @@ impl BlockIO for VolumeInner { wq_counts.active_count += sub_wq_counts.active_count; } - if let Some(ref read_only_parent) = &self.read_only_parent { + if let Some(read_only_parent) = &self.read_only_parent { let sub_wq_counts = read_only_parent.show_work().await?; wq_counts.up_count += sub_wq_counts.up_count; @@ -1128,8 +1131,11 @@ impl BlockIO for SubVolume { async fn activate(&self) -> Result<(), CrucibleError> { self.block_io.activate().await } - async fn activate_with_gen(&self, gen: u64) -> Result<(), CrucibleError> { - self.block_io.activate_with_gen(gen).await + async fn activate_with_gen( + &self, + generation: u64, + ) -> Result<(), CrucibleError> { + self.block_io.activate_with_gen(generation).await } async fn query_work_queue(&self) -> Result { self.block_io.query_work_queue().await @@ -1273,7 +1279,7 @@ impl Volume { blocks_per_extent, extent_count, opts, - gen, + generation, } => { let mut vol = VolumeBuilder::new(block_size, log.clone()); vol.add_subvolume_create_guest( @@ -1283,7 +1289,7 @@ impl Volume { blocks_per_extent, extent_count, }, - gen, + generation, producer_registry, ) .await?; @@ -1660,8 +1666,14 @@ impl Volume { blocks_per_extent, extent_count, ref opts, - gen, - } => (block_size, blocks_per_extent, extent_count, opts, gen), + generation, + } => ( + block_size, + blocks_per_extent, + extent_count, + opts, + generation, + ), _ => { crucible_bail!( @@ -1683,8 +1695,14 @@ impl Volume { blocks_per_extent, extent_count, ref opts, - gen, - } => (block_size, blocks_per_extent, extent_count, opts, gen), + generation, + } => ( + block_size, + blocks_per_extent, + extent_count, + opts, + generation, + ), _ => { crucible_bail!( @@ -1940,9 +1958,9 @@ mod test { use std::fs::File; use std::io::Write; - use base64::{engine, Engine}; + use base64::{Engine, engine}; use fakedata_generator::gen_ipv4; - use slog::{o, Drain, Logger}; + use slog::{Drain, Logger, o}; use tempfile::tempdir; // Create a simple logger @@ -2465,8 +2483,8 @@ mod test { } #[tokio::test] - async fn test_parent_initialized_read_only_region_one_subvolume( - ) -> Result<()> { + async fn test_parent_initialized_read_only_region_one_subvolume() + -> Result<()> { const BLOCK_SIZE: u64 = 512; // test initializing the read only parent with all byte values @@ -2558,8 +2576,8 @@ mod test { } #[tokio::test] - async fn test_parent_uninitialized_read_only_region_one_subvolume( - ) -> Result<()> { + async fn test_parent_uninitialized_read_only_region_one_subvolume() + -> Result<()> { const BLOCK_SIZE: u64 = 512; // test an uninitialized read only parent @@ -2589,8 +2607,8 @@ mod test { } #[tokio::test] - async fn test_parent_initialized_read_only_region_with_multiple_sub_volumes_1( - ) -> Result<()> { + async fn test_parent_initialized_read_only_region_with_multiple_sub_volumes_1() + -> Result<()> { const BLOCK_SIZE: u64 = 512; for i in 0x00..0xFF { @@ -2636,8 +2654,8 @@ mod test { } #[tokio::test] - async fn test_parent_uninitialized_read_only_region_with_multiple_sub_volumes_1( - ) -> Result<()> { + async fn test_parent_uninitialized_read_only_region_with_multiple_sub_volumes_1() + -> Result<()> { const BLOCK_SIZE: u64 = 512; let parent = @@ -2667,8 +2685,8 @@ mod test { } #[tokio::test] - async fn test_parent_initialized_read_only_region_with_multiple_sub_volumes_2( - ) -> Result<()> { + async fn test_parent_initialized_read_only_region_with_multiple_sub_volumes_2() + -> Result<()> { const BLOCK_SIZE: u64 = 512; for i in 0x00..0xFF { @@ -2714,8 +2732,8 @@ mod test { } #[tokio::test] - async fn test_parent_uninitialized_read_only_region_with_multiple_sub_volumes_2( - ) -> Result<()> { + async fn test_parent_uninitialized_read_only_region_with_multiple_sub_volumes_2() + -> Result<()> { const BLOCK_SIZE: u64 = 512; let parent = @@ -3585,7 +3603,7 @@ mod test { blocks_per_extent: u64, extent_count: u32, opts: CrucibleOpts, - gen: u64, + generation: u64, ) -> Vec { (0..sv_count) .map(|i| { @@ -3601,7 +3619,7 @@ mod test { blocks_per_extent, extent_count, opts: new_opts, - gen, + generation, } }) .collect() @@ -3625,9 +3643,11 @@ mod test { for (i, sv) in new_vcr_vec.iter_mut().enumerate() { match sv { - VolumeConstructionRequest::Region { opts, gen, .. } => { + VolumeConstructionRequest::Region { + opts, generation, .. + } => { if change_gen { - *gen += 1; + *generation += 1; } if i == sv_changed { opts.target[cid] = new_target; @@ -3698,7 +3718,7 @@ mod test { blocks_per_extent, extent_count, opts: opts.clone(), - gen: 3, + generation: 3, }); let (original_rop, replacement_rop) = match rop_mode { @@ -3747,9 +3767,13 @@ mod test { }; let log = csl(); - info!(log, + info!( + log, "replacement of CID {} with sv_count:{} sv_changed:{} rop_mode:{:?}", - cid, sv_count, sv_changed, rop_mode + cid, + sv_count, + sv_changed, + rop_mode ); let ReplacementRequestCheck::Valid { old, new } = Volume::compare_vcr_for_target_replacement( @@ -3801,7 +3825,7 @@ mod test { blocks_per_extent, extent_count, opts: opts.clone(), - gen: 3, + generation: 3, }); let (original_rop, replacement_rop) = match rop_mode { @@ -3855,7 +3879,7 @@ mod test { blocks_per_extent, extent_count, opts: replacement_opts.clone(), - gen: 1, // Lower generation, should cause the error. + generation: 1, // Lower generation, should cause the error. } }) .collect(); @@ -3900,7 +3924,7 @@ mod test { blocks_per_extent, extent_count, opts: opts.clone(), - gen: 3, + generation: 3, }); let original = VolumeConstructionRequest::Volume { @@ -3911,7 +3935,7 @@ mod test { blocks_per_extent, extent_count, opts: opts.clone(), - gen: 2, + generation: 2, }], read_only_parent: Some(rop), }; @@ -3928,7 +3952,7 @@ mod test { blocks_per_extent, extent_count, opts: opts.clone(), - gen: 3, + generation: 3, }], read_only_parent: None, }; @@ -3979,7 +4003,7 @@ mod test { blocks_per_extent, extent_count, opts: opts.clone(), - gen: 3, + generation: 3, }); Some(test_rop) } @@ -4007,12 +4031,14 @@ mod test { let log = csl(); - assert!(Volume::compare_vcr_for_target_replacement( - original.clone(), - original, - &log - ) - .is_err()); + assert!( + Volume::compare_vcr_for_target_replacement( + original.clone(), + original, + &log + ) + .is_err() + ); } #[test] @@ -4045,7 +4071,7 @@ mod test { blocks_per_extent, extent_count, opts: opts.clone(), - gen: 3, + generation: 3, }); let (original_rop, replacement_rop) = match rop_mode { @@ -4076,8 +4102,8 @@ mod test { // Update the sub_volumes for the replacement. for sv in sub_volumes.iter_mut() { match sv { - VolumeConstructionRequest::Region { gen, .. } => { - *gen += 1; + VolumeConstructionRequest::Region { generation, .. } => { + *generation += 1; } _ => { panic!("Invalid VCR"); @@ -4184,12 +4210,14 @@ mod test { sv_changed, ); - assert!(Volume::compare_vcr_for_target_replacement( - original, - replacement, - &log - ) - .is_err()); + assert!( + Volume::compare_vcr_for_target_replacement( + original, + replacement, + &log + ) + .is_err() + ); } #[test] @@ -4253,12 +4281,14 @@ mod test { sv_count, sv_changed, ); - assert!(Volume::compare_vcr_for_target_replacement( - original, - replacement, - &log - ) - .is_err()); + assert!( + Volume::compare_vcr_for_target_replacement( + original, + replacement, + &log + ) + .is_err() + ); } #[test] @@ -4319,7 +4349,7 @@ mod test { blocks_per_extent, extent_count, opts: opts.clone(), - gen: 3, + generation: 3, }, )), }; @@ -4331,12 +4361,14 @@ mod test { sv_count, sv_changed, ); - assert!(Volume::compare_vcr_for_target_replacement( - original, - replacement, - &log - ) - .is_err()); + assert!( + Volume::compare_vcr_for_target_replacement( + original, + replacement, + &log + ) + .is_err() + ); } #[test] @@ -4388,7 +4420,7 @@ mod test { blocks_per_extent, extent_count, opts: rop_opts.clone(), - gen: 4, + generation: 4, }, )), }; @@ -4402,8 +4434,10 @@ mod test { // Use the same sub-volume, just bump the generation numbers for sv in sub_volumes.iter_mut() { match sv { - VolumeConstructionRequest::Region { gen, .. } => { - *gen += 1; + VolumeConstructionRequest::Region { + generation, .. + } => { + *generation += 1; } _ => { panic!("Unsupported VCR"); @@ -4424,7 +4458,7 @@ mod test { blocks_per_extent, extent_count, opts: rop_opts.clone(), - gen: 4, + generation: 4, }, )), }; @@ -4489,7 +4523,7 @@ mod test { blocks_per_extent, extent_count, opts: rop_opts.clone(), - gen: 4, + generation: 4, }; let new_target: SocketAddr = "127.0.0.1:8888".parse().unwrap(); @@ -4524,7 +4558,7 @@ mod test { blocks_per_extent, extent_count, opts: rop_opts.clone(), - gen: 4, + generation: 4, }, )), }; @@ -4537,12 +4571,14 @@ mod test { sv_changed, ); - assert!(Volume::compare_vcr_for_target_replacement( - original, - replacement, - &log - ) - .is_err()); + assert!( + Volume::compare_vcr_for_target_replacement( + original, + replacement, + &log + ) + .is_err() + ); } #[test] @@ -4598,7 +4634,7 @@ mod test { blocks_per_extent, extent_count, opts: replacement_opts, - gen: replacement_gen, + generation: replacement_gen, } }) .collect(); @@ -4617,12 +4653,14 @@ mod test { sv_count, sv_changed, ); - assert!(Volume::compare_vcr_for_target_replacement( - original, - replacement, - &log - ) - .is_err()); + assert!( + Volume::compare_vcr_for_target_replacement( + original, + replacement, + &log + ) + .is_err() + ); } #[test] @@ -4682,7 +4720,7 @@ mod test { blocks_per_extent: replacement_bpe, extent_count, opts: replacement_opts, - gen: replacement_gen, + generation: replacement_gen, } }) .collect(); @@ -4701,12 +4739,14 @@ mod test { sv_count, sv_changed, ); - assert!(Volume::compare_vcr_for_target_replacement( - original, - replacement, - &log - ) - .is_err()); + assert!( + Volume::compare_vcr_for_target_replacement( + original, + replacement, + &log + ) + .is_err() + ); } #[test] @@ -4761,7 +4801,7 @@ mod test { blocks_per_extent, extent_count: replacement_ec, opts: replacement_opts, - gen: replacement_gen, + generation: replacement_gen, } }) .collect(); @@ -4774,8 +4814,10 @@ mod test { }; let log = csl(); - assert!(Volume::compare_vcr_for_update(original, replacement, &log) - .is_err()); + assert!( + Volume::compare_vcr_for_update(original, replacement, &log) + .is_err() + ); } // This is a wrapper function to test changing CrucibleOpts structures. @@ -4825,7 +4867,7 @@ mod test { blocks_per_extent, extent_count, opts: replacement_opts, - gen: replacement_gen, + generation: replacement_gen, } }) .collect(); @@ -4868,17 +4910,19 @@ mod test { for sv in 1..4 { for sv_changed in 0..sv { - assert!(test_volume_replace_opts( - vol_id, - 512, - blocks_per_extent, - extent_count, - o_opts.clone(), - n_opts.clone(), - sv, - sv_changed, - ) - .is_err()); + assert!( + test_volume_replace_opts( + vol_id, + 512, + blocks_per_extent, + extent_count, + o_opts.clone(), + n_opts.clone(), + sv, + sv_changed, + ) + .is_err() + ); } } } @@ -4902,17 +4946,19 @@ mod test { for sv in 1..4 { for sv_changed in 0..sv { - assert!(test_volume_replace_opts( - vol_id, - 512, - blocks_per_extent, - extent_count, - o_opts.clone(), - n_opts.clone(), - sv, - sv_changed, - ) - .is_err()); + assert!( + test_volume_replace_opts( + vol_id, + 512, + blocks_per_extent, + extent_count, + o_opts.clone(), + n_opts.clone(), + sv, + sv_changed, + ) + .is_err() + ); } } } @@ -4936,17 +4982,19 @@ mod test { for sv in 1..4 { for sv_changed in 0..sv { - assert!(test_volume_replace_opts( - vol_id, - 512, - blocks_per_extent, - extent_count, - o_opts.clone(), - n_opts.clone(), - sv, - sv_changed, - ) - .is_err()); + assert!( + test_volume_replace_opts( + vol_id, + 512, + blocks_per_extent, + extent_count, + o_opts.clone(), + n_opts.clone(), + sv, + sv_changed, + ) + .is_err() + ); } } } @@ -4972,17 +5020,19 @@ mod test { for sv in 1..4 { for sv_changed in 0..sv { - assert!(test_volume_replace_opts( - vol_id, - 512, - blocks_per_extent, - extent_count, - o_opts.clone(), - n_opts.clone(), - sv, - sv_changed, - ) - .is_err()); + assert!( + test_volume_replace_opts( + vol_id, + 512, + blocks_per_extent, + extent_count, + o_opts.clone(), + n_opts.clone(), + sv, + sv_changed, + ) + .is_err() + ); } } } @@ -5006,17 +5056,19 @@ mod test { for sv in 1..4 { for sv_changed in 0..sv { - assert!(test_volume_replace_opts( - vol_id, - 512, - blocks_per_extent, - extent_count, - o_opts.clone(), - n_opts.clone(), - sv, - sv_changed, - ) - .is_err()); + assert!( + test_volume_replace_opts( + vol_id, + 512, + blocks_per_extent, + extent_count, + o_opts.clone(), + n_opts.clone(), + sv, + sv_changed, + ) + .is_err() + ); } } } @@ -5040,17 +5092,19 @@ mod test { for sv in 1..4 { for sv_changed in 0..sv { - assert!(test_volume_replace_opts( - vol_id, - 512, - blocks_per_extent, - extent_count, - o_opts.clone(), - n_opts.clone(), - sv, - sv_changed, - ) - .is_err()); + assert!( + test_volume_replace_opts( + vol_id, + 512, + blocks_per_extent, + extent_count, + o_opts.clone(), + n_opts.clone(), + sv, + sv_changed, + ) + .is_err() + ); } } } @@ -5074,17 +5128,19 @@ mod test { for sv in 1..4 { for sv_changed in 0..sv { - assert!(test_volume_replace_opts( - vol_id, - 512, - blocks_per_extent, - extent_count, - o_opts.clone(), - n_opts.clone(), - sv, - sv_changed, - ) - .is_err()); + assert!( + test_volume_replace_opts( + vol_id, + 512, + blocks_per_extent, + extent_count, + o_opts.clone(), + n_opts.clone(), + sv, + sv_changed, + ) + .is_err() + ); } } } @@ -5108,17 +5164,19 @@ mod test { for sv in 1..4 { for sv_changed in 0..sv { - assert!(test_volume_replace_opts( - vol_id, - 512, - blocks_per_extent, - extent_count, - o_opts.clone(), - n_opts.clone(), - sv, - sv_changed, - ) - .is_err()); + assert!( + test_volume_replace_opts( + vol_id, + 512, + blocks_per_extent, + extent_count, + o_opts.clone(), + n_opts.clone(), + sv, + sv_changed, + ) + .is_err() + ); } } } @@ -5142,17 +5200,19 @@ mod test { for sv in 1..4 { for sv_changed in 0..sv { - assert!(test_volume_replace_opts( - vol_id, - 512, - blocks_per_extent, - extent_count, - o_opts.clone(), - n_opts.clone(), - sv, - sv_changed, - ) - .is_err()); + assert!( + test_volume_replace_opts( + vol_id, + 512, + blocks_per_extent, + extent_count, + o_opts.clone(), + n_opts.clone(), + sv, + sv_changed, + ) + .is_err() + ); } } } @@ -5168,7 +5228,7 @@ mod test { block_size: 512, blocks_per_extent: 131072, extent_count: 128, - gen: 3, + generation: 3, opts: CrucibleOpts { id: vol_id, target: vec![ @@ -5187,7 +5247,7 @@ mod test { block_size: 512, blocks_per_extent: 131072, extent_count: 32, - gen: 2, + generation: 2, opts: CrucibleOpts { id: Uuid::new_v4(), target: vec![ @@ -5219,8 +5279,10 @@ mod test { .. } => { match &mut sub_volumes[0] { - VolumeConstructionRequest::Region { gen, .. } => { - *gen += 1; + VolumeConstructionRequest::Region { + generation, .. + } => { + *generation += 1; } _ => { @@ -5282,7 +5344,7 @@ mod test { block_size: 512, blocks_per_extent: 131072, extent_count: 128, - gen: 3, + generation: 3, opts: CrucibleOpts { id: vol_id, target: vec![ @@ -5301,7 +5363,7 @@ mod test { block_size: 512, blocks_per_extent: 131072, extent_count: 32, - gen: 2, + generation: 2, opts: CrucibleOpts { id: Uuid::new_v4(), target: vec![ @@ -5327,7 +5389,7 @@ mod test { block_size: 512, blocks_per_extent: 131072, extent_count: 32, - gen: 1, + generation: 1, opts: CrucibleOpts { id: Uuid::new_v4(), target: vec![ @@ -5434,7 +5496,7 @@ mod test { block_size: 512, blocks_per_extent: 131072, extent_count: 128, - gen: 3, + generation: 3, opts: CrucibleOpts { id: vol_id, target: vec![ @@ -5453,7 +5515,7 @@ mod test { block_size: 512, blocks_per_extent: 131072, extent_count: 32, - gen: 2, + generation: 2, opts: CrucibleOpts { id: Uuid::new_v4(), target: vec![ @@ -5485,8 +5547,10 @@ mod test { .. } => { match &mut sub_volumes[0] { - VolumeConstructionRequest::Region { gen, .. } => { - *gen += 1; + VolumeConstructionRequest::Region { + generation, .. + } => { + *generation += 1; } _ => { @@ -5503,13 +5567,15 @@ mod test { sub_volumes, .. } => match &mut sub_volumes[0] { VolumeConstructionRequest::Region { - opts, gen, .. + opts, + generation, + .. } => { opts.target[1] = "[fd00:1122:3344:111::a]:20000" .parse() .unwrap(); - *gen += 1; + *generation += 1; } _ => { @@ -5552,7 +5618,7 @@ mod test { block_size: 512, blocks_per_extent: 131072, extent_count: 128, - gen: 3, + generation: 3, opts: CrucibleOpts { id: vol_id, target: vec![ @@ -5571,7 +5637,7 @@ mod test { block_size: 512, blocks_per_extent: 131072, extent_count: 32, - gen: 2, + generation: 2, opts: CrucibleOpts { id: Uuid::new_v4(), target: vec![ @@ -5603,8 +5669,10 @@ mod test { .. } => { match &mut sub_volumes[0] { - VolumeConstructionRequest::Region { gen, .. } => { - *gen += 1; + VolumeConstructionRequest::Region { + generation, .. + } => { + *generation += 1; } _ => { @@ -5621,13 +5689,15 @@ mod test { sub_volumes, .. } => match &mut sub_volumes[0] { VolumeConstructionRequest::Region { - opts, gen, .. + opts, + generation, + .. } => { opts.target[1] = "[fd00:1122:3344:111::a]:20000" .parse() .unwrap(); - *gen -= 1; + *generation -= 1; } _ => { @@ -5663,7 +5733,7 @@ mod test { block_size: 512, blocks_per_extent: 131072, extent_count: 128, - gen: 3, + generation: 3, opts: CrucibleOpts { id: vol_id, target: vec![ @@ -5682,7 +5752,7 @@ mod test { block_size: 512, blocks_per_extent: 131072, extent_count: 32, - gen: 2, + generation: 2, opts: CrucibleOpts { id: Uuid::new_v4(), target: vec![ @@ -5775,7 +5845,7 @@ mod test { control: None, read_only: false, }, - gen: 1, + generation: 1, }], read_only_parent: None, }; @@ -5805,7 +5875,7 @@ mod test { control: None, read_only: false, }, - gen: 1, + generation: 1, }, VolumeConstructionRequest::Region { block_size: 4096, @@ -5823,7 +5893,7 @@ mod test { control: None, read_only: false, }, - gen: 1, + generation: 1, }, ], read_only_parent: None, @@ -5853,7 +5923,7 @@ mod test { control: None, read_only: false, }, - gen: 1, + generation: 1, }], read_only_parent: Some(Box::new( VolumeConstructionRequest::Region { @@ -5872,7 +5942,7 @@ mod test { control: None, read_only: false, }, - gen: 1, + generation: 1, }, )), }; @@ -5901,7 +5971,7 @@ mod test { control: None, read_only: false, }, - gen: 1, + generation: 1, }], read_only_parent: Some(Box::new( VolumeConstructionRequest::Volume { @@ -5923,7 +5993,7 @@ mod test { control: None, read_only: false, }, - gen: 1, + generation: 1, }], read_only_parent: None, }, diff --git a/workspace-hack/Cargo.toml b/workspace-hack/Cargo.toml index 96ce671e3..3030a668b 100644 --- a/workspace-hack/Cargo.toml +++ b/workspace-hack/Cargo.toml @@ -6,7 +6,7 @@ name = "crucible-workspace-hack" version = "0.1.0" description = "workspace-hack package, managed by hakari" -edition = "2021" +edition = "2024" # You can choose to publish this crate: see https://docs.rs/cargo-hakari/latest/cargo_hakari/publishing. publish = false