diff options
author | Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> | 2021-02-09 21:47:56 -0800 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2021-02-10 16:38:05 +0100 |
commit | d81d57cf1b4702b7c2fa8ce8f1d5c6961a0c20b5 (patch) | |
tree | c6dc382e3a0d32548a86e509d33a738471cd78e9 /drivers/nvme/target/core.c | |
parent | nvmet: remove extra variable in id-ns handler (diff) | |
download | linux-dev-d81d57cf1b4702b7c2fa8ce8f1d5c6961a0c20b5.tar.xz linux-dev-d81d57cf1b4702b7c2fa8ce8f1d5c6961a0c20b5.zip |
nvmet: add helper to report invalid opcode
In the NVMeOF block device backend, file backend, and passthru backend
we reject and report the commands if opcode is not handled.
Add an helper and use it in block device backend to keep the code
and error message uniform.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/nvme/target/core.c')
-rw-r--r-- | drivers/nvme/target/core.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index 95b58d4b1af2..35ad96261b8f 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -82,6 +82,15 @@ inline u16 errno_to_nvme_status(struct nvmet_req *req, int errno) return status; } +u16 nvmet_report_invalid_opcode(struct nvmet_req *req) +{ + pr_debug("unhandled cmd %d on qid %d\n", req->cmd->common.opcode, + req->sq->qid); + + req->error_loc = offsetof(struct nvme_common_command, opcode); + return NVME_SC_INVALID_OPCODE | NVME_SC_DNR; +} + static struct nvmet_subsys *nvmet_find_get_subsys(struct nvmet_port *port, const char *subsysnqn); |