Skip to content

Commit 5e3b700

Browse files
metaspaceaxboe
authored andcommitted
rust: block: do not use removed queue limit API
The Rust block layer API was using the old queue limit API, which was just removed. Use the new API instead. Reported-by: Boqun Feng <[email protected]> Fixes: 3253aba ("rust: block: introduce `kernel::block::mq` module") Signed-off-by: Andreas Hindborg <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent e3e72fe commit 5e3b700

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

rust/kernel/block/mq/gen_disk.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,17 @@ impl GenDiskBuilder {
9595
) -> Result<GenDisk<T>> {
9696
let lock_class_key = crate::sync::LockClassKey::new();
9797

98+
// SAFETY: `bindings::queue_limits` contain only fields that are valid when zeroed.
99+
let mut lim: bindings::queue_limits = unsafe { core::mem::zeroed() };
100+
101+
lim.logical_block_size = self.logical_block_size;
102+
lim.physical_block_size = self.physical_block_size;
103+
98104
// SAFETY: `tagset.raw_tag_set()` points to a valid and initialized tag set
99105
let gendisk = from_err_ptr(unsafe {
100106
bindings::__blk_mq_alloc_disk(
101107
tagset.raw_tag_set(),
102-
core::ptr::null_mut(), // TODO: We can pass queue limits right here
108+
&mut lim,
103109
core::ptr::null_mut(),
104110
lock_class_key.as_ptr(),
105111
)
@@ -141,18 +147,6 @@ impl GenDiskBuilder {
141147
raw_writer.write_fmt(name)?;
142148
raw_writer.write_char('\0')?;
143149

144-
// SAFETY: `gendisk` points to a valid and initialized instance of
145-
// `struct gendisk`. We have exclusive access, so we cannot race.
146-
unsafe {
147-
bindings::blk_queue_logical_block_size((*gendisk).queue, self.logical_block_size)
148-
};
149-
150-
// SAFETY: `gendisk` points to a valid and initialized instance of
151-
// `struct gendisk`. We have exclusive access, so we cannot race.
152-
unsafe {
153-
bindings::blk_queue_physical_block_size((*gendisk).queue, self.physical_block_size)
154-
};
155-
156150
// SAFETY: `gendisk` points to a valid and initialized instance of
157151
// `struct gendisk`. `set_capacity` takes a lock to synchronize this
158152
// operation, so we will not race.

0 commit comments

Comments
 (0)