Skip to content

Commit

Permalink
Merge pull request #3562 from mulkieran/two-tidies
Browse files Browse the repository at this point in the history
Two tidies
  • Loading branch information
mulkieran authored Mar 7, 2024
2 parents 838d7b6 + c696761 commit 6a73c22
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/engine/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@ const DEFAULT_THIN_DEV_SIZE: Sectors = Sectors(2 * IEC::Gi); // 1 TiB
#[cfg(test)]
pub const DEFAULT_THIN_DEV_SIZE: Sectors = Sectors(2 * IEC::Gi); // 1 TiB

// xfs is planning to reject making "small" filesystems:
// https://www.spinics.net/lists/linux-xfs/msg59453.html
// Current versions of xfs now reject "small" filesystems:
// The data section of the filesystem must be at least 300 MiB.
// A Stratis imposed minimum of 512 MiB allows sufficient space for XFS
// metadata.
const MIN_THIN_DEV_SIZE: Sectors = Sectors(IEC::Mi); // 512 MiB

// Linux has a maximum filename length of 255 bytes. We use this length
// as a cap on the size of the pool name also. This ensures that the name
// serialized in the pool-level metadata has a bounded length.
const MAXIMUM_NAME_SIZE: usize = 255;

/// Called when the name of a requested pool coincides with the name of an
/// existing pool. Returns an error if the specifications of the requested
/// pool differ from the specifications of the existing pool, otherwise
Expand Down Expand Up @@ -141,10 +148,9 @@ pub fn validate_name(name: &str) -> StratisResult<()> {
if name == "." || name == ".." {
return Err(StratisError::Msg(format!("Name is . or .. : {name}")));
}
// Linux has a maximum filename length of 255 bytes
if name.len() > 255 {
if name.len() > MAXIMUM_NAME_SIZE {
return Err(StratisError::Msg(format!(
"Name has more than 255 bytes: {name}"
"Name has more than {MAXIMUM_NAME_SIZE} bytes: {name}"
)));
}
if name.len() != name.trim().len() {
Expand Down

0 comments on commit 6a73c22

Please sign in to comment.