Skip to content

Commit 2da6e00

Browse files
ChaitanayaKulkarniChristoph Hellwig
authored andcommitted
nvmet: add error log support for admin-cmd
This patch adds the support to maintain the error log page for admin commands. Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 762a11d commit 2da6e00

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

drivers/nvme/target/admin-cmd.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req,
4747
if (!ns) {
4848
pr_err("Could not find namespace id : %d\n",
4949
le32_to_cpu(req->cmd->get_log_page.nsid));
50+
req->error_loc = offsetof(struct nvme_rw_command, nsid);
5051
return NVME_SC_INVALID_NS;
5152
}
5253

@@ -380,6 +381,7 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
380381
u16 status = 0;
381382

382383
if (le32_to_cpu(req->cmd->identify.nsid) == NVME_NSID_ALL) {
384+
req->error_loc = offsetof(struct nvme_identify, nsid);
383385
status = NVME_SC_INVALID_NS | NVME_SC_DNR;
384386
goto out;
385387
}
@@ -500,6 +502,7 @@ static void nvmet_execute_identify_desclist(struct nvmet_req *req)
500502

501503
ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid);
502504
if (!ns) {
505+
req->error_loc = offsetof(struct nvme_identify, nsid);
503506
status = NVME_SC_INVALID_NS | NVME_SC_DNR;
504507
goto out;
505508
}
@@ -562,8 +565,10 @@ static u16 nvmet_set_feat_write_protect(struct nvmet_req *req)
562565
u16 status = NVME_SC_FEATURE_NOT_CHANGEABLE;
563566

564567
req->ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->rw.nsid);
565-
if (unlikely(!req->ns))
568+
if (unlikely(!req->ns)) {
569+
req->error_loc = offsetof(struct nvme_common_command, nsid);
566570
return status;
571+
}
567572

568573
mutex_lock(&subsys->lock);
569574
switch (write_protect) {
@@ -602,8 +607,10 @@ u16 nvmet_set_feat_async_event(struct nvmet_req *req, u32 mask)
602607
{
603608
u32 val32 = le32_to_cpu(req->cmd->common.cdw11);
604609

605-
if (val32 & ~mask)
610+
if (val32 & ~mask) {
611+
req->error_loc = offsetof(struct nvme_common_command, cdw11);
606612
return NVME_SC_INVALID_FIELD | NVME_SC_DNR;
613+
}
607614

608615
WRITE_ONCE(req->sq->ctrl->aen_enabled, val32);
609616
nvmet_set_result(req, val32);
@@ -635,6 +642,7 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
635642
status = nvmet_set_feat_write_protect(req);
636643
break;
637644
default:
645+
req->error_loc = offsetof(struct nvme_common_command, cdw10);
638646
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
639647
break;
640648
}
@@ -648,9 +656,10 @@ static u16 nvmet_get_feat_write_protect(struct nvmet_req *req)
648656
u32 result;
649657

650658
req->ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->common.nsid);
651-
if (!req->ns)
659+
if (!req->ns) {
660+
req->error_loc = offsetof(struct nvme_common_command, nsid);
652661
return NVME_SC_INVALID_NS | NVME_SC_DNR;
653-
662+
}
654663
mutex_lock(&subsys->lock);
655664
if (req->ns->readonly == true)
656665
result = NVME_NS_WRITE_PROTECT;
@@ -716,6 +725,8 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
716725
case NVME_FEAT_HOST_ID:
717726
/* need 128-bit host identifier flag */
718727
if (!(req->cmd->common.cdw11 & cpu_to_le32(1 << 0))) {
728+
req->error_loc =
729+
offsetof(struct nvme_common_command, cdw11);
719730
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
720731
break;
721732
}
@@ -727,6 +738,8 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
727738
status = nvmet_get_feat_write_protect(req);
728739
break;
729740
default:
741+
req->error_loc =
742+
offsetof(struct nvme_common_command, cdw10);
730743
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
731744
break;
732745
}
@@ -848,5 +861,6 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
848861

849862
pr_err("unhandled cmd %d on qid %d\n", cmd->common.opcode,
850863
req->sq->qid);
864+
req->error_loc = offsetof(struct nvme_common_command, opcode);
851865
return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
852866
}

0 commit comments

Comments
 (0)