Skip to content

Commit

Permalink
Add whether or not to allocate the integrity superblock
Browse files Browse the repository at this point in the history
This is an option in the D-Bus, the predict script and the pool-level
metadata.

Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Dec 20, 2024
1 parent c2f2231 commit 2714a96
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/bin/utils/cmds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/dbus_api/api/manager_3_8/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ pub fn create_pool_method(f: &Factory<MTSync<TData>, TData>) -> Method<MTSync<TD
//
// Rust representation: (bool, String)
.in_arg(("tag_spec", "(bs)"))
// Optionally specify whether to reserve space for integrity
// superblock.
// b: true if the second value is to be read, otherwise false.
// b: true if the superblock reservation is supposed to be done
//
// Rust representation: (bool, bool)
.in_arg(("allocate_superblock", "(bb)"))
// In order from left to right:
// b: true if a pool was created and object paths were returned
// o: Object path for Pool
Expand Down
6 changes: 5 additions & 1 deletion src/dbus_api/api/manager_3_8/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ pub fn create_pool(m: &MethodInfo<'_, MTSync<TData>, 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();

Expand Down Expand Up @@ -201,14 +202,17 @@ pub fn create_pool(m: &MethodInfo<'_, MTSync<TData>, 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,
&devs.map(Path::new).collect::<Vec<&Path>>(),
EncryptionInfo::from_options((key_desc, clevis_info)).as_ref(),
IntegritySpec {
journal_size,
tag_spec
tag_spec,
allocate_superblock,
},
)));
match create_result {
Expand Down
3 changes: 3 additions & 0 deletions src/engine/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,13 +527,15 @@ impl IntegrityTagSpec {
pub struct IntegritySpec {
pub tag_spec: Option<IntegrityTagSpec>,
pub journal_size: Option<Bytes>,
pub allocate_superblock: Option<bool>,
}

#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct ValidatedIntegritySpec {
pub tag_spec: IntegrityTagSpec,
pub journal_size: Sectors,
pub block_size: Bytes,
pub allocate_superblock: bool,
}

impl Default for ValidatedIntegritySpec {
Expand Down Expand Up @@ -563,6 +565,7 @@ impl TryFrom<IntegritySpec> 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),
})
}
}
1 change: 1 addition & 0 deletions tests/client-dbus/src/stratisd_client_dbus/_introspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<arg name="clevis_info" type="(b(ss))" direction="in" />
<arg name="journal_size" type="(bt)" direction="in" />
<arg name="tag_spec" type="(bs)" direction="in" />
<arg name="allocate_superblock" type="(bb)" direction="in" />
<arg name="result" type="(b(oao))" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
Expand Down
1 change: 1 addition & 0 deletions tests/client-dbus/tests/udev/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def create_v2_pool():
),
"journal_size": (False, 0),
"tag_spec": (False, ""),
"allocate_superblock": (False, False),
},
)

Expand Down

0 comments on commit 2714a96

Please sign in to comment.