@@ -95,11 +95,17 @@ impl GenDiskBuilder {
95
95
) -> Result < GenDisk < T > > {
96
96
let lock_class_key = crate :: sync:: LockClassKey :: new ( ) ;
97
97
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
+
98
104
// SAFETY: `tagset.raw_tag_set()` points to a valid and initialized tag set
99
105
let gendisk = from_err_ptr ( unsafe {
100
106
bindings:: __blk_mq_alloc_disk (
101
107
tagset. raw_tag_set ( ) ,
102
- core :: ptr :: null_mut ( ) , // TODO: We can pass queue limits right here
108
+ & mut lim ,
103
109
core:: ptr:: null_mut ( ) ,
104
110
lock_class_key. as_ptr ( ) ,
105
111
)
@@ -141,18 +147,6 @@ impl GenDiskBuilder {
141
147
raw_writer. write_fmt ( name) ?;
142
148
raw_writer. write_char ( '\0' ) ?;
143
149
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
-
156
150
// SAFETY: `gendisk` points to a valid and initialized instance of
157
151
// `struct gendisk`. `set_capacity` takes a lock to synchronize this
158
152
// operation, so we will not race.
0 commit comments