Re: [PATCH v2] rust: adding UniqueRefCounted and UniqueRef types
From: Andreas Hindborg
Date: Fri Feb 28 2025 - 13:29:25 EST
"Oliver Mangold" <oliver.mangold@xxxxx> writes:
> For usage with block-mq, a variant of ARef
> which is guaranteed to be unique would be useful.
> As chances are it is useful in general, This implements it
> as kernel::types::UniqueRef.
> The difference between ARef and UniqueRef
> is basically the same as between Arc and UniqueArc.
I would suggest splitting out the use case from the commit message:
rust: add `UniqueRef` for `ARef` references
Add `UniqeRef` as a variabt of `ARef` that is guaranteed to be unique.
This is useful when mutable access to the underlying type is required
and we can guarantee uniqueness, and when APIs that would normally take
an `ARef` require uniqueness.
---
Upcomming changes to the rust block device driver API depend on this
patch. Please see [1] for a use casel.
[1] https://github.com/metaspace/linux/blob/41034cb4ea7cd20b981ce320136b6526a9fa9db6/rust/kernel/block/mq/request.rs#L406
The comments after the --- will not got in the commit log, they are a
message for the review process only.
Best regards,
Andreas Hindborg