* [PATCH] nvmet: check that host sqsize does not exceed ctrl MQES
@ 2021-07-26 5:25 amit.engel
0 siblings, 0 replies; 5+ messages in thread
From: amit.engel @ 2021-07-26 5:25 UTC (permalink / raw)
To: linux-nvme, sagi; +Cc: amit.engel
From: Amit Engel <amit.engel@dell.com>
Check that host sqsize is not greater-than
Maximum Queue Entries Supported (MQES) by the ctrl
Signed-off-by: Amit Engel <amit.engel@dell.com>
---
drivers/nvme/target/fabrics-cmd.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/nvme/target/fabrics-cmd.c b/drivers/nvme/target/fabrics-cmd.c
index 7d0f3523fdab..bc9407525d2c 100644
--- a/drivers/nvme/target/fabrics-cmd.c
+++ b/drivers/nvme/target/fabrics-cmd.c
@@ -109,6 +109,7 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req)
u16 qid = le16_to_cpu(c->qid);
u16 sqsize = le16_to_cpu(c->sqsize);
struct nvmet_ctrl *old;
+ u16 mqes = ctrl->cap & 0xffff;
u16 ret;
old = cmpxchg(&req->sq->ctrl, NULL, ctrl);
@@ -123,6 +124,13 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req)
ret = NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR;
goto err;
}
+ /* sqsize is not allowed to exceed Maximum Queue Entries Supported (MQES) */
+ if (sqsize > mqes) {
+ pr_warn("sqsize %u is larger than MQES supported %u cntlid %d\n",
+ sqsize, mqes, ctrl->cntlid);
+ req->error_loc = offsetof(struct nvmf_connect_command, sqsize);
+ return NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR;
+ }
/* note: convert queue size from 0's-based value to 1's-based value */
nvmet_cq_setup(ctrl, req->cq, qid, sqsize + 1);
--
2.18.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] nvmet: check that host sqsize does not exceed ctrl MQES
2021-08-05 15:02 amit.engel
2021-08-06 19:36 ` Sagi Grimberg
@ 2021-08-10 16:21 ` Christoph Hellwig
1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-08-10 16:21 UTC (permalink / raw)
To: amit.engel; +Cc: linux-nvme, sagi, kbusch
Thanks,
applied to nvme-5.15 with the comment removed as suggested by Sagi.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvmet: check that host sqsize does not exceed ctrl MQES
2021-08-05 15:02 amit.engel
@ 2021-08-06 19:36 ` Sagi Grimberg
2021-08-10 16:21 ` Christoph Hellwig
1 sibling, 0 replies; 5+ messages in thread
From: Sagi Grimberg @ 2021-08-06 19:36 UTC (permalink / raw)
To: amit.engel, linux-nvme, kbusch
> From: Amit Engel <amit.engel@dell.com>
>
> Check that host sqsize is not greater-than
> Maximum Queue Entries Supported (MQES) by the ctrl
>
> Signed-off-by: Amit Engel <amit.engel@dell.com>
> ---
> drivers/nvme/target/fabrics-cmd.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/nvme/target/fabrics-cmd.c b/drivers/nvme/target/fabrics-cmd.c
> index 7d0f3523fdab..2b4a41b45c45 100644
> --- a/drivers/nvme/target/fabrics-cmd.c
> +++ b/drivers/nvme/target/fabrics-cmd.c
> @@ -109,6 +109,7 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req)
> u16 qid = le16_to_cpu(c->qid);
> u16 sqsize = le16_to_cpu(c->sqsize);
> struct nvmet_ctrl *old;
> + u16 mqes = NVME_CAP_MQES(ctrl->cap);
> u16 ret;
>
> old = cmpxchg(&req->sq->ctrl, NULL, ctrl);
> @@ -123,6 +124,14 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req)
> ret = NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR;
> goto err;
> }
> + /* sqsize is not allowed to exceed Maximum Queue Entries Supported (MQES) */
Little redundant comment I think (it is also printed in the error).
> + if (sqsize > mqes) {
> + pr_warn("sqsize %u is larger than MQES supported %u cntlid %d\n",
> + sqsize, mqes, ctrl->cntlid);
> + req->error_loc = offsetof(struct nvmf_connect_command, sqsize);
> + req->cqe->result.u32 = IPO_IATTR_CONNECT_SQE(sqsize);
> + return NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR;
> + }
Otherwise,
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] nvmet: check that host sqsize does not exceed ctrl MQES
@ 2021-08-05 15:02 amit.engel
2021-08-06 19:36 ` Sagi Grimberg
2021-08-10 16:21 ` Christoph Hellwig
0 siblings, 2 replies; 5+ messages in thread
From: amit.engel @ 2021-08-05 15:02 UTC (permalink / raw)
To: linux-nvme, sagi, kbusch; +Cc: amit.engel
From: Amit Engel <amit.engel@dell.com>
Check that host sqsize is not greater-than
Maximum Queue Entries Supported (MQES) by the ctrl
Signed-off-by: Amit Engel <amit.engel@dell.com>
---
drivers/nvme/target/fabrics-cmd.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/nvme/target/fabrics-cmd.c b/drivers/nvme/target/fabrics-cmd.c
index 7d0f3523fdab..2b4a41b45c45 100644
--- a/drivers/nvme/target/fabrics-cmd.c
+++ b/drivers/nvme/target/fabrics-cmd.c
@@ -109,6 +109,7 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req)
u16 qid = le16_to_cpu(c->qid);
u16 sqsize = le16_to_cpu(c->sqsize);
struct nvmet_ctrl *old;
+ u16 mqes = NVME_CAP_MQES(ctrl->cap);
u16 ret;
old = cmpxchg(&req->sq->ctrl, NULL, ctrl);
@@ -123,6 +124,14 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req)
ret = NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR;
goto err;
}
+ /* sqsize is not allowed to exceed Maximum Queue Entries Supported (MQES) */
+ if (sqsize > mqes) {
+ pr_warn("sqsize %u is larger than MQES supported %u cntlid %d\n",
+ sqsize, mqes, ctrl->cntlid);
+ req->error_loc = offsetof(struct nvmf_connect_command, sqsize);
+ req->cqe->result.u32 = IPO_IATTR_CONNECT_SQE(sqsize);
+ return NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR;
+ }
/* note: convert queue size from 0's-based value to 1's-based value */
nvmet_cq_setup(ctrl, req->cq, qid, sqsize + 1);
--
2.18.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] nvmet: check that host sqsize does not exceed ctrl MQES
@ 2021-07-28 9:42 amit.engel
0 siblings, 0 replies; 5+ messages in thread
From: amit.engel @ 2021-07-28 9:42 UTC (permalink / raw)
To: linux-nvme, sagi; +Cc: amit.engel
From: Amit Engel <amit.engel@dell.com>
Check that host sqsize is not greater-than
Maximum Queue Entries Supported (MQES) by the ctrl
Signed-off-by: Amit Engel <amit.engel@dell.com>
---
drivers/nvme/target/fabrics-cmd.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/nvme/target/fabrics-cmd.c b/drivers/nvme/target/fabrics-cmd.c
index 7d0f3523fdab..f30ffe99245f 100644
--- a/drivers/nvme/target/fabrics-cmd.c
+++ b/drivers/nvme/target/fabrics-cmd.c
@@ -109,6 +109,7 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req)
u16 qid = le16_to_cpu(c->qid);
u16 sqsize = le16_to_cpu(c->sqsize);
struct nvmet_ctrl *old;
+ u16 mqes = NVME_CAP_MQES(ctrl->cap);
u16 ret;
old = cmpxchg(&req->sq->ctrl, NULL, ctrl);
@@ -123,6 +124,13 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req)
ret = NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR;
goto err;
}
+ /* sqsize is not allowed to exceed Maximum Queue Entries Supported (MQES) */
+ if (sqsize > mqes) {
+ pr_warn("sqsize %u is larger than MQES supported %u cntlid %d\n",
+ sqsize, mqes, ctrl->cntlid);
+ req->error_loc = offsetof(struct nvmf_connect_command, sqsize);
+ return NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR;
+ }
/* note: convert queue size from 0's-based value to 1's-based value */
nvmet_cq_setup(ctrl, req->cq, qid, sqsize + 1);
--
2.18.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-10 16:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-26 5:25 [PATCH] nvmet: check that host sqsize does not exceed ctrl MQES amit.engel
2021-07-28 9:42 amit.engel
2021-08-05 15:02 amit.engel
2021-08-06 19:36 ` Sagi Grimberg
2021-08-10 16:21 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.