nvmet: check that host sqsize does not exceed ctrl MQES
Subsystems (2)
PATCH 1/1 nvmet: check that host sqsize does not exceed ctrl MQES
From: Amit Engel <[email protected]>
Check that host sqsize is not greater-than Maximum Queue Entries Supported (MQES) by the ctrl
--- drivers/nvme/target/fabrics-cmd.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/nvme/target/fabrics-cmd.c +9 -0
@@ -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 );
Signature · 7 lines
2.18.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 24 lines
From: Amit Engel <[email protected]>
Check that host sqsize is not greater-than Maximum Queue Entries Supported (MQES) by the ctrl
Signed-off-by Amit Engel <[email protected]>--- drivers/nvme/target/fabrics-cmd.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/nvme/target/fabrics-cmd.c +1
-0@@ -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);
drivers/nvme/target/fabrics-cmd.c static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req) · line 127
Quoted 4 lines
drivers/nvme/target/fabrics-cmd.c +1
-0@@ -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).
drivers/nvme/target/fabrics-cmd.c static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req) · line 134
Quoted 7 lines
drivers/nvme/target/fabrics-cmd.c +7
-0+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,
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
AppliedThanks,
applied to nvme-5.15 with the comment removed as suggested by Sagi.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme