Re: [PATCH 1/3] rust: block: add bio segment iteration and request accessors

From: Andreas Hindborg

Date: Wed Nov 18 2026 - 10:25:47 EST


Hi Vitaly,

"Vitaly Wool" <vitaly.wool@xxxxxxxxxxx> writes:

> From: Igor B <igor.b@xxxxxxxxx>
>
> The Rust blk-mq abstractions only cover what the null block driver
> needs: requests can be started and ended, but a driver cannot find out
> what a request asks for or reach its data.
>
> For a driver that actually transfers data we need:
>
> - A `bio` module with a `Bio` wrapper, an iterator over the bios of a
> request and an iterator over the single-page segments of a bio, the
> equivalent of rq_for_each_segment(). Segments can be copied to and
> from a `Page` and zeroed, with bounds checks. Iteration goes through
> two new C helpers wrapping bio_iter_iovec() and
> bio_advance_iter_single(), so the multi-page bvec handling stays in
> C.
>
> - `Request::command()`, `Request::sector()`, `Request::bytes()` and
> `Request::bio_iter()`, exposing the operation, start sector, length
> and bios of a request. REQ_OP_MASK is added as a constant helper,
> since bindgen cannot evaluate it.
>
> - `GenDiskBuilder::max_hw_discard_sectors()` and
> `GenDiskBuilder::discard_granularity()`, so drivers can advertise
> discard support.
>
> These are used by the rbrd driver added in forthcoming patch.
>
> Signed-off-by: Igor Belousov <igor.b@xxxxxxxxx>
> Signed-off-by: Vitaly Wool <vitaly.wool@xxxxxxxxxxx>

I already submitted this [1]. I have a version rebased on v7.4 if you are
interested.


Best regards,
Andreas Hindborg


[1] https://lore.kernel.org/all/20260216-rnull-v6-19-rc5-send-v1-0-de9a7af4b469@xxxxxxxxxx/