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

From: Alice Ryhl

Date: Tue Mar 24 2026 - 09:35:15 EST


On Mon, Mar 23, 2026 at 1:08 PM Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote:
>
> Alice Ryhl <aliceryhl@xxxxxxxxxx> 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@xxxxxxxxxx>
> >
> > 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.

So how exactly is the refcount used here? Can you elaborate?

With regards to the Owned series, I still think we should split it up
so that the patches making ARef+Owned work like Arc/UniqueArc is
separate follow-up series.

Alice