Re: [PATCH 12/79] block: rust: add `TagSet` flags

Alice Ryhl
2026-03-16T10:34:10Z

On Mon, Feb 16, 2026 at 12:34:59AM +0100, Andreas Hindborg wrote:
> Add support for `TagSet` flags by introducing a `Flags` type and adding
> a flags parameter to `TagSet::new`. This allows configuring tagset
> behavior such as blocking vs non-blocking operation.
>
> The Flags type supports bitwise operations and provides values like
> `Blocking` for common use cases. The module documentation example is
> updated to demonstrate the new API.
>
> For now, only a single flag is added.
>
> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>

with nits fixed:
Reviewed-by: Alice Ryhl <aliceryhl@google.com>

> /// A wrapper for the C `struct blk_mq_tag_set`.
> ///
> /// `struct blk_mq_tag_set` contains a `struct list_head` and so must be pinned.
> @@ -37,6 +41,7 @@ pub fn new(
> nr_hw_queues: u32,
> num_tags: u32,
> num_maps: u32,
> + flags: Flags,
> ) -> impl PinInit<Self, error::Error> {
> // SAFETY: `blk_mq_tag_set` only contains integers and pointers, which
> // all are allowed to be 0.
> @@ -51,7 +56,7 @@ pub fn new(
> numa_node: bindings::NUMA_NO_NODE,
> queue_depth: num_tags,
> cmd_size,
> - flags: 0,
> + flags: flags.into_inner(),
> driver_data: core::ptr::null_mut::<crate::ffi::c_void>(),

c_void in prelude.

> nr_maps: num_maps,
> ..tag_set
> diff --git a/rust/kernel/block/mq/tag_set/flags.rs b/rust/kernel/block/mq/tag_set/flags.rs
> new file mode 100644
> index 0000000000000..768db938b9a95
> --- /dev/null
> +++ b/rust/kernel/block/mq/tag_set/flags.rs
> @@ -0,0 +1,19 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +use kernel::prelude::*;
> +
> +impl_flags! {
> +
> + /// Flags to be used when creating [`super::TagSet`] objects.
> + #[derive(Debug, Clone, Default, Copy, PartialEq, Eq)]
> + pub struct Flags(u32);

Nit: Spurious newline in beginning of macro.

Alice