rust/kernel/block/mq/operations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Commit b040a1a4523d ("block: switch numa_node to int in
blk_mq_hw_ctx and init_request") changed the type of the
`numa_node` argument of `blk_mq_ops::init_request` from
`unsigned int` to `int`. Update the Rust callback signature to
match, so that the function item can be coerced to the C fn
pointer type stored in `blk_mq_ops`.
Without this change the Rust block layer fails to build:
error[E0308]: mismatched types
--> rust/kernel/block/mq/operations.rs:274:28
|
274 | init_request: Some(Self::init_request_callback),
| ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| expected fn pointer, found fn item
|
= note: expected fn pointer
`unsafe extern "C" fn(_, _, _, i32) -> _`
found fn item
`unsafe extern "C" fn(_, _, _, u32) -> _ {...}`
The argument is unused on the Rust side, so this is a pure
type-signature change with no functional impact.
Fixes: b040a1a4523d ("block: switch numa_node to int in blk_mq_hw_ctx and init_request")
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
---
rust/kernel/block/mq/operations.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/kernel/block/mq/operations.rs b/rust/kernel/block/mq/operations.rs
index 8ad46129a52c..861903e18fbf 100644
--- a/rust/kernel/block/mq/operations.rs
+++ b/rust/kernel/block/mq/operations.rs
@@ -218,7 +218,7 @@ impl<T: Operations> OperationsVTable<T> {
_set: *mut bindings::blk_mq_tag_set,
rq: *mut bindings::request,
_hctx_idx: crate::ffi::c_uint,
- _numa_node: crate::ffi::c_uint,
+ _numa_node: crate::ffi::c_int,
) -> crate::ffi::c_int {
from_result(|| {
// SAFETY: By the safety requirements of this function, `rq` points
---
base-commit: 27236c051c01c1c1025e0e0d12a107082557e8f1
change-id: 20260527-block-for-next-2026-05-26-2200-failure-64907085fc49
Best regards,
--
Andreas Hindborg <a.hindborg@kernel.org>
On Wed, 27 May 2026 11:18:09 +0200, Andreas Hindborg wrote:
> Commit b040a1a4523d ("block: switch numa_node to int in
> blk_mq_hw_ctx and init_request") changed the type of the
> `numa_node` argument of `blk_mq_ops::init_request` from
> `unsigned int` to `int`. Update the Rust callback signature to
> match, so that the function item can be coerced to the C fn
> pointer type stored in `blk_mq_ops`.
>
> [...]
Applied, thanks!
[1/1] rust: block: mq: align init_request numa_node arg with C signature
commit: 6b2f3e4970e48e70c10111366f59f908f2ea6f96
Best regards,
--
Jens Axboe
Hello Andreas,
how can I catch it earlier in the future? I verified patch correctness
with compiling 'allyesconfig' but
I didn't catch rust issue.
Regards,
Mateusz
On 27.05.2026 11:18, Andreas Hindborg wrote:
> Commit b040a1a4523d ("block: switch numa_node to int in
> blk_mq_hw_ctx and init_request") changed the type of the
> `numa_node` argument of `blk_mq_ops::init_request` from
> `unsigned int` to `int`. Update the Rust callback signature to
> match, so that the function item can be coerced to the C fn
> pointer type stored in `blk_mq_ops`.
>
> Without this change the Rust block layer fails to build:
>
> error[E0308]: mismatched types
> --> rust/kernel/block/mq/operations.rs:274:28
> |
> 274 | init_request: Some(Self::init_request_callback),
> | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | expected fn pointer, found fn item
> |
> = note: expected fn pointer
> `unsafe extern "C" fn(_, _, _, i32) -> _`
> found fn item
> `unsafe extern "C" fn(_, _, _, u32) -> _ {...}`
>
> The argument is unused on the Rust side, so this is a pure
> type-signature change with no functional impact.
>
> Fixes: b040a1a4523d ("block: switch numa_node to int in blk_mq_hw_ctx
> and init_request")
> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
> ---
> rust/kernel/block/mq/operations.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rust/kernel/block/mq/operations.rs
> b/rust/kernel/block/mq/operations.rs
> index 8ad46129a52c..861903e18fbf 100644
> --- a/rust/kernel/block/mq/operations.rs
> +++ b/rust/kernel/block/mq/operations.rs
> @@ -218,7 +218,7 @@ impl<T: Operations> OperationsVTable<T> {
> _set: *mut bindings::blk_mq_tag_set,
> rq: *mut bindings::request,
> _hctx_idx: crate::ffi::c_uint,
> - _numa_node: crate::ffi::c_uint,
> + _numa_node: crate::ffi::c_int,
> ) -> crate::ffi::c_int {
> from_result(|| {
> // SAFETY: By the safety requirements of this function,
> `rq` points
>
> ---
> base-commit: 27236c051c01c1c1025e0e0d12a107082557e8f1
> change-id: 20260527-block-for-next-2026-05-26-2200-failure-64907085fc49
>
> Best regards,
mateusz.nowicki@posteo.net writes: > Hello Andreas, > > how can I catch it earlier in the future? I verified patch correctness > with compiling 'allyesconfig' but > I didn't catch rust issue. As Gary says, CONFIG_RUST is silently disabled if the required tools are not present. Please see the quick start guide for how to get a suitable compiler on major distros [1]. You can run `make LLVM=1 rustavailable` to check that your tools are set up correctly. Best regards, Andreas Hindborg [1] https://docs.kernel.org/rust/quick-start.html
On Wed May 27, 2026 at 12:57 PM BST, mateusz.nowicki wrote: > Hello Andreas, > > how can I catch it earlier in the future? I verified patch correctness > with compiling 'allyesconfig' but > I didn't catch rust issue. Currently allyesconfig will skip Rust if you don't have a suitable version of Rust compiler installed. There's discussions on getting it changed: https://lore.kernel.org/rust-for-linux/20260521-evolve-to-crab-v2-1-c18e0e98fc54@chaosmail.tech/ Best, Gary
On Wed May 27, 2026 at 10:18 AM BST, Andreas Hindborg wrote:
> Commit b040a1a4523d ("block: switch numa_node to int in
> blk_mq_hw_ctx and init_request") changed the type of the
> `numa_node` argument of `blk_mq_ops::init_request` from
> `unsigned int` to `int`. Update the Rust callback signature to
> match, so that the function item can be coerced to the C fn
> pointer type stored in `blk_mq_ops`.
>
> Without this change the Rust block layer fails to build:
>
> error[E0308]: mismatched types
> --> rust/kernel/block/mq/operations.rs:274:28
> |
> 274 | init_request: Some(Self::init_request_callback),
> | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | expected fn pointer, found fn item
> |
> = note: expected fn pointer
> `unsafe extern "C" fn(_, _, _, i32) -> _`
> found fn item
> `unsafe extern "C" fn(_, _, _, u32) -> _ {...}`
>
> The argument is unused on the Rust side, so this is a pure
> type-signature change with no functional impact.
>
> Fixes: b040a1a4523d ("block: switch numa_node to int in blk_mq_hw_ctx and init_request")
> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
You could also just use `i32` instead of `ffi::c_int`. But it doesn't really
matter for this patch.
Reviewed-by: Gary Guo <gary@garyguo.net>
> ---
> rust/kernel/block/mq/operations.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
On Wed, May 27, 2026 at 12:57 PM Gary Guo <gary@garyguo.net> wrote:
>
> On Wed May 27, 2026 at 10:18 AM BST, Andreas Hindborg wrote:
> > Commit b040a1a4523d ("block: switch numa_node to int in
> > blk_mq_hw_ctx and init_request") changed the type of the
> > `numa_node` argument of `blk_mq_ops::init_request` from
> > `unsigned int` to `int`. Update the Rust callback signature to
> > match, so that the function item can be coerced to the C fn
> > pointer type stored in `blk_mq_ops`.
> >
> > Without this change the Rust block layer fails to build:
> >
> > error[E0308]: mismatched types
> > --> rust/kernel/block/mq/operations.rs:274:28
> > |
> > 274 | init_request: Some(Self::init_request_callback),
> > | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > | expected fn pointer, found fn item
> > |
> > = note: expected fn pointer
> > `unsafe extern "C" fn(_, _, _, i32) -> _`
> > found fn item
> > `unsafe extern "C" fn(_, _, _, u32) -> _ {...}`
> >
> > The argument is unused on the Rust side, so this is a pure
> > type-signature change with no functional impact.
> >
> > Fixes: b040a1a4523d ("block: switch numa_node to int in blk_mq_hw_ctx and init_request")
> > Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
>
> You could also just use `i32` instead of `ffi::c_int`. But it doesn't really
> matter for this patch.
By the way, all these constants are in the prelude.
Alice
On Wed May 27, 2026 at 11:59 AM BST, Alice Ryhl wrote:
> On Wed, May 27, 2026 at 12:57 PM Gary Guo <gary@garyguo.net> wrote:
>>
>> On Wed May 27, 2026 at 10:18 AM BST, Andreas Hindborg wrote:
>> > Commit b040a1a4523d ("block: switch numa_node to int in
>> > blk_mq_hw_ctx and init_request") changed the type of the
>> > `numa_node` argument of `blk_mq_ops::init_request` from
>> > `unsigned int` to `int`. Update the Rust callback signature to
>> > match, so that the function item can be coerced to the C fn
>> > pointer type stored in `blk_mq_ops`.
>> >
>> > Without this change the Rust block layer fails to build:
>> >
>> > error[E0308]: mismatched types
>> > --> rust/kernel/block/mq/operations.rs:274:28
>> > |
>> > 274 | init_request: Some(Self::init_request_callback),
>> > | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> > | expected fn pointer, found fn item
>> > |
>> > = note: expected fn pointer
>> > `unsafe extern "C" fn(_, _, _, i32) -> _`
>> > found fn item
>> > `unsafe extern "C" fn(_, _, _, u32) -> _ {...}`
>> >
>> > The argument is unused on the Rust side, so this is a pure
>> > type-signature change with no functional impact.
>> >
>> > Fixes: b040a1a4523d ("block: switch numa_node to int in blk_mq_hw_ctx and init_request")
>> > Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
>>
>> You could also just use `i32` instead of `ffi::c_int`. But it doesn't really
>> matter for this patch.
>
> By the way, all these constants are in the prelude.
I wonder if we should actually encourage people, by removing them from prelude,
to use i32/u32 instead of c_int/c_uint, isize/usize instead of c_long/c_ulong
and similar, given all Linux ABIs have consistent mapping for them.
On a different note, perhaps it might worth adding a lint to klint to check for
path references for types available via prelude for other types.
Best,
Gary
© 2016 - 2026 Red Hat, Inc.