[PATCH v3 5/5] block, nvme: add same-LBA multipath limit helpers

John Garry john.g.garry at oracle.com
Mon Sep 7 02:44:09 PDT 2026


On 21/08/2026 11:10, Yao Sang wrote:
> A same-LBA multipath head and its paths address the same logical block
> space, so they do not need mapped-range topology calculations.
> 
> Add blk_stack_mpath_limits() to stack limits that may differ between
> paths, and blk_set_mpath_head_limits() to set head limits that are
> expected to be identical across paths. Export both helpers and use them
> for NVMe namespace heads.
> 
> Initialize max_hw_discard_sectors to UINT_MAX before stacking the first
> path. A zero limit means that a path does not support discard, so it
> disables discard for the head.
> 
> Signed-off-by: Yao Sang<sangyao at kylinos.cn>
> ---
>    block/blk-settings.c          | 58 +++++++++++++++++++++++++++++++++++
>    drivers/nvme/host/core.c      | 34 ++-------------------
>    drivers/nvme/host/multipath.c |  2 ++
>    include/linux/blkdev.h        |  3 ++
>    4 files changed, 65 insertions(+), 32 deletions(-)
> 
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index eaba38370657..8f70bab0a814 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -800,6 +800,64 @@ static void blk_stack_path_limits(struct queue_limits *t,
>    	t->dma_alignment = max(t->dma_alignment, b->dma_alignment);
>    }
>    
> +/**
> + * blk_set_mpath_head_limits - set head limits common to all paths
> + * @t: limits for the multipath head
> + * @b: limits for one path
> + *
> + * Set head limits that are expected to be identical across paths. Stack
> + * limits that may differ between paths with blk_stack_mpath_limits().
> + */
> +void blk_set_mpath_head_limits(struct queue_limits *t,
> +			       struct queue_limits *b)

nit: mpath_head is a NVMe multipath term, so maybe we need something 
more generic

> +{
> +	t->logical_block_size = b->logical_block_size;
> +	t->physical_block_size = b->physical_block_size;
> +	t->alignment_offset = b->alignment_offset;
> +	t->io_min = b->io_min;
> +	t->io_opt = b->io_opt;

I would not say that io_opt is really fixed for the disk. For SCSI, we 
change this value from transport/HBA factors - see sd_revalidate_disk() 
and how io_opt may change from the SCSI HBA limits.

I think that you need to take a conservative approach here in deciding 
what is a fixed limit for a disk.

> +	t->discard_granularity = b->discard_granularity;
> +	t->discard_alignment = b->discard_alignment;
> +	t->zone_write_granularity = b->zone_write_granularity;
> +	t->max_write_streams = b->max_write_streams;
> +	t->write_stream_granularity = b->write_stream_granularity;
> +}
> +EXPORT_SYMBOL_GPL(blk_set_mpath_head_limits);




More information about the Linux-nvme mailing list