Re: [PATCH] block: fix arg type in `blk_mq_update_nr_hw_queues`

From: Andreas Hindborg

Date: Tue Jun 09 2026 - 04:07:23 EST


"Bart Van Assche" <bvanassche@xxxxxxx> writes:

> On 6/8/26 1:39 AM, Andreas Hindborg wrote:
>> The type of the argument `nr_hw_queues` in the function
>> `blk_mq_update_nr_hw_queues` is a signed integer. This is wrong,
>> considering the field `nr_hw_queues` of `struct blk_mq_tag_set` is
>> unsigned. Thus, change the type of the parameter to unsigned.
>
> Will there ever be storage devices that support more than 2**31 hardware
> queues? If not,

Probably not.

> I think the word "wrong" in the commit message is too
> strong.

Right, I understand. I can change the wording. I chose it because it
seems wrong to me to use a signed type for a value that logically should
never assume a negative value. If the negative value was used to carry
some kind of information, it would make sense, but that is not the case
here.

> If this patch does not change the behavior of the code for any practical
> use case that would be good to mention.

The patch does not change behavior of the code as long as no overflows
occur, and they are not likely to occur. I will be sure to add that to
the commit message.

I came across this while designing the Rust API for these functions.
Rust is kind of particular about integer types, so it gave me some
checks/casts on the Rust side that really should no be required. I was
thinking we might as well change the type on the C side to unsigned when
the data it carries really should be unsigned.

Best regards,
Andreas Hindborg