[PATCH] nvme: move nvme_dsm_range size check to _nvme_check_size()

Guixin Liu kanie at linux.alibaba.com
Mon Feb 26 22:05:40 PST 2024


Hi,

     Gentle ping...

Best Regards,

Guixin Liu

在 2024/2/23 11:29, Guixin Liu 写道:
> Move nvme_dsm_range size check to _nvme_check_size(), and remove
> redundant same check.
>
> Signed-off-by: Guixin Liu <kanie at linux.alibaba.com>
> ---
>   drivers/nvme/host/core.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 5cdd22f591f9..848d4b896fec 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1800,9 +1800,6 @@ static void nvme_config_discard(struct nvme_ctrl *ctrl, struct gendisk *disk,
>   		return;
>   	}
>   
> -	BUILD_BUG_ON(PAGE_SIZE / sizeof(struct nvme_dsm_range) <
> -			NVME_DSM_MAX_RANGES);
> -
>   	/*
>   	 * If discard is already enabled, don't reset queue limits.
>   	 *
> @@ -4602,8 +4599,6 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
>   	ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive;
>   	ctrl->ka_last_check_time = jiffies;
>   
> -	BUILD_BUG_ON(NVME_DSM_MAX_RANGES * sizeof(struct nvme_dsm_range) >
> -			PAGE_SIZE);
>   	ctrl->discard_page = alloc_page(GFP_KERNEL);
>   	if (!ctrl->discard_page) {
>   		ret = -ENOMEM;
> @@ -4823,6 +4818,8 @@ static inline void _nvme_check_size(void)
>   	BUILD_BUG_ON(sizeof(struct nvme_dbbuf) != 64);
>   	BUILD_BUG_ON(sizeof(struct nvme_directive_cmd) != 64);
>   	BUILD_BUG_ON(sizeof(struct nvme_feat_host_behavior) != 512);
> +	BUILD_BUG_ON(NVME_DSM_MAX_RANGES * sizeof(struct nvme_dsm_range) >
> +			PAGE_SIZE);
>   }
>   
>   



More information about the Linux-nvme mailing list