Re: [PATCH 05/79] block: rust: change `queue_rq` request type to `Owned`

Andreas Hindborg
2026-03-23T12:08:22Z

Alice Ryhl <aliceryhl@google.com> writes:

> On Mon, Feb 16, 2026 at 12:34:52AM +0100, Andreas Hindborg wrote:
>> Simplify the reference counting scheme for `Request` from 4 states to 3
>> states. This is achieved by coalescing the zero state between block layer
>> owned and uniquely owned by driver.
>>
>> Implement `Ownable` for `Request` and deliver `Request` to drivers as
>> `Owned<Request>`. In this process:
>>
>> - Move uniqueness assertions out of `rnull` as these are now guaranteed by
>> the `Owned` type.
>> - Move `start_unchecked`, `try_set_end` and `end_ok` from `Request` to
>> `Owned<Request>`, relying on type invariant for uniqueness.
>>
>> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
>
> It would be a lot cleaner if we could implement HrTimerPointer for
> Owned<Request> and entirely get rid of the refcount in request so we
> don't need ARef<Request> at all.
>
> Is there a reason we *need* ARef here?

There is. Real drivers will need to dma map the data buffers in
`Request` to a device. This requires taking a reference on the pages to
be mapped, which in turn requires taking a reference on the `Request`.

We could split up the reference counts into multiple fields, but that
would be less efficient.

Best regards,
Andreas Hindborg