Linux block layer
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: "Alice Ryhl" <aliceryhl@google.com>, "Gary Guo" <gary@garyguo.net>
Cc: "Andreas Hindborg" <a.hindborg@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Jens Axboe" <axboe@kernel.dk>,
	"Mateusz Nowicki" <mateusz.nowicki@posteo.net>,
	linux-block@vger.kernel.org, rust-for-linux@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: block: mq: align init_request numa_node arg with C signature
Date: Wed, 27 May 2026 12:09:30 +0100	[thread overview]
Message-ID: <DITEV2DOK450.3R3J0EDVU6EJ5@garyguo.net> (raw)
In-Reply-To: <CAH5fLgiobJ2yCbDM56H8rzMeAWv0eaqt8-vPchU1EV3VEYb=jA@mail.gmail.com>

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

  reply	other threads:[~2026-05-27 11:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-27  9:18 [PATCH] rust: block: mq: align init_request numa_node arg with C signature Andreas Hindborg
2026-05-27 10:56 ` Gary Guo
2026-05-27 10:59   ` Alice Ryhl
2026-05-27 11:09     ` Gary Guo [this message]
2026-05-27 11:57 ` mateusz.nowicki
2026-05-27 14:06   ` Gary Guo
2026-05-27 18:16   ` Andreas Hindborg
2026-05-27 14:37 ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DITEV2DOK450.3R3J0EDVU6EJ5@garyguo.net \
    --to=gary@garyguo.net \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=axboe@kernel.dk \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=mateusz.nowicki@posteo.net \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox