[PATCHv2] nvme: implement non-mdts command limits

Christoph Hellwig hch at lst.de
Thu Mar 18 04:42:45 GMT 2021


>  static void nvme_config_write_zeroes(struct request_queue *q,
>  		struct nvme_ctrl *ctrl)
>  {
> +	blk_queue_max_write_zeroes_sectors(q, ctrl->max_zeroes_sectors);

I think at this point we can kill nvme_config_write_zeroes :)

> +static int nvme_init_non_mdts_limits(struct nvme_ctrl *ctrl)
> +{
> +	struct nvme_command c = { };
> +	struct nvme_id_ctrl_nvm *id;
> +	int ret;
> +
> +	if (!(ctrl->oncs & NVME_CTRL_ONCS_DSM)) {
> +		ctrl->max_discard_sectors = 0;
> +		ctrl->max_discard_segments = 0;
> +	} else {
> +		ctrl->max_discard_sectors = UINT_MAX;
> +		ctrl->max_discard_segments = NVME_DSM_MAX_RANGES;
> +	}

Can you switch the polarity here, that is avoid the pointless
negation in the if?

> +	if (ctrl->vs < NVME_VS(1, 2, 0))
> +		return 0;

This check doesn't make much sense to me, as new TPs can always apply
to older spec versions as well.  Instead this probably should be a
nvme_ctrl_limited_cns() check.



More information about the Linux-nvme mailing list