All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk-settings: round down io_opt to at least 4K
@ 2025-01-20 15:16 Mikulas Patocka
  2025-01-22  6:12 ` Christoph Hellwig
  2025-01-23 12:24 ` Milan Broz
  0 siblings, 2 replies; 18+ messages in thread
From: Mikulas Patocka @ 2025-01-20 15:16 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Alasdair Kergon, Mike Snitzer, Zdenek Kabelac, linux-block,
	dm-devel

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(-)

Index: linux-2.6/block/blk-settings.c
===================================================================
--- linux-2.6.orig/block/blk-settings.c	2025-01-03 21:10:56.000000000 +0100
+++ linux-2.6/block/blk-settings.c	2025-01-20 15:59:13.000000000 +0100
@@ -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,


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2025-02-10 17:02 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-20 15:16 [PATCH] blk-settings: round down io_opt to at least 4K Mikulas Patocka
2025-01-22  6:12 ` Christoph Hellwig
2025-02-03 13:38   ` Mikulas Patocka
2025-02-03 19:02     ` Martin K. Petersen
2025-02-03 21:05       ` Mikulas Patocka
2025-02-04  3:30         ` Martin K. Petersen
2025-02-04  5:57           ` Christoph Hellwig
2025-02-04 13:02             ` Martin K. Petersen
2025-02-04 13:50               ` Christoph Hellwig
2025-02-05  2:36                 ` Martin K. Petersen
2025-02-05 16:00                   ` Christoph Hellwig
2025-02-04 14:56           ` Mikulas Patocka
2025-02-05  2:41             ` Martin K. Petersen
2025-02-10 12:54               ` Mikulas Patocka
2025-02-10 17:02                 ` Milan Broz
2025-02-04  5:56         ` Christoph Hellwig
2025-02-04  5:55     ` Christoph Hellwig
2025-01-23 12:24 ` Milan Broz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.