Re: [PATCH v4] rust: block: rnull: update to Pin<KBox<QueueData>> for PinInit
From: Benno Lossin
Date: Wed Mar 18 2026 - 03:48:37 EST
On Tue Mar 17, 2026 at 8:32 PM CET, Adrián García Casado wrote:
> Utilize the pin_init! macro for QueueData initialization to correctly support in-place initialization patterns. This aligns the driver with standard Rust-for-Linux pinning practices for driver-specific queue data.
>
> Signed-off-by: Adrián García Casado <adriangarciacasado42@xxxxxxxxx>
You haven't replied to Miguel's questions and disregarded his advice to
wait for maintainers to get back to you before sending a new version.
The patch itself is completely unnecessary, there is no need for pinning
for `QueueData` proven by the fact that the code works as is. Please
reply with an email explaining your thought process and don't send
another version.
Cheers,
Benno
> ---
> drivers/block/rnull/rnull.rs | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/block/rnull/rnull.rs b/drivers/block/rnull/rnull.rs
> index 0ca8715fe..11ea0696d 100644
> --- a/drivers/block/rnull/rnull.rs
> +++ b/drivers/block/rnull/rnull.rs
> @@ -54,7 +54,7 @@ fn new(
> ) -> Result<GenDisk<Self>> {
> let tagset = Arc::pin_init(TagSet::new(1, 256, 1), GFP_KERNEL)?;
>
> - let queue_data = Box::new(QueueData { irq_mode }, GFP_KERNEL)?;
> + let queue_data = Box::pin_init(pin_init!(QueueData { irq_mode }), GFP_KERNEL)?;
>
> gen_disk::GenDiskBuilder::new()
> .capacity_sectors(capacity_mib << (20 - block::SECTOR_SHIFT))
> @@ -65,16 +65,21 @@ fn new(
> }
> }
>
> +#[pin_data]
> struct QueueData {
> irq_mode: IRQMode,
> }
>
> #[vtable]
> impl Operations for NullBlkDevice {
> - type QueueData = KBox<QueueData>;
> + type QueueData = Pin<KBox<QueueData>>;
>
> #[inline(always)]
> - fn queue_rq(queue_data: &QueueData, rq: ARef<mq::Request<Self>>, _is_last: bool) -> Result {
> + fn queue_rq(
> + queue_data: Pin<&QueueData>,
> + rq: ARef<mq::Request<Self>>,
> + _is_last: bool,
> + ) -> Result {
> match queue_data.irq_mode {
> IRQMode::None => mq::Request::end_ok(rq)
> .map_err(|_e| kernel::error::code::EIO)
> @@ -87,7 +92,7 @@ fn queue_rq(queue_data: &QueueData, rq: ARef<mq::Request<Self>>, _is_last: bool)
> Ok(())
> }
>
> - fn commit_rqs(_queue_data: &QueueData) {}
> + fn commit_rqs(_queue_data: Pin<&QueueData>) {}
>
> fn complete(rq: ARef<mq::Request<Self>>) {
> mq::Request::end_ok(rq)