* [PATCH V3] nvmet: check ncqr & nsqr for set-features cmd
@ 2020-03-01 0:28 Chaitanya Kulkarni
2020-03-02 17:41 ` Sagi Grimberg
0 siblings, 1 reply; 3+ messages in thread
From: Chaitanya Kulkarni @ 2020-03-01 0:28 UTC (permalink / raw)
To: linux-nvme; +Cc: sagi, Chaitanya Kulkarni, amit.engel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 1852 bytes --]
From: Amit Engel <amit.engel@dell.com>
For set feature command when setting up NVME_FEAT_NUM_QUEUES, check
Number of I/O Completion Queues Requested (NCQR) and
Number of I/O Submission Queues Requested (NSQR) before we proceed, for
invalid values (i.e. 65535) return an appropriate NVMe invalid field
status.
Signed-off-by: Amit Engel <Amit.Engel@dell.com>
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
Changes from V2 :
1. Remove initialization of the ncqr and nsqr variables at the start,
and initialize them in the NVME_FEAT_NUM_QUEUES switch-case where
they are actually used.
2. Add a patch version information and the history since it has more
than one versions.
3. Fix patch subject and description.
Changes from V1 :
1. Avoid parenthesis in the switch-case statement and declare and
initialize ncqr and nsqr variables at the start of the function.
---
drivers/nvme/target/admin-cmd.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 19f949570625..83df11a7dace 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -733,13 +733,22 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
{
struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
+ u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11);
u16 status = 0;
+ u16 nsqr;
+ u16 ncqr;
if (!nvmet_check_data_len(req, 0))
return;
switch (cdw10 & 0xff) {
case NVME_FEAT_NUM_QUEUES:
+ ncqr = (cdw11 >> 16) & 0xffff;
+ nsqr = cdw11 & 0xffff;
+ if (ncqr == 0xffff || nsqr == 0xffff) {
+ status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
+ break;
+ }
nvmet_set_result(req,
(subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16));
break;
--
2.22.1
[-- Attachment #2: Type: text/plain, Size: 158 bytes --]
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V3] nvmet: check ncqr & nsqr for set-features cmd
2020-03-01 0:28 [PATCH V3] nvmet: check ncqr & nsqr for set-features cmd Chaitanya Kulkarni
@ 2020-03-02 17:41 ` Sagi Grimberg
2020-03-03 0:00 ` Keith Busch
0 siblings, 1 reply; 3+ messages in thread
From: Sagi Grimberg @ 2020-03-02 17:41 UTC (permalink / raw)
To: Chaitanya Kulkarni, linux-nvme; +Cc: amit.engel
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] 3+ messages in thread
* Re: [PATCH V3] nvmet: check ncqr & nsqr for set-features cmd
2020-03-02 17:41 ` Sagi Grimberg
@ 2020-03-03 0:00 ` Keith Busch
0 siblings, 0 replies; 3+ messages in thread
From: Keith Busch @ 2020-03-03 0:00 UTC (permalink / raw)
To: Sagi Grimberg; +Cc: linux-nvme, Chaitanya Kulkarni, amit.engel
Thanks, everyone. Patch applied for 5.7.
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-03 0:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-01 0:28 [PATCH V3] nvmet: check ncqr & nsqr for set-features cmd Chaitanya Kulkarni
2020-03-02 17:41 ` Sagi Grimberg
2020-03-03 0:00 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).