* [PATCH v4] rust: block: rnull: update to Pin<KBox<QueueData>> for PinInit
@ 2026-03-17 19:32 ` Adrián García Casado
2026-03-18 7:44 ` Benno Lossin
2026-03-18 13:03 ` Andreas Hindborg
0 siblings, 2 replies; 3+ messages in thread
From: Adrián García Casado @ 2026-03-17 19:32 UTC (permalink / raw)
To: Andreas Hindborg, Jens Axboe
Cc: Boqun Feng, Miguel Ojeda, rust-for-linux, linux-block,
linux-kernel, Adrián García Casado
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@gmail.com>
---
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)
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v4] rust: block: rnull: update to Pin<KBox<QueueData>> for PinInit
2026-03-17 19:32 ` [PATCH v4] rust: block: rnull: update to Pin<KBox<QueueData>> for PinInit Adrián García Casado
@ 2026-03-18 7:44 ` Benno Lossin
2026-03-18 13:03 ` Andreas Hindborg
1 sibling, 0 replies; 3+ messages in thread
From: Benno Lossin @ 2026-03-18 7:44 UTC (permalink / raw)
To: Adrián García Casado, Andreas Hindborg, Jens Axboe
Cc: Boqun Feng, Miguel Ojeda, rust-for-linux, linux-block,
linux-kernel
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@gmail.com>
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)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4] rust: block: rnull: update to Pin<KBox<QueueData>> for PinInit
2026-03-17 19:32 ` [PATCH v4] rust: block: rnull: update to Pin<KBox<QueueData>> for PinInit Adrián García Casado
2026-03-18 7:44 ` Benno Lossin
@ 2026-03-18 13:03 ` Andreas Hindborg
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Hindborg @ 2026-03-18 13:03 UTC (permalink / raw)
To: Adrián García Casado, Jens Axboe
Cc: Boqun Feng, Miguel Ojeda, rust-for-linux, linux-block,
linux-kernel, Adrián García Casado
Adrián García Casado <adriangarciacasado42@gmail.com> writes:
> 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@gmailcom>
I don't understand the rationale for this patch. I already have a patch
on list that pins `QueueData` for rnull [1], but not for the reasons you
mention here. `QueueData` does not need to be pinned if it does not have
any fields of types that must always be pinned.
Best regards,
Andreas Hindborg
[1] https://lore.kernel.org/r/20260216-rnull-v6-19-rc5-send-v1-13-de9a7af4b469@kernel.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-18 13:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <2hK6oarCGyUX9gXNJ6wZZoePYLShXTYjw8wOlhbW1szik-km-pMO8wtX6dgm5i34HLG2zxzqZgK-cb2MiDtdpw==@protonmail.internalid>
2026-03-17 19:32 ` [PATCH v4] rust: block: rnull: update to Pin<KBox<QueueData>> for PinInit Adrián García Casado
2026-03-18 7:44 ` Benno Lossin
2026-03-18 13:03 ` Andreas Hindborg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox