===================================================================
@@ -269,8 +269,12 @@ int blk_validate_limits(struct queue_lim
* The optimal I/O size may not be aligned to physical block size
* (because it may be limited by dma engines which have no clue about
* block size of the disks attached to them), so we round it down here.
+ *
+ * Note that some SSDs erroneously report physical_block_size 512
+ * despite the fact that they have remapping table granularity 4K and
+ * they perform read-modify-write for unaligned requests.
*/
- lim->io_opt = round_down(lim->io_opt, lim->physical_block_size);
+ lim->io_opt = round_down(lim->io_opt, max(4096, lim->physical_block_size));
/*
* max_hw_sectors has a somewhat weird default for historical reason,
Some SATA SSDs and most NVMe SSDs report physical block size 512 bytes, but they use 4K remapping table internally and they do slow read-modify-write cycle for requests that are not aligned on 4K boundary. Therefore, io_opt should be aligned on 4K. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Fixes: a23634644afc ("block: take io_opt and io_min into account for max_sectors") Fixes: 9c0ba14828d6 ("blk-settings: round down io_opt to physical_block_size") Cc: stable@vger.kernel.org # v6.11+ --- block/blk-settings.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)