]> www.infradead.org Git - nvme.git/commitdiff
rust: block: do not use removed queue limit API
authorAndreas Hindborg <a.hindborg@samsung.com>
Fri, 14 Jun 2024 23:53:50 +0000 (01:53 +0200)
committerJens Axboe <axboe@kernel.dk>
Sat, 15 Jun 2024 00:25:13 +0000 (18:25 -0600)
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 <boqun.feng@gmail.com>
Fixes: 3253aba3408a ("rust: block: introduce `kernel::block::mq` module")
Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com>
Link: https://lore.kernel.org/r/20240614235350.621121-1-nmi@metaspace.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
rust/kernel/block/mq/gen_disk.rs

index 3b9edb96c8ff77c26f9ccf1b3cc5a3e163b54502..e06044b549e0be6e694d9c38eada523bc9ffabf9 100644 (file)
@@ -95,11 +95,17 @@ impl GenDiskBuilder {
     ) -> 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() };
+
+        lim.logical_block_size = self.logical_block_size;
+        lim.physical_block_size = self.physical_block_size;
+
         // SAFETY: `tagset.raw_tag_set()` points to a valid and initialized tag set
         let gendisk = from_err_ptr(unsafe {
             bindings::__blk_mq_alloc_disk(
                 tagset.raw_tag_set(),
-                core::ptr::null_mut(), // TODO: We can pass queue limits right here
+                &mut lim,
                 core::ptr::null_mut(),
                 lock_class_key.as_ptr(),
             )
@@ -141,18 +147,6 @@ impl GenDiskBuilder {
         raw_writer.write_fmt(name)?;
         raw_writer.write_char('\0')?;
 
-        // SAFETY: `gendisk` points to a valid and initialized instance of
-        // `struct gendisk`. We have exclusive access, so we cannot race.
-        unsafe {
-            bindings::blk_queue_logical_block_size((*gendisk).queue, self.logical_block_size)
-        };
-
-        // SAFETY: `gendisk` points to a valid and initialized instance of
-        // `struct gendisk`. We have exclusive access, so we cannot race.
-        unsafe {
-            bindings::blk_queue_physical_block_size((*gendisk).queue, self.physical_block_size)
-        };
-
         // SAFETY: `gendisk` points to a valid and initialized instance of
         // `struct gendisk`. `set_capacity` takes a lock to synchronize this
         // operation, so we will not race.