diff --git a/src/dbus_api/api/manager_3_0/methods.rs b/src/dbus_api/api/manager_3_0/methods.rs index 7f9cda5e7e..5b6ee29ab0 100644 --- a/src/dbus_api/api/manager_3_0/methods.rs +++ b/src/dbus_api/api/manager_3_0/methods.rs @@ -22,7 +22,7 @@ use crate::{ util::{engine_to_dbus_err_tuple, get_next_arg, tuple_to_option}, }, engine::{ - CreateAction, DeleteAction, EncryptionInfo, EngineAction, KeyDescription, + CreateAction, DeleteAction, EncryptionInfo, EngineAction, IntegritySpec, KeyDescription, MappingCreateAction, MappingDeleteAction, PoolIdentifier, PoolUuid, SetUnlockAction, UnlockMethod, }, @@ -328,8 +328,7 @@ pub fn create_pool(m: &MethodInfo<'_, MTSync, TData>) -> MethodResult { name, &devs.map(Path::new).collect::>(), EncryptionInfo::from_options((key_desc, clevis_info)).as_ref(), - None, - None, + IntegritySpec::default(), ))); match create_result { Ok(pool_uuid_action) => match pool_uuid_action { diff --git a/src/dbus_api/api/manager_3_5/methods.rs b/src/dbus_api/api/manager_3_5/methods.rs index e3f12233da..573358cb60 100644 --- a/src/dbus_api/api/manager_3_5/methods.rs +++ b/src/dbus_api/api/manager_3_5/methods.rs @@ -15,7 +15,7 @@ use crate::{ types::{DbusErrorEnum, TData, OK_STRING}, util::{engine_to_dbus_err_tuple, get_next_arg, tuple_to_option}, }, - engine::{CreateAction, EncryptionInfo, KeyDescription, PoolIdentifier}, + engine::{CreateAction, EncryptionInfo, IntegritySpec, KeyDescription, PoolIdentifier}, stratis::StratisError, }; @@ -65,8 +65,7 @@ pub fn create_pool(m: &MethodInfo<'_, MTSync, TData>) -> MethodResult { name, &devs.map(Path::new).collect::>(), EncryptionInfo::from_options((key_desc, clevis_info)).as_ref(), - None, - None, + IntegritySpec::default(), ))); match create_result { Ok(pool_uuid_action) => match pool_uuid_action { diff --git a/src/dbus_api/api/manager_3_8/methods.rs b/src/dbus_api/api/manager_3_8/methods.rs index 2d3411862d..cece3e0fc8 100644 --- a/src/dbus_api/api/manager_3_8/methods.rs +++ b/src/dbus_api/api/manager_3_8/methods.rs @@ -23,8 +23,8 @@ use crate::{ util::{engine_to_dbus_err_tuple, get_next_arg, tuple_to_option}, }, engine::{ - CreateAction, EncryptionInfo, IntegrityTagSpec, KeyDescription, Name, PoolIdentifier, - PoolUuid, StartAction, UnlockMethod, + CreateAction, EncryptionInfo, IntegritySpec, IntegrityTagSpec, KeyDescription, Name, + PoolIdentifier, PoolUuid, StartAction, UnlockMethod, }, stratis::StratisError, }; @@ -206,8 +206,10 @@ pub fn create_pool(m: &MethodInfo<'_, MTSync, TData>) -> MethodResult { name, &devs.map(Path::new).collect::>(), EncryptionInfo::from_options((key_desc, clevis_info)).as_ref(), - journal_size, - tag_spec, + IntegritySpec { + journal_size, + tag_spec + }, ))); match create_result { Ok(pool_uuid_action) => match pool_uuid_action { diff --git a/src/engine/engine.rs b/src/engine/engine.rs index 5b08d62417..1b192fedc0 100644 --- a/src/engine/engine.rs +++ b/src/engine/engine.rs @@ -21,7 +21,7 @@ use crate::{ structures::{AllLockReadGuard, AllLockWriteGuard, SomeLockReadGuard, SomeLockWriteGuard}, types::{ ActionAvailability, BlockDevTier, Clevis, CreateAction, DeleteAction, DevUuid, - EncryptionInfo, FilesystemUuid, GrowAction, IntegrityTagSpec, Key, KeyDescription, + EncryptionInfo, FilesystemUuid, GrowAction, IntegritySpec, Key, KeyDescription, LockedPoolsInfo, MappingCreateAction, MappingDeleteAction, Name, PoolDiff, PoolEncryptionInfo, PoolIdentifier, PoolUuid, RegenAction, RenameAction, ReportType, SetCreateAction, SetDeleteAction, SetUnlockAction, StartAction, StopAction, @@ -382,8 +382,7 @@ pub trait Engine: Debug + Report + Send + Sync { name: &str, blockdev_paths: &[&Path], encryption_info: Option<&EncryptionInfo>, - journal_size: Option, - tag_spec: Option, + integrity_spec: IntegritySpec, ) -> StratisResult>; /// Handle a libudev event. diff --git a/src/engine/mod.rs b/src/engine/mod.rs index 5281cbe2cb..e5399799d2 100644 --- a/src/engine/mod.rs +++ b/src/engine/mod.rs @@ -21,10 +21,10 @@ pub use self::{ structures::{AllLockReadGuard, ExclusiveGuard, SharedGuard, Table}, types::{ ActionAvailability, BlockDevTier, ClevisInfo, CreateAction, DeleteAction, DevUuid, Diff, - EncryptionInfo, EngineAction, FilesystemUuid, GrowAction, IntegrityTagSpec, KeyDescription, - Lockable, LockedPoolInfo, LockedPoolsInfo, MappingCreateAction, MappingDeleteAction, - MaybeInconsistent, Name, PoolDiff, PoolEncryptionInfo, PoolIdentifier, PoolUuid, - PropChangeAction, RenameAction, ReportType, SetCreateAction, SetDeleteAction, + EncryptionInfo, EngineAction, FilesystemUuid, GrowAction, IntegritySpec, IntegrityTagSpec, + KeyDescription, Lockable, LockedPoolInfo, LockedPoolsInfo, MappingCreateAction, + MappingDeleteAction, MaybeInconsistent, Name, PoolDiff, PoolEncryptionInfo, PoolIdentifier, + PoolUuid, PropChangeAction, RenameAction, ReportType, SetCreateAction, SetDeleteAction, SetUnlockAction, StartAction, StopAction, StoppedPoolInfo, StoppedPoolsInfo, StratBlockDevDiff, StratFilesystemDiff, StratPoolDiff, StratSigblockVersion, StratisUuid, ThinPoolDiff, ToDisplay, UdevEngineEvent, UnlockMethod, diff --git a/src/engine/sim_engine/engine.rs b/src/engine/sim_engine/engine.rs index e6c84678ba..802e4f47d7 100644 --- a/src/engine/sim_engine/engine.rs +++ b/src/engine/sim_engine/engine.rs @@ -14,8 +14,6 @@ use futures::executor::block_on; use serde_json::{json, Value}; use tokio::sync::RwLock; -use devicemapper::Bytes; - use crate::{ engine::{ engine::{Engine, HandleEvents, KeyActions, Pool, Report}, @@ -27,9 +25,9 @@ use crate::{ }, types::{ CreateAction, DeleteAction, DevUuid, EncryptionInfo, Features, FilesystemUuid, - IntegrityTagSpec, LockedPoolsInfo, Name, PoolDevice, PoolDiff, PoolIdentifier, - PoolUuid, RenameAction, ReportType, SetUnlockAction, StartAction, StopAction, - StoppedPoolInfo, StoppedPoolsInfo, StratFilesystemDiff, UdevEngineEvent, UnlockMethod, + IntegritySpec, LockedPoolsInfo, Name, PoolDevice, PoolDiff, PoolIdentifier, PoolUuid, + RenameAction, ReportType, SetUnlockAction, StartAction, StopAction, StoppedPoolInfo, + StoppedPoolsInfo, StratFilesystemDiff, UdevEngineEvent, UnlockMethod, }, StratSigblockVersion, }, @@ -131,8 +129,7 @@ impl Engine for SimEngine { name: &str, blockdev_paths: &[&Path], encryption_info: Option<&EncryptionInfo>, - _: Option, - _: Option, + _: IntegritySpec, ) -> StratisResult> { validate_name(name)?; let name = Name::new(name.to_owned()); @@ -444,8 +441,7 @@ mod tests { "name", strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None + IntegritySpec::default(), )) .unwrap() .changed() @@ -457,11 +453,15 @@ mod tests { /// Destroying a pool with devices should succeed fn destroy_pool_w_devices() { let engine = SimEngine::default(); - let uuid = - test_async!(engine.create_pool("name", strs_to_paths!(["/s/d"]), None, None, None)) - .unwrap() - .changed() - .unwrap(); + let uuid = test_async!(engine.create_pool( + "name", + strs_to_paths!(["/s/d"]), + None, + IntegritySpec::default() + )) + .unwrap() + .changed() + .unwrap(); assert!(test_async!(engine.destroy_pool(uuid)).is_ok()); } @@ -470,11 +470,15 @@ mod tests { fn destroy_pool_w_filesystem() { let engine = SimEngine::default(); let pool_name = "pool_name"; - let uuid = - test_async!(engine.create_pool(pool_name, strs_to_paths!(["/s/d"]), None, None, None)) - .unwrap() - .changed() - .unwrap(); + let uuid = test_async!(engine.create_pool( + pool_name, + strs_to_paths!(["/s/d"]), + None, + IntegritySpec::default() + )) + .unwrap() + .changed() + .unwrap(); { let mut pool = test_async!(engine.get_mut_pool(PoolIdentifier::Uuid(uuid))).unwrap(); pool.create_filesystems(pool_name, uuid, &[("test", None, None)]) @@ -490,9 +494,9 @@ mod tests { let name = "name"; let engine = SimEngine::default(); let devices = strs_to_paths!(["/s/d"]); - test_async!(engine.create_pool(name, devices, None, None, None)).unwrap(); + test_async!(engine.create_pool(name, devices, None, IntegritySpec::default())).unwrap(); assert_matches!( - test_async!(engine.create_pool(name, devices, None, None, None)), + test_async!(engine.create_pool(name, devices, None, IntegritySpec::default())), Ok(CreateAction::Identity) ); } @@ -502,13 +506,18 @@ mod tests { fn create_pool_name_collision_different_args() { let name = "name"; let engine = SimEngine::default(); - test_async!(engine.create_pool(name, strs_to_paths!(["/s/d"]), None, None, None)).unwrap(); + test_async!(engine.create_pool( + name, + strs_to_paths!(["/s/d"]), + None, + IntegritySpec::default() + )) + .unwrap(); assert!(test_async!(engine.create_pool( name, strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .is_err()); } @@ -519,15 +528,20 @@ mod tests { let path = "/s/d"; let engine = SimEngine::default(); assert_matches!( - test_async!(engine.create_pool("name", strs_to_paths!([path, path]), None, None, None)) - .unwrap() - .changed() - .map( - |uuid| test_async!(engine.get_pool(PoolIdentifier::Uuid(uuid))) - .unwrap() - .blockdevs() - .len() - ), + test_async!(engine.create_pool( + "name", + strs_to_paths!([path, path]), + None, + IntegritySpec::default() + )) + .unwrap() + .changed() + .map( + |uuid| test_async!(engine.get_pool(PoolIdentifier::Uuid(uuid))) + .unwrap() + .blockdevs() + .len() + ), Some(1) ); } @@ -551,8 +565,7 @@ mod tests { name, strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() @@ -571,8 +584,7 @@ mod tests { "old_name", strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() @@ -592,8 +604,7 @@ mod tests { "old_name", strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() @@ -602,8 +613,7 @@ mod tests { new_name, strs_to_paths!(["/dev/four", "/dev/five", "/dev/six"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap(); assert!(test_async!(engine.rename_pool(uuid, new_name)).is_err()); @@ -618,8 +628,7 @@ mod tests { new_name, strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap(); assert_matches!( diff --git a/src/engine/sim_engine/pool.rs b/src/engine/sim_engine/pool.rs index b475b5170e..1f7ec712e8 100644 --- a/src/engine/sim_engine/pool.rs +++ b/src/engine/sim_engine/pool.rs @@ -882,7 +882,7 @@ mod tests { use crate::engine::{ sim_engine::SimEngine, - types::{EngineAction, PoolIdentifier}, + types::{EngineAction, IntegritySpec, PoolIdentifier}, Engine, }; @@ -897,8 +897,7 @@ mod tests { pool_name, strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() @@ -919,8 +918,7 @@ mod tests { pool_name, strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() @@ -949,8 +947,7 @@ mod tests { pool_name, strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() @@ -982,8 +979,7 @@ mod tests { pool_name, strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() @@ -1004,8 +1000,7 @@ mod tests { pool_name, strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() @@ -1026,8 +1021,7 @@ mod tests { pool_name, strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() @@ -1048,8 +1042,7 @@ mod tests { pool_name, strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() @@ -1078,8 +1071,7 @@ mod tests { pool_name, strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() @@ -1098,8 +1090,7 @@ mod tests { pool_name, strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() @@ -1125,8 +1116,7 @@ mod tests { pool_name, strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() @@ -1150,8 +1140,7 @@ mod tests { pool_name, strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() @@ -1179,8 +1168,7 @@ mod tests { "pool_name", strs_to_paths!(["/dev/one", "/dev/two", "/dev/three"]), None, - None, - None, + IntegritySpec::default(), )) .unwrap() .changed() diff --git a/src/engine/strat_engine/engine.rs b/src/engine/strat_engine/engine.rs index b626281994..5fb8a6351b 100644 --- a/src/engine/strat_engine/engine.rs +++ b/src/engine/strat_engine/engine.rs @@ -37,7 +37,7 @@ use crate::{ SomeLockWriteGuard, Table, }, types::{ - CreateAction, DeleteAction, DevUuid, EncryptionInfo, FilesystemUuid, IntegrityTagSpec, + CreateAction, DeleteAction, DevUuid, EncryptionInfo, FilesystemUuid, IntegritySpec, LockedPoolsInfo, PoolDiff, PoolIdentifier, RenameAction, ReportType, SetUnlockAction, StartAction, StopAction, StoppedPoolsInfo, StratFilesystemDiff, UdevEngineEvent, UnlockMethod, @@ -495,12 +495,11 @@ impl Engine for StratEngine { name: &str, blockdev_paths: &[&Path], encryption_info: Option<&EncryptionInfo>, - journal_size: Option, - tag_spec: Option, + integrity_spec: IntegritySpec, ) -> StratisResult> { validate_name(name)?; let name = Name::new(name.to_owned()); - let rounded_journal_size = match journal_size { + let rounded_journal_size = match integrity_spec.journal_size { Some(b) => { if b % 4096u64 != Bytes(0) { return Err(StratisError::Msg(format!("{b} is not a multiple of 4096"))); @@ -571,7 +570,7 @@ impl Engine for StratEngine { unowned_devices, cloned_enc_info.as_ref(), rounded_journal_size, - tag_spec, + integrity_spec.tag_spec, ) })??; pools.insert(Name::new(name.to_string()), pool_uuid, AnyPool::V2(pool)); @@ -923,7 +922,7 @@ mod test { let engine = StratEngine::initialize().unwrap(); let name1 = "name1"; - let uuid1 = test_async!(engine.create_pool(name1, paths, None, None, None)) + let uuid1 = test_async!(engine.create_pool(name1, paths, None, IntegritySpec::default())) .unwrap() .changed() .unwrap(); @@ -1028,13 +1027,13 @@ mod test { let engine = StratEngine::initialize().unwrap(); let name1 = "name1"; - let uuid1 = test_async!(engine.create_pool(name1, paths1, None, None, None)) + let uuid1 = test_async!(engine.create_pool(name1, paths1, None, IntegritySpec::default())) .unwrap() .changed() .unwrap(); let name2 = "name2"; - let uuid2 = test_async!(engine.create_pool(name2, paths2, None, None, None)) + let uuid2 = test_async!(engine.create_pool(name2, paths2, None, IntegritySpec::default())) .unwrap() .changed() .unwrap(); @@ -1494,7 +1493,7 @@ mod test { fn test_start_stop(paths: &[&Path]) { let engine = StratEngine::initialize().unwrap(); let name = "pool_name"; - let uuid = test_async!(engine.create_pool(name, paths, None, None, None)) + let uuid = test_async!(engine.create_pool(name, paths, None, IntegritySpec::default())) .unwrap() .changed() .unwrap(); diff --git a/src/engine/strat_engine/pool/v2.rs b/src/engine/strat_engine/pool/v2.rs index 1034840c98..82ecf5e65c 100644 --- a/src/engine/strat_engine/pool/v2.rs +++ b/src/engine/strat_engine/pool/v2.rs @@ -1265,7 +1265,7 @@ mod tests { tests::{loopbacked, real}, thinpool::ThinPoolStatusDigest, }, - types::{EngineAction, PoolIdentifier}, + types::{EngineAction, IntegritySpec, PoolIdentifier}, Engine, StratEngine, }; @@ -1690,10 +1690,11 @@ mod tests { fn test_grow_physical_pre_grow(paths: &[&Path]) { let pool_name = Name::new("pool".to_string()); let engine = StratEngine::initialize().unwrap(); - let pool_uuid = test_async!(engine.create_pool(&pool_name, paths, None, None, None)) - .unwrap() - .changed() - .unwrap(); + let pool_uuid = + test_async!(engine.create_pool(&pool_name, paths, None, IntegritySpec::default())) + .unwrap() + .changed() + .unwrap(); let mut guard = test_async!(engine.get_mut_pool(PoolIdentifier::Uuid(pool_uuid))).unwrap(); let (_, _, pool) = guard.as_mut_tuple(); diff --git a/src/engine/types/mod.rs b/src/engine/types/mod.rs index cb9e458f26..991d51e9eb 100644 --- a/src/engine/types/mod.rs +++ b/src/engine/types/mod.rs @@ -518,3 +518,9 @@ impl IntegrityTagSpec { } } } + +#[derive(Default)] +pub struct IntegritySpec { + pub tag_spec: Option, + pub journal_size: Option, +} diff --git a/src/jsonrpc/server/pool.rs b/src/jsonrpc/server/pool.rs index bbb365b509..3b1d584591 100644 --- a/src/jsonrpc/server/pool.rs +++ b/src/jsonrpc/server/pool.rs @@ -10,7 +10,7 @@ use tokio::task::block_in_place; use crate::{ engine::{ BlockDevTier, CreateAction, DeleteAction, EncryptionInfo, Engine, EngineAction, - KeyDescription, Name, PoolIdentifier, PoolUuid, RenameAction, UnlockMethod, + IntegritySpec, KeyDescription, Name, PoolIdentifier, PoolUuid, RenameAction, UnlockMethod, }, jsonrpc::interface::PoolListType, stratis::{StratisError, StratisResult}, @@ -46,7 +46,7 @@ pub async fn pool_create<'a>( ) -> StratisResult { Ok( match engine - .create_pool(name, blockdev_paths, enc_info, None, None) + .create_pool(name, blockdev_paths, enc_info, IntegritySpec::default()) .await? { CreateAction::Created(_) => true,