@@ -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