* [PATCH] nvme: move nvme_dsm_range size check to _nvme_check_size()
@ 2024-02-23 3:29 Guixin Liu
2024-02-27 6:05 ` Guixin Liu
0 siblings, 1 reply; 4+ messages in thread
From: Guixin Liu @ 2024-02-23 3:29 UTC (permalink / raw)
To: kbusch, axboe, hch, sagi; +Cc: linux-nvme
Move nvme_dsm_range size check to _nvme_check_size(), and remove
redundant same check.
Signed-off-by: Guixin Liu <kanie@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);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme: move nvme_dsm_range size check to _nvme_check_size()
2024-02-23 3:29 [PATCH] nvme: move nvme_dsm_range size check to _nvme_check_size() Guixin Liu
@ 2024-02-27 6:05 ` Guixin Liu
2024-02-27 15:21 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Guixin Liu @ 2024-02-27 6:05 UTC (permalink / raw)
To: kbusch, axboe, hch, sagi; +Cc: linux-nvme
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@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);
> }
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme: move nvme_dsm_range size check to _nvme_check_size()
2024-02-27 6:05 ` Guixin Liu
@ 2024-02-27 15:21 ` Christoph Hellwig
2024-03-07 9:39 ` Sagi Grimberg
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2024-02-27 15:21 UTC (permalink / raw)
To: Guixin Liu; +Cc: kbusch, axboe, hch, sagi, linux-nvme
This is not a check for a spec provided struct size, so it should
not be grouped with them.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme: move nvme_dsm_range size check to _nvme_check_size()
2024-02-27 15:21 ` Christoph Hellwig
@ 2024-03-07 9:39 ` Sagi Grimberg
0 siblings, 0 replies; 4+ messages in thread
From: Sagi Grimberg @ 2024-03-07 9:39 UTC (permalink / raw)
To: Christoph Hellwig, Guixin Liu; +Cc: kbusch, axboe, linux-nvme
On 27/02/2024 17:21, Christoph Hellwig wrote:
> This is not a check for a spec provided struct size, so it should
> not be grouped with them.
>
Agreed.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-03-07 9:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-23 3:29 [PATCH] nvme: move nvme_dsm_range size check to _nvme_check_size() Guixin Liu
2024-02-27 6:05 ` Guixin Liu
2024-02-27 15:21 ` Christoph Hellwig
2024-03-07 9:39 ` Sagi Grimberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox