From: amit.engel@dell.com
To: linux-nvme@lists.infradead.org, sagi@grimberg.me
Cc: amit.engel@dell.com
Subject: [PATCH] nvmet: check that host sqsize does not exceed ctrl MQES
Date: Wed, 28 Jul 2021 12:42:34 +0300 [thread overview]
Message-ID: <20210728094234.119049-1-amit.engel@dell.com> (raw)
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
next reply other threads:[~2021-07-28 9:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-28 9:42 amit.engel [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-08-05 15:02 [PATCH] nvmet: check that host sqsize does not exceed ctrl MQES amit.engel
2021-08-06 19:36 ` Sagi Grimberg
2021-08-10 16:21 ` Christoph Hellwig
2021-07-26 5:25 amit.engel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210728094234.119049-1-amit.engel@dell.com \
--to=amit.engel@dell.com \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox