Skip to content

Commit 2714a96

Browse files
committed
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 <[email protected]>
1 parent c2f2231 commit 2714a96

File tree

6 files changed

+24
-1
lines changed

6 files changed

+24
-1
lines changed

src/bin/utils/cmds.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ pool is encrypted, setting this option has no effect on the prediction."),
110110
.default_value(Box::leak((*DEFAULT_INTEGRITY_JOURNAL_SIZE).to_string().into_boxed_str()) as &'static str)
111111
.help("Size of the integrity journal. Default is 128 MiB. Units are bytes.")
112112
.next_line_help(true)
113+
)
114+
.arg(
115+
Arg::new("no_integrity_superblock")
116+
.long("no-integrity-superblock")
117+
.help("Do not allocate space for integrity superblock")
118+
.next_line_help(true)
113119
),
114120
Command::new("filesystem")
115121
.about("Predicts the space usage when creating a Stratis filesystem.")
@@ -166,6 +172,7 @@ impl<'a> UtilCommand<'a> for StratisPredictUsage {
166172
})
167173
.expect("default specified by parser"),
168174
),
175+
allocate_superblock: Some(!sub_m.get_flag("no_integrity_superblock")),
169176
})?,
170177
LevelFilter::from_str(
171178
matches

src/dbus_api/api/manager_3_8/api.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ pub fn create_pool_method(f: &Factory<MTSync<TData>, TData>) -> Method<MTSync<TD
6868
//
6969
// Rust representation: (bool, String)
7070
.in_arg(("tag_spec", "(bs)"))
71+
// Optionally specify whether to reserve space for integrity
72+
// superblock.
73+
// b: true if the second value is to be read, otherwise false.
74+
// b: true if the superblock reservation is supposed to be done
75+
//
76+
// Rust representation: (bool, bool)
77+
.in_arg(("allocate_superblock", "(bb)"))
7178
// In order from left to right:
7279
// b: true if a pool was created and object paths were returned
7380
// o: Object path for Pool

src/dbus_api/api/manager_3_8/methods.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ pub fn create_pool(m: &MethodInfo<'_, MTSync<TData>, TData>) -> MethodResult {
159159
);
160160
let journal_size_tuple: (bool, u64) = get_next_arg(&mut iter, 4)?;
161161
let tag_spec_tuple: (bool, String) = get_next_arg(&mut iter, 5)?;
162+
let allocate_superblock_tuple: (bool, bool) = get_next_arg(&mut iter, 6)?;
162163

163164
let return_message = message.method_return();
164165

@@ -201,14 +202,17 @@ pub fn create_pool(m: &MethodInfo<'_, MTSync<TData>, TData>) -> MethodResult {
201202
}
202203
};
203204

205+
let allocate_superblock = tuple_to_option(allocate_superblock_tuple);
206+
204207
let dbus_context = m.tree.get_data();
205208
let create_result = handle_action!(block_on(dbus_context.engine.create_pool(
206209
name,
207210
&devs.map(Path::new).collect::<Vec<&Path>>(),
208211
EncryptionInfo::from_options((key_desc, clevis_info)).as_ref(),
209212
IntegritySpec {
210213
journal_size,
211-
tag_spec
214+
tag_spec,
215+
allocate_superblock,
212216
},
213217
)));
214218
match create_result {

src/engine/types/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,13 +527,15 @@ impl IntegrityTagSpec {
527527
pub struct IntegritySpec {
528528
pub tag_spec: Option<IntegrityTagSpec>,
529529
pub journal_size: Option<Bytes>,
530+
pub allocate_superblock: Option<bool>,
530531
}
531532

532533
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
533534
pub struct ValidatedIntegritySpec {
534535
pub tag_spec: IntegrityTagSpec,
535536
pub journal_size: Sectors,
536537
pub block_size: Bytes,
538+
pub allocate_superblock: bool,
537539
}
538540

539541
impl Default for ValidatedIntegritySpec {
@@ -563,6 +565,7 @@ impl TryFrom<IntegritySpec> for ValidatedIntegritySpec {
563565
journal_size,
564566
tag_spec: spec.tag_spec.unwrap_or(DEFAULT_INTEGRITY_TAG_SPEC),
565567
block_size: DEFAULT_INTEGRITY_BLOCK_SIZE,
568+
allocate_superblock: spec.allocate_superblock.unwrap_or(true),
566569
})
567570
}
568571
}

tests/client-dbus/src/stratisd_client_dbus/_introspect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<arg name="clevis_info" type="(b(ss))" direction="in" />
1616
<arg name="journal_size" type="(bt)" direction="in" />
1717
<arg name="tag_spec" type="(bs)" direction="in" />
18+
<arg name="allocate_superblock" type="(bb)" direction="in" />
1819
<arg name="result" type="(b(oao))" direction="out" />
1920
<arg name="return_code" type="q" direction="out" />
2021
<arg name="return_string" type="s" direction="out" />

tests/client-dbus/tests/udev/_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def create_v2_pool():
152152
),
153153
"journal_size": (False, 0),
154154
"tag_spec": (False, ""),
155+
"allocate_superblock": (False, False),
155156
},
156157
)
157158

0 commit comments

Comments
 (0)