null_blk always uses the default BLK_SAFE_MAX_SECTORS value for the max_hw_sectors and max_sectors queue limits resulting in a maximum request size of 127 sectors. When the blocksize setting is larger than the default 512B, this maximum request size is not aligned to the block size. To emulate a real device more accurately, fix this by setting the max_hw_sectors and max_sectors queue limits to a value that is aligned to the block size. Signed-off-by: Damien Le Moal <damien.lemoal@xxxxxxx> --- drivers/block/null_blk_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 4685ea401d5b..b77a506a4ae4 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1866,6 +1866,9 @@ static int null_add_dev(struct nullb_device *dev) blk_queue_logical_block_size(nullb->q, dev->blocksize); blk_queue_physical_block_size(nullb->q, dev->blocksize); + blk_queue_max_hw_sectors(nullb->q, + round_down(queue_max_hw_sectors(nullb->q), + dev->blocksize >> SECTOR_SHIFT)); null_config_discard(nullb); -- 2.26.2