RE: [PATCH 62/79] block: rust: add `TagSet::update_hw_queue_count`

Ken Kurematsu
2026-02-16T23:59:41Z

Hi Andreas,

> -----Original Message-----
> From: Andreas Hindborg <a.hindborg@kernel.org>
> Sent: Monday, February 16, 2026 8:36 AM
> To: Boqun Feng <boqun.feng@gmail.com>; Jens Axboe <axboe@kernel.dk>;
> Miguel Ojeda <ojeda@kernel.org>; Gary Guo <gary@garyguo.net>; Björn Roy
> Baron <bjorn3_gh@protonmail.com>; Benno Lossin <lossin@kernel.org>;
> Alice Ryhl <aliceryhl@google.com>; Trevor Gross <tmgross@umich.edu>;
> Danilo Krummrich <dakr@kernel.org>; FUJITA Tomonori
> <fujita.tomonori@gmail.com>; Frederic Weisbecker <frederic@kernel.org>;
> Lyude Paul <lyude@redhat.com>; Thomas Gleixner <tglx@kernel.org>;
> Anna-Maria Behnsen <anna-maria@linutronix.de>; John Stultz
> <jstultz@google.com>; Stephen Boyd <sboyd@kernel.org>; Lorenzo Stoakes
> <lorenzo.stoakes@oracle.com>; Liam R. Howlett
> <Liam.Howlett@oracle.com>
> Cc: linux-block@vger.kernel.org; rust-for-linux@vger.kernel.org;
> linux-kernel@vger.kernel.org; linux-mm@kvack.org; Andreas Hindborg
> <a.hindborg@kernel.org>
> Subject: [PATCH 62/79] block: rust: add `TagSet::update_hw_queue_count`
>
> Add a method to `TagSet` that allows changing the number of hardware
> queues
> dynamically.
>
> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
> ---
> rust/kernel/block/mq/tag_set.rs | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/rust/kernel/block/mq/tag_set.rs
> b/rust/kernel/block/mq/tag_set.rs
> index 4d00979a83dbd..47a162360e628 100644
> --- a/rust/kernel/block/mq/tag_set.rs
> +++ b/rust/kernel/block/mq/tag_set.rs
> @@ -8,6 +8,7 @@
> bindings,
> block::mq::{operations::OperationsVTable, request::RequestDataWrapper,
> Operations},
> error::{self, Result},
> + prelude::*,
> try_pin_init,
> types::{ForeignOwnable, Opaque},
> };
> @@ -34,7 +35,7 @@ pub struct TagSet<T: Operations> {
> }
>
> impl<T: Operations> TagSet<T> {
> - /// Try to create a new tag set
> + /// Try to create a new tag se }t

Is this a typo?
It looks like an unnecessary ' }'.

> pub fn new(
> nr_hw_queues: u32,
> tagset_data: T::TagSetData,
> @@ -142,6 +143,20 @@ pub fn hw_queue_count(&self) -> u32 {
> unsafe { (*self.inner.get()).nr_hw_queues }
> }
>
> + /// Update the number of hardware queues for this tag set.
> + ///
> + /// This operation may fail if memory for tags cannot be allocated.
> + pub fn update_hw_queue_count(&self, nr_hw_queues: u32) -> Result {
> + // SAFETY: blk_mq_update_nr_hw_queues applies internal
> synchronization.
> + unsafe { bindings::blk_mq_update_nr_hw_queues(self.inner.get(),
> nr_hw_queues) }
> +
> + if self.hw_queue_count() == nr_hw_queues {
> + Ok(())
> + } else {
> + Err(ENOMEM)
> + }
> + }
> +
> /// Borrow the [`T::TagSetData`] associated with this tag set.
> pub fn data(&self) -> <T::TagSetData as
> ForeignOwnable>::Borrowed<'_> {
> // SAFETY: By type invariant, `self.inner` is valid.
>
> --
> 2.51.2
>
>

Best regards,
Ken Kurematsu