Skip to content

Commit

Permalink
Make read and write messages contiguous (#1387)
Browse files Browse the repository at this point in the history
The `BlockIO` trait only allows us to access contiguous sets of blocks
for reading and writing.

However, our internal `Message` type converts these contiguous spans
into random-access block lists. This adds complexity: we have to support
the possibility for disjoint operations everywhere, even though they
should never actually happen.

This PR changes the `Message` types to accept a starting index + block
count (for reads), or a starting index + block and context data (for
writes). In addition, the `ReadResponse` is simplified to not include
per-block indexes, because they're implied by the start index + position
in the list.

Various tests for disjoint reads and writes are removed.
  • Loading branch information
mkeeter authored Jul 23, 2024
1 parent 58dfca4 commit 5951c65
Show file tree
Hide file tree
Showing 12 changed files with 512 additions and 990 deletions.
8 changes: 8 additions & 0 deletions common/src/impacted_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ impl ImpactedBlocks {
ImpactedBlocks::Empty
}

/// Returns the first impacted address
pub fn start(&self) -> Option<ImpactedAddr> {
match self {
ImpactedBlocks::InclusiveRange(a, _) => Some(*a),
ImpactedBlocks::Empty => None,
}
}

/// Create a new ImpactedBlocks range starting at a given offset, and
/// stretching n_blocks further into the extent. Panics an error if
/// `extent_size` is 0. Returns ImpactedBlocks::Empty if n_blocks is 0.
Expand Down
Loading

0 comments on commit 5951c65

Please sign in to comment.