From: Keith Busch <kbusch@xxxxxxxxxx> The user can set the max_sectors limit to any valid value via sysfs /sys/block/<dev>/queue/max_sectors_kb attribute. If the device limits are ever rescanned, though, the limit reverts back to the potentially artificially low BLK_DEF_MAX_SECTORS value. Preserve the user's setting as long as it's valid and greater than the default. Signed-off-by: Keith Busch <kbusch@xxxxxxxxxx> --- block/blk-settings.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index 0477c4d527fee..523348926a800 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -135,7 +135,8 @@ void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_secto limits->max_hw_sectors = max_hw_sectors; max_sectors = min_not_zero(max_hw_sectors, limits->max_dev_sectors); - max_sectors = min_t(unsigned int, max_sectors, BLK_DEF_MAX_SECTORS); + max_sectors = min_t(unsigned int, max_sectors, max(limits->max_sectors, + BLK_DEF_MAX_SECTORS)); max_sectors = round_down(max_sectors, limits->logical_block_size >> SECTOR_SHIFT); limits->max_sectors = max_sectors; -- 2.30.2