linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: linux-nvme@lists.infradead.org
Cc: hch@lst.de, Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
	sagi@grimberg.me
Subject: [PATCH V3 05/11] nvmet: add helper to report invalid opcode
Date: Tue,  9 Feb 2021 21:47:56 -0800	[thread overview]
Message-ID: <20210210054802.34269-6-chaitanya.kulkarni@wdc.com> (raw)
In-Reply-To: <20210210054802.34269-1-chaitanya.kulkarni@wdc.com>

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>
---
 drivers/nvme/target/io-cmd-bdev.c | 5 +----
 drivers/nvme/target/nvmet.h       | 9 +++++++++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c
index 23095bdfce06..105ef2b125cf 100644
--- a/drivers/nvme/target/io-cmd-bdev.c
+++ b/drivers/nvme/target/io-cmd-bdev.c
@@ -449,9 +449,6 @@ u16 nvmet_bdev_parse_io_cmd(struct nvmet_req *req)
 		req->execute = nvmet_bdev_execute_write_zeroes;
 		return 0;
 	default:
-		pr_err("unhandled cmd %d on qid %d\n", cmd->common.opcode,
-		       req->sq->qid);
-		req->error_loc = offsetof(struct nvme_common_command, opcode);
-		return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
+		return nvmet_report_invalid_opcode(req);
 	}
 }
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 954b3d8451f5..6b5f1b60cf50 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -613,4 +613,13 @@ static inline sector_t nvmet_lba_to_sect(struct nvmet_ns *ns, __le64 lba)
 	return le64_to_cpu(lba) << (ns->blksize_shift - SECTOR_SHIFT);
 }
 
+static inline 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;
+}
+
 #endif /* _NVMET_H */
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2021-02-10  5:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10  5:47 [PATCH V3 00/11] nvmet: fixes and some cleanups Chaitanya Kulkarni
2021-02-10  5:47 ` [PATCH V3 01/11] nvmet: set status to 0 in case for invalid nsid Chaitanya Kulkarni
2021-02-10  5:47 ` [PATCH V3 02/11] nvmet: return uniform error for invalid ns Chaitanya Kulkarni
2021-02-10  5:47 ` [PATCH V3 03/11] nvmet: make nvmet_find_namespace() req based Chaitanya Kulkarni
2021-02-10  5:47 ` [PATCH V3 04/11] nvmet: remove extra variable in id-ns handler Chaitanya Kulkarni
2021-02-10  5:47 ` Chaitanya Kulkarni [this message]
2021-02-10  8:12   ` [PATCH V3 05/11] nvmet: add helper to report invalid opcode Christoph Hellwig
2021-02-10  5:47 ` [PATCH V3 06/11] nvmet: use invalid cmd opcode helper Chaitanya Kulkarni
2021-02-10  5:47 ` [PATCH V3 07/11] " Chaitanya Kulkarni
2021-02-10  5:47 ` [PATCH V3 08/11] nvmet: use min of device_path and disk len Chaitanya Kulkarni
2021-02-10  8:13   ` Christoph Hellwig
2021-02-10  5:48 ` [PATCH V3 09/11] nvme-loop: rename variable to get rid of the warn Chaitanya Kulkarni
2021-02-10  8:13   ` Christoph Hellwig
2021-02-10  8:18     ` Chaitanya Kulkarni
2021-02-10  8:23       ` Christoph Hellwig
2021-02-10  5:48 ` [PATCH V3 10/11] nvmet: add nvmet_req_subsys() helper Chaitanya Kulkarni
2021-02-10  5:48 ` [PATCH V3 11/11] nvmet: remove else at the end of the function Chaitanya Kulkarni
2021-02-10  8:11 ` [PATCH V3 00/11] nvmet: fixes and some cleanups Christoph Hellwig
2021-02-10  8:52   ` Chaitanya Kulkarni

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=20210210054802.34269-6-chaitanya.kulkarni@wdc.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=hch@lst.de \
    --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;
as well as URLs for NNTP newsgroup(s).