From a1238e04ae001662fb687634d8e443f979190d11 Mon Sep 17 00:00:00 2001 From: John Baublitz Date: Mon, 25 Nov 2024 14:43:33 -0500 Subject: [PATCH] Add tag and journal size parameters to prediction script --- src/bin/utils/cmds.rs | 30 +++++++++++++++++++++++++ src/bin/utils/predict_usage.rs | 14 ++++++++---- src/dbus_api/api/manager_3_8/methods.rs | 2 +- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/bin/utils/cmds.rs b/src/bin/utils/cmds.rs index 75783fc95b..2f1b357739 100644 --- a/src/bin/utils/cmds.rs +++ b/src/bin/utils/cmds.rs @@ -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.") @@ -130,6 +144,22 @@ impl<'a> UtilCommand<'a> for StratisPredictUsage { .collect::, _>>() }) .transpose()?, + sub_m + .get_one::("integrity_journal_size") + .map(|s| s.parse::().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::("integrity_tag_size") + .map(|s| s.parse::().map(Bytes::from)) + .transpose()?, LevelFilter::from_str( matches .get_one::("log-level") diff --git a/src/bin/utils/predict_usage.rs b/src/bin/utils/predict_usage.rs index f9c5f80d81..1c9d602f05 100644 --- a/src/bin/utils/predict_usage.rs +++ b/src/bin/utils/predict_usage.rs @@ -164,7 +164,11 @@ pub fn predict_filesystem_usage( Ok(()) } -fn predict_pool_metadata_usage(device_sizes: Vec) -> Result> { +fn predict_pool_metadata_usage( + device_sizes: Vec, + journal_size: Option, + tag_size: Option, +) -> Result> { let stratis_metadata_alloc = BDA::default().extended_size().sectors(); let stratis_avail_sizes = device_sizes .iter() @@ -173,9 +177,9 @@ fn predict_pool_metadata_usage(device_sizes: Vec) -> Result, filesystem_sizes: Option>, + journal_size: Option, + tag_size: Option, log_level: LevelFilter, ) -> Result<(), Box> { Builder::new().filter(None, log_level).init(); @@ -224,7 +230,7 @@ pub fn predict_pool_usage( let device_sizes = device_sizes.iter().map(|s| s.sectors()).collect::>(); 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(); diff --git a/src/dbus_api/api/manager_3_8/methods.rs b/src/dbus_api/api/manager_3_8/methods.rs index 8f8bdb3929..de1660d462 100644 --- a/src/dbus_api/api/manager_3_8/methods.rs +++ b/src/dbus_api/api/manager_3_8/methods.rs @@ -187,7 +187,7 @@ pub fn create_pool(m: &MethodInfo<'_, MTSync, 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();