Skip to main content

read_aligned_range

Function read_aligned_range 

Source
pub fn read_aligned_range<F>(
    extents: &Extents,
    range: Range<u64>,
    service: &(impl BlockService + ?Sized),
    callback: F,
)
where F: FnMut(Result<OwnedBuffer, Error>) -> ControlFlow<()> + Send + 'static,
Expand description

Reads the specified block-aligned logical range (start..end) into one or more OwnedBuffer chunks with zero copies, streaming each chunk sequentially to callback.

Both range.start and range.end must be multiples of BLOCK_SIZE. Callers requiring unaligned sub-ranges must align range to block boundaries and handle leading or trailing byte trimming/zeroing in callback.

Allocates buffers and submits block read requests immediately inside a loop until range is fully covered. If service.allocate_buffer returns a partial buffer or blocks due to memory pool exhaustion, the function makes progress by allocating and submitting what is available, then blocking inside allocate_buffer when needed until background completions free memory back to the pool. Out-of-order completions across requests are buffered so callback always receives chunks strictly in ascending logical offset sequence.