Re: [PATCH v2 1/2] rust: add initial scatterlist bindings

From: Alexandre Courbot
Date: Thu Jul 03 2025 - 03:04:13 EST


On Wed Jul 2, 2025 at 11:37 AM JST, Alexandre Courbot wrote:
> Thoughts? If Abdiel is comfortable with this I can submit a v3 with this design
> for review (putting myself as co-developer), on which Abdiel could then keep
> iterating, as I suspect this would be easier to understand than this long email
> :).

Figured I could just as well share the code with you and save both of us
some time. ^_^;

The top commit of this branch contains the proposal discussed:

https://github.com/Gnurou/linux/tree/scatterlists

The sample code has been updated to add dummy examples for the 3
use-cases discussed (reference to an existing `sg_table`, refcounted
reference, and owned data).

There are still things missing, including the typestate on `SGEntry`, as
it wasn't necessary to demonstrate the basic idea.

Note also that if we decide to only support DMA-mapped SG-entries, we
can remove a bunch of code, including the one that maps a `SGTable` if
the backing type implements `BorrowMut`.

For your consideration. :) Please feel free to take and use anything you
find useful.