[PATCH 13/20] nvme: set the queue limits in nvme_update_ns_info

Chaitanya Kulkarni Chaitanya.Kulkarni at wdc.com
Tue Sep 29 17:52:17 EDT 2020


On 9/28/20 05:46, Christoph Hellwig wrote:
> Only set the queue limits once we have the real block size.  This also
> updates the limits on a rescan if needed.
>
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
>  drivers/nvme/host/core.c | 46 ++++++++++++++++++----------------------
>  1 file changed, 21 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 910198c3e0bbd1..bb630d5fcb9647 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2010,6 +2010,26 @@ static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
>  	return 0;
>  }
>  
> +static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
> +		struct request_queue *q)
> +{
> +	bool vwc = false;
nit:- If we are initializing vwc why not :-

 bool vwc = ctrl->vwc & NVME_CTRL_VWC_PRESENT ? true : false;

and get rid of the if before call to blk_queue_write_cache() that way

all blk_queue_XXX() calls will look smooth.

Irrespective of that, looks good.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>

> +
> +	if (ctrl->max_hw_sectors) {
> +		u32 max_segments =
> +			(ctrl->max_hw_sectors / (NVME_CTRL_PAGE_SIZE >> 9)) + 1;
> +
> +		max_segments = min_not_zero(max_segments, ctrl->max_segments);
> +		blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors);
> +		blk_queue_max_segments(q, min_t(u32, max_segments, USHRT_MAX));
> +	}
> +	blk_queue_virt_boundary(q, NVME_CTRL_PAGE_SIZE - 1);
> +	blk_queue_dma_alignment(q, 7);
> +	if (ctrl->vwc & NVME_CTRL_VWC_PRESENT)
> +		vwc = true;
> +	blk_queue_write_cache(q, vwc, vwc);
> +}
> +





More information about the Linux-nvme mailing list