From 2714a969e62bdac83807c6493fd3182ce1f23510 Mon Sep 17 00:00:00 2001 From: mulhern Date: Fri, 20 Dec 2024 12:17:58 -0500 Subject: [PATCH] Add whether or not to allocate the integrity superblock This is an option in the D-Bus, the predict script and the pool-level metadata. Signed-off-by: mulhern --- src/bin/utils/cmds.rs | 7 +++++++ src/dbus_api/api/manager_3_8/api.rs | 7 +++++++ src/dbus_api/api/manager_3_8/methods.rs | 6 +++++- src/engine/types/mod.rs | 3 +++ tests/client-dbus/src/stratisd_client_dbus/_introspect.py | 1 + tests/client-dbus/tests/udev/_utils.py | 1 + 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/bin/utils/cmds.rs b/src/bin/utils/cmds.rs index 57826cc623..7aef28a01e 100644 --- a/src/bin/utils/cmds.rs +++ b/src/bin/utils/cmds.rs @@ -110,6 +110,12 @@ pool is encrypted, setting this option has no effect on the prediction."), .default_value(Box::leak((*DEFAULT_INTEGRITY_JOURNAL_SIZE).to_string().into_boxed_str()) as &'static str) .help("Size of the integrity journal. Default is 128 MiB. Units are bytes.") .next_line_help(true) + ) + .arg( + Arg::new("no_integrity_superblock") + .long("no-integrity-superblock") + .help("Do not allocate space for integrity superblock") + .next_line_help(true) ), Command::new("filesystem") .about("Predicts the space usage when creating a Stratis filesystem.") @@ -166,6 +172,7 @@ impl<'a> UtilCommand<'a> for StratisPredictUsage { }) .expect("default specified by parser"), ), + allocate_superblock: Some(!sub_m.get_flag("no_integrity_superblock")), })?, LevelFilter::from_str( matches diff --git a/src/dbus_api/api/manager_3_8/api.rs b/src/dbus_api/api/manager_3_8/api.rs index 9d6a6329b4..5b8e468599 100644 --- a/src/dbus_api/api/manager_3_8/api.rs +++ b/src/dbus_api/api/manager_3_8/api.rs @@ -68,6 +68,13 @@ pub fn create_pool_method(f: &Factory, TData>) -> Method, TData>) -> MethodResult { ); let journal_size_tuple: (bool, u64) = get_next_arg(&mut iter, 4)?; let tag_spec_tuple: (bool, String) = get_next_arg(&mut iter, 5)?; + let allocate_superblock_tuple: (bool, bool) = get_next_arg(&mut iter, 6)?; let return_message = message.method_return(); @@ -201,6 +202,8 @@ pub fn create_pool(m: &MethodInfo<'_, MTSync, TData>) -> MethodResult { } }; + let allocate_superblock = tuple_to_option(allocate_superblock_tuple); + let dbus_context = m.tree.get_data(); let create_result = handle_action!(block_on(dbus_context.engine.create_pool( name, @@ -208,7 +211,8 @@ pub fn create_pool(m: &MethodInfo<'_, MTSync, TData>) -> MethodResult { EncryptionInfo::from_options((key_desc, clevis_info)).as_ref(), IntegritySpec { journal_size, - tag_spec + tag_spec, + allocate_superblock, }, ))); match create_result { diff --git a/src/engine/types/mod.rs b/src/engine/types/mod.rs index de26ab9533..09c013a4d3 100644 --- a/src/engine/types/mod.rs +++ b/src/engine/types/mod.rs @@ -527,6 +527,7 @@ impl IntegrityTagSpec { pub struct IntegritySpec { pub tag_spec: Option, pub journal_size: Option, + pub allocate_superblock: Option, } #[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)] @@ -534,6 +535,7 @@ pub struct ValidatedIntegritySpec { pub tag_spec: IntegrityTagSpec, pub journal_size: Sectors, pub block_size: Bytes, + pub allocate_superblock: bool, } impl Default for ValidatedIntegritySpec { @@ -563,6 +565,7 @@ impl TryFrom for ValidatedIntegritySpec { journal_size, tag_spec: spec.tag_spec.unwrap_or(DEFAULT_INTEGRITY_TAG_SPEC), block_size: DEFAULT_INTEGRITY_BLOCK_SIZE, + allocate_superblock: spec.allocate_superblock.unwrap_or(true), }) } } diff --git a/tests/client-dbus/src/stratisd_client_dbus/_introspect.py b/tests/client-dbus/src/stratisd_client_dbus/_introspect.py index 6326c23624..9920f2e29d 100644 --- a/tests/client-dbus/src/stratisd_client_dbus/_introspect.py +++ b/tests/client-dbus/src/stratisd_client_dbus/_introspect.py @@ -15,6 +15,7 @@ + diff --git a/tests/client-dbus/tests/udev/_utils.py b/tests/client-dbus/tests/udev/_utils.py index a5011c118b..40c4fcd935 100644 --- a/tests/client-dbus/tests/udev/_utils.py +++ b/tests/client-dbus/tests/udev/_utils.py @@ -152,6 +152,7 @@ def create_v2_pool(): ), "journal_size": (False, 0), "tag_spec": (False, ""), + "allocate_superblock": (False, False), }, )