Skip to content

Commit 9c0ba14

Browse files
Mikulas Patockaaxboe
authored andcommitted
blk-settings: round down io_opt to physical_block_size
There was a bug report [1] where the user got a warning alignment inconsistency. The user has optimal I/O 16776704 (0xFFFE00) and physical block size 4096. Note that the optimal I/O size may be set by the DMA engines or SCSI controllers and they have no knowledge about the disks attached to them, so the situation with optimal I/O not aligned to physical block size may happen. This commit makes blk_validate_limits round down optimal I/O size to the physical block size of the block device. Closes: https://lore.kernel.org/dm-devel/[email protected]/T/ [1] Signed-off-by: Mikulas Patocka <[email protected]> Fixes: a236346 ("block: take io_opt and io_min into account for max_sectors") Cc: [email protected] # v6.11+ Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent a3f143c commit 9c0ba14

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

block/blk-settings.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ int blk_validate_limits(struct queue_limits *lim)
248248
if (lim->io_min < lim->physical_block_size)
249249
lim->io_min = lim->physical_block_size;
250250

251+
/*
252+
* The optimal I/O size may not be aligned to physical block size
253+
* (because it may be limited by dma engines which have no clue about
254+
* block size of the disks attached to them), so we round it down here.
255+
*/
256+
lim->io_opt = round_down(lim->io_opt, lim->physical_block_size);
257+
251258
/*
252259
* max_hw_sectors has a somewhat weird default for historical reason,
253260
* but driver really should set their own instead of relying on this

0 commit comments

Comments
 (0)