summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2024-11-18 15:52:50 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-12-05 14:02:51 +0100
commit37c2ca4e89d049d4806745ecdc467864571a4227 (patch)
treee87f243380f9825eb60124b84a1377e7f6ee8048 /block
parentaaa90844afd499c9142d0199dfda74439314c013 (diff)
downloadlinux-37c2ca4e89d049d4806745ecdc467864571a4227.tar.gz
linux-37c2ca4e89d049d4806745ecdc467864571a4227.tar.bz2
linux-37c2ca4e89d049d4806745ecdc467864571a4227.zip
blk-settings: round down io_opt to physical_block_size
commit 9c0ba14828d64744ccd195c610594ba254a1a9ab upstream. 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/1426ad71-79b4-4062-b2bf-84278be66a5d@redhat.com/T/ [1] Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Fixes: a23634644afc ("block: take io_opt and io_min into account for max_sectors") Cc: stable@vger.kernel.org # v6.11+ Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/3dc0014b-9690-dc38-81c9-4a316a2d4fb2@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'block')
-rw-r--r--block/blk-settings.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/block/blk-settings.c b/block/blk-settings.c
index a446654ddee5..7abf034089cd 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -250,6 +250,13 @@ static int blk_validate_limits(struct queue_limits *lim)
lim->io_min = lim->physical_block_size;
/*
+ * 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.
+ */
+ lim->io_opt = round_down(lim->io_opt, lim->physical_block_size);
+
+ /*
* max_hw_sectors has a somewhat weird default for historical reason,
* but driver really should set their own instead of relying on this
* value.