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 Nov 25, 2024
1 parent 4e3810f commit 503aa58
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
27 changes: 26 additions & 1 deletion src/bin/utils/cmds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use clap::{Arg, ArgAction, Command};
use clap::builder::Str;
use log::LevelFilter;

use devicemapper::Bytes;
use devicemapper::{Bytes, IEC};

use crate::utils::predict_usage;

Expand Down 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 4KiB blocks.")
.next_line_help(true)
),
Command::new("filesystem")
.about("Predicts the space usage when creating a Stratis filesystem.")
Expand Down Expand Up @@ -130,6 +144,17 @@ impl<'a> UtilCommand<'a> for StratisPredictUsage {
.collect::<Result<Vec<_>, _>>()
})
.transpose()?,
sub_m
.get_one::<String>("integrity_journal_size")
.map(|s| {
s.parse::<u64>()
.map(|i| Bytes::from(i * 4 * IEC::Ki).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

0 comments on commit 503aa58

Please sign in to comment.