Commit fd764e74 authored by Andreas Hindborg's avatar Andreas Hindborg Committed by Miguel Ojeda

rust: block: fix wrong usage of lockdep API

When allocating `struct gendisk`, `GenDiskBuilder` is using a dynamic
lock class key without registering the key. This is an incorrect use of
the API, which causes a `WARN` trace.

Fix the issue by using a static lock class key, which is more appropriate
for the situation anyway.

Fixes: 3253aba3 ("rust: block: introduce `kernel::block::mq` module")
Reported-by: default avatarBehme Dirk (XC-CP/ESB5) <Dirk.Behme@de.bosch.com>
Closes: https://rust-for-linux.zulipchat.com/#narrow/stream/x/topic/x/near/457090036Signed-off-by: default avatarAndreas Hindborg <a.hindborg@samsung.com>
Reviewed-by: default avatarBenno Lossin <benno.lossin@proton.me>
Reviewed-by: default avatarGary Guo <gary@garyguo.net>
Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
Tested-by: default avatarDirk Behme <dirk.behme@de.bosch.com>
Link: https://lore.kernel.org/r/20240815074519.2684107-3-nmi@metaspace.dk
[ Applied `rustfmt`, reworded slightly and made Zulip link
  a permalink. - Miguel ]
Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
parent b8673d56
......@@ -6,8 +6,8 @@
//! C header: [`include/linux/blk_mq.h`](srctree/include/linux/blk_mq.h)
use crate::block::mq::{raw_writer::RawWriter, Operations, TagSet};
use crate::error;
use crate::{bindings, error::from_err_ptr, error::Result, sync::Arc};
use crate::{error, static_lock_class};
use core::fmt::{self, Write};
/// A builder for [`GenDisk`].
......@@ -93,8 +93,6 @@ pub fn build<T: Operations>(
name: fmt::Arguments<'_>,
tagset: Arc<TagSet<T>>,
) -> Result<GenDisk<T>> {
let lock_class_key = crate::sync::LockClassKey::new();
// SAFETY: `bindings::queue_limits` contain only fields that are valid when zeroed.
let mut lim: bindings::queue_limits = unsafe { core::mem::zeroed() };
......@@ -110,7 +108,7 @@ pub fn build<T: Operations>(
tagset.raw_tag_set(),
&mut lim,
core::ptr::null_mut(),
lock_class_key.as_ptr(),
static_lock_class!().as_ptr(),
)
})?;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment