Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block size buffers #1105

Merged
merged 3 commits into from
Jan 24, 2024
Merged

Block size buffers #1105

merged 3 commits into from
Jan 24, 2024

Conversation

mkeeter
Copy link
Contributor

@mkeeter mkeeter commented Jan 23, 2024

This PR changes the struct Buffer to enforce that it is always an exact multiple of blocks.

The property is enforced at construction: the only way to build or resize a Buffer is to provide a tuple of (block_count, block_size). Various implementors of BlockIO also now check that their reads and writes are block-aligned, returning the existing CrucibleError::DataLenUnaligned if that's not the case.

These changes are a step towards per-block ownership, but make sense as a standalone PR:

  • This PR touches a bunch of lines, but is mostly mechanical changes
  • The upcoming per-block ownership PR will touch fewer lines, but will be making trickier logical changes

Copy link
Contributor

@jmpesp jmpesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@@ -326,17 +332,34 @@ impl PantryEntry {
block_size,
);
}
if Self::MAX_CHUNK_SIZE % block_size as usize != 0 {
crucible_bail!(
InvalidNumberOfBlocks,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should be

    #[error("Data length not block size multiple")]
    DataLenUnaligned,

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added static assertions relating MAX_CHUNK_SIZE and MAX_BLOCK_SIZE, so this should always be true and I switched it to an assertion (4c2c657)

@mkeeter mkeeter merged commit 627f3c9 into oxidecomputer:main Jan 24, 2024
18 checks passed
@mkeeter mkeeter deleted the block-size-buffers branch January 24, 2024 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants