[PATCH v2 5/7] nvme: set discard_granularity from NPDG/NPDA

Keith Busch kbusch at kernel.org
Tue Feb 24 07:15:21 PST 2026


On Fri, Feb 20, 2026 at 08:33:00PM -0700, Caleb Sander Mateos wrote:
> @@ -2113,11 +2114,27 @@ static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id,
>  	else if (ctrl->oncs & NVME_CTRL_ONCS_DSM)
>  		lim->max_hw_discard_sectors = UINT_MAX;
>  	else
>  		lim->max_hw_discard_sectors = 0;
>  
> -	lim->discard_granularity = lim->logical_block_size;
> +	if (ctrl->dmrsl && ctrl->dmrsl <= nvme_sect_to_lba(ns->head, UINT_MAX))
> +		lim->max_hw_discard_sectors =
> +			nvme_lba_to_sect(ns->head, ctrl->dmrsl);
> +	else if (ctrl->oncs & NVME_CTRL_ONCS_DSM)
> +		lim->max_hw_discard_sectors = UINT_MAX;
> +	else
> +		lim->max_hw_discard_sectors = 0;

Something seems off about this patch: these last four new lines added
here are the same as the unmodified lines preceding it.



More information about the Linux-nvme mailing list