[PATCH v2 2/4] block: factor block size and alignment handling out of blk_stack_limits

John Garry john.g.garry at oracle.com
Mon Aug 17 10:05:28 PDT 2026


On 06/08/2026 03:46, Yao Sang wrote:
> Topology limits are the block size and alignment limits that the top
> device exposes after its data is placed at an offset on a bottom device.
> blk_stack_limits() uses start, the first data sector in the bottom device
> used by the top device, to calculate alignment_offset.
> 
> It then stacks logical_block_size, physical_block_size, io_min, io_opt and
> chunk_sectors, checks that they are compatible, and rounds max_sectors,
> max_hw_sectors and max_dev_sectors down to the final logical_block_size.
> 
> Keep these operations together because the checks and rounding must run
> after the final logical and physical block sizes are known. Factor them
> into a static blk_stack_topology_limits() helper.

It still is not clear to me what is the criteria for a limit to be 
evaluated in blk_stack_topology_limits() (and not in blk_stack_limits()).

You seem to be just saying that some limits need to be calculated before 
other dependent limits, so put them in a separate function.

> 
> There is no behavior change.
> > Signed-off-by: Yao Sang <sangyao at kylinos.cn>
> ---
>   block/blk-settings.c | 169 ++++++++++++++++++++++++-------------------
>   1 file changed, 93 insertions(+), 76 deletions(-)
> 
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index 8274631290db..1aff818aaaac 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -756,6 +756,96 @@ static void blk_stack_atomic_writes_limits(struct queue_limits *t,
>   	t->atomic_write_hw_boundary = 0;
>   }
>   
> +/*
> + * Stack and check logical_block_size, physical_block_size, io_min, io_opt,
> + * chunk_sectors and alignment_offset for a bottom-device range, then round
> + * max_sectors, max_hw_sectors and max_dev_sectors to logical_block_size.
> + */

This just describes what the code does. Anyone can see that.

> +static int blk_stack_topology_limits(struct queue_limits *t,
> +		const struct queue_limits *b, sector_t start)
> +{
> +	unsigned int top, bottom, alignment;
> +	int ret = 0;



More information about the Linux-nvme mailing list