]> www.infradead.org Git - users/hch/block.git/commit
block: take io_opt and io_min into account for max_sectors
authorChristoph Hellwig <hch@lst.de>
Fri, 31 May 2024 07:28:58 +0000 (09:28 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 31 May 2024 07:28:58 +0000 (09:28 +0200)
commit285177f71ed1727df6728e3ab2f2610341c8ecd2
tree096ad653ffecb47ab07176d1268dd81dd7ebacd6
parent2175fd35d2e9944e010b89859e20c11964aa3d1a
block: take io_opt and io_min into account for max_sectors

The soft max_sectors limit is normally capped by the hardware limits and
an arbitrary upper limit enforced by the kernel, but can be modified by
the user.  A few drivers want to increase this limit (nbd, rbd) or
adjust it up or down based on hardware capabilities (sd).

Change blk_validate_limits to default max_sectors to the optimal I/O
size, or upgrade it to the preferred minimal I/O size if that is
larger than the kernel default if no optimal I/O size is provided based
on the logic in the SD driver.

This keeps the existing kernel default for drivers that do not provide
an io_opt or very big io_min value, but picks a much more useful
default for those who provide these hints, and allows to remove the
hacks to set the user max_sectors limit in nbd, rbd and sd.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
block/blk-settings.c
drivers/block/nbd.c
drivers/block/rbd.c
drivers/scsi/sd.c