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

From: Alexandre Courbot
Date: Mon Jun 02 2025 - 08:42:39 EST


On Mon Jun 2, 2025 at 8:40 PM JST, Jason Gunthorpe wrote:
> On Sat, May 31, 2025 at 09:54:20PM +0900, Alexandre Courbot wrote:
>
>> So if I understood your idea correctly, this would mean creating the
>> SGTable and mapping it in one call, eschewing the typestate entirely?
>
> Probably no need for a type state

No need indeed, nice and simple.

>
>> And the `SGTable` would own the backing data, and only release it upon
>> destruction and unmapping?
>
> But I don't think you can do this, it is not allowed to pin kmalloc
> memory for instance so you have to do something as you showed to tie
> the lifetime to the kmalloc across the sgtable lifetime.

The caller would have to pass already-pinned memory. And to allow both
the owner and borrowed patterns we could leverage the `Borrow` trait I
think.