Skip to content

Commit

Permalink
Add tag and journal size parameters to prediction script
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaublitz committed Dec 2, 2024
1 parent 0c4f1c7 commit 56efb3a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
30 changes: 30 additions & 0 deletions src/bin/utils/cmds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ pool is encrypted, setting this option has no effect on the prediction."),
.action(ArgAction::Append)
.help("Size of filesystem to be made for this pool. May be specified multiple times, one for each filesystem. Units are bytes. Must be at least 512 MiB and less than 4 PiB.")
.next_line_help(true)
)
.arg(
Arg::new("integrity_tag_size")
.long("integrity-tag-size")
.num_args(1)
.help("Size of the integrity checksums to be stored in the integrity metadata. The checksum size depends on the algorithm used for checksums. Units are bytes.")
.next_line_help(true)
)
.arg(
Arg::new("integrity_journal_size")
.long("integrity-journal-size")
.num_args(1)
.help("Size of the integrity journal. Default is 128 MiB. Units are bytes.")
.next_line_help(true)
),
Command::new("filesystem")
.about("Predicts the space usage when creating a Stratis filesystem.")
Expand Down Expand Up @@ -130,6 +144,22 @@ impl<'a> UtilCommand<'a> for StratisPredictUsage {
.collect::<Result<Vec<_>, _>>()
})
.transpose()?,
sub_m
.get_one::<String>("integrity_journal_size")
.map(|s| s.parse::<u64>().map(Bytes::from))
.transpose()?
.map(|b| {
if b % 4096u64 != Bytes(0) {
Err(format!("Value {b} is not aligned to 4096"))
} else {
Ok(b.sectors())
}
})
.transpose()?,
sub_m
.get_one::<String>("integrity_tag_size")
.map(|s| s.parse::<u8>().map(Bytes::from))
.transpose()?,
LevelFilter::from_str(
matches
.get_one::<String>("log-level")
Expand Down
14 changes: 10 additions & 4 deletions src/bin/utils/predict_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ pub fn predict_filesystem_usage(
Ok(())
}

fn predict_pool_metadata_usage(device_sizes: Vec<Sectors>) -> Result<Sectors, Box<dyn Error>> {
fn predict_pool_metadata_usage(
device_sizes: Vec<Sectors>,
journal_size: Option<Sectors>,
tag_size: Option<Bytes>,
) -> Result<Sectors, Box<dyn Error>> {
let stratis_metadata_alloc = BDA::default().extended_size().sectors();
let stratis_avail_sizes = device_sizes
.iter()
Expand All @@ -173,9 +177,9 @@ fn predict_pool_metadata_usage(device_sizes: Vec<Sectors>) -> Result<Sectors, Bo

let integrity_deduction = integrity_meta_space(
s,
DEFAULT_INTEGRITY_JOURNAL_SIZE.sectors(),
journal_size.unwrap_or(DEFAULT_INTEGRITY_JOURNAL_SIZE.sectors()),
DEFAULT_INTEGRITY_BLOCK_SIZE,
DEFAULT_INTEGRITY_TAG_SIZE,
tag_size.unwrap_or(DEFAULT_INTEGRITY_TAG_SIZE),
);
info!(
"Deduction for stratis metadata: {:}",
Expand Down Expand Up @@ -213,6 +217,8 @@ pub fn predict_pool_usage(
overprovisioned: bool,
device_sizes: Vec<Bytes>,
filesystem_sizes: Option<Vec<Bytes>>,
journal_size: Option<Sectors>,
tag_size: Option<Bytes>,
log_level: LevelFilter,
) -> Result<(), Box<dyn Error>> {
Builder::new().filter(None, log_level).init();
Expand All @@ -224,7 +230,7 @@ pub fn predict_pool_usage(
let device_sizes = device_sizes.iter().map(|s| s.sectors()).collect::<Vec<_>>();
let total_size: Sectors = device_sizes.iter().cloned().sum();

let non_metadata_size = predict_pool_metadata_usage(device_sizes)?;
let non_metadata_size = predict_pool_metadata_usage(device_sizes, journal_size, tag_size)?;

let size_params = ThinPoolSizeParams::new(non_metadata_size)?;
let total_non_data = 2usize * size_params.meta_size() + size_params.mdv_size();
Expand Down
2 changes: 1 addition & 1 deletion src/dbus_api/api/manager_3_8/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub fn create_pool(m: &MethodInfo<'_, MTSync<TData>, TData>) -> MethodResult {
None => None,
};

let journal_size = tuple_to_option(journal_size_tuple).map(|i| Bytes::from(i));
let journal_size = tuple_to_option(journal_size_tuple).map(Bytes::from);
let tag_size = tuple_to_option(tag_size_tuple).map(Bytes::from);

let dbus_context = m.tree.get_data();
Expand Down

0 comments on commit 56efb3a

Please sign in to comment.