* [PATCH 2/5] nvme: remove redundant status mask
2024-01-31 16:43 [PATCH 1/5] nvme: return string as char *, not unsigned char * Caleb Sander
@ 2024-01-31 16:43 ` Caleb Sander
2024-01-31 17:33 ` Christoph Hellwig
2024-01-31 20:54 ` Sagi Grimberg
2024-01-31 16:43 ` [PATCH 3/5] nvme: take const cmd pointer in read-only helpers Caleb Sander
` (6 subsequent siblings)
7 siblings, 2 replies; 17+ messages in thread
From: Caleb Sander @ 2024-01-31 16:43 UTC (permalink / raw)
To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
James Smart, linux-nvme
Cc: Caleb Sander
In nvme_get_error_status_str(), the status code is already masked
with 0x7ff at the beginning of the function.
Don't bother masking it again when indexing nvme_statuses.
Signed-off-by: Caleb Sander <csander@purestorage.com>
---
drivers/nvme/host/constants.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/host/constants.c b/drivers/nvme/host/constants.c
index 8791283ec6ad..6f2ebb5fcdb0 100644
--- a/drivers/nvme/host/constants.c
+++ b/drivers/nvme/host/constants.c
@@ -173,11 +173,11 @@ static const char * const nvme_statuses[] = {
const char *nvme_get_error_status_str(u16 status)
{
status &= 0x7ff;
if (status < ARRAY_SIZE(nvme_statuses) && nvme_statuses[status])
- return nvme_statuses[status & 0x7ff];
+ return nvme_statuses[status];
return "Unknown";
}
const char *nvme_get_opcode_str(u8 opcode)
{
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH 2/5] nvme: remove redundant status mask
2024-01-31 16:43 ` [PATCH 2/5] nvme: remove redundant status mask Caleb Sander
@ 2024-01-31 17:33 ` Christoph Hellwig
2024-01-31 20:54 ` Sagi Grimberg
1 sibling, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2024-01-31 17:33 UTC (permalink / raw)
To: Caleb Sander
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
James Smart, linux-nvme
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 2/5] nvme: remove redundant status mask
2024-01-31 16:43 ` [PATCH 2/5] nvme: remove redundant status mask Caleb Sander
2024-01-31 17:33 ` Christoph Hellwig
@ 2024-01-31 20:54 ` Sagi Grimberg
1 sibling, 0 replies; 17+ messages in thread
From: Sagi Grimberg @ 2024-01-31 20:54 UTC (permalink / raw)
To: Caleb Sander, Keith Busch, Jens Axboe, Christoph Hellwig,
James Smart, linux-nvme
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 3/5] nvme: take const cmd pointer in read-only helpers
2024-01-31 16:43 [PATCH 1/5] nvme: return string as char *, not unsigned char * Caleb Sander
2024-01-31 16:43 ` [PATCH 2/5] nvme: remove redundant status mask Caleb Sander
@ 2024-01-31 16:43 ` Caleb Sander
2024-01-31 17:33 ` Christoph Hellwig
2024-01-31 20:55 ` Sagi Grimberg
2024-01-31 16:43 ` [PATCH 4/5] nvme: split out fabrics version of nvme_opcode_str() Caleb Sander
` (5 subsequent siblings)
7 siblings, 2 replies; 17+ messages in thread
From: Caleb Sander @ 2024-01-31 16:43 UTC (permalink / raw)
To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
James Smart, linux-nvme
Cc: Caleb Sander
nvme_is_fabrics() and nvme_is_write() only read struct nvme_command,
so take it by const pointer. This allows callers to pass a const pointer
and communicates that these functions don't modify the command.
Signed-off-by: Caleb Sander <csander@purestorage.com>
---
include/linux/nvme.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 68eff8c86ce3..bc605ec4a3fd 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -1810,11 +1810,11 @@ struct nvme_command {
struct nvme_dbbuf dbbuf;
struct nvme_directive_cmd directive;
};
};
-static inline bool nvme_is_fabrics(struct nvme_command *cmd)
+static inline bool nvme_is_fabrics(const struct nvme_command *cmd)
{
return cmd->common.opcode == nvme_fabrics_command;
}
struct nvme_error_slot {
@@ -1829,11 +1829,11 @@ struct nvme_error_slot {
__u8 resv[3];
__le64 cs;
__u8 resv2[24];
};
-static inline bool nvme_is_write(struct nvme_command *cmd)
+static inline bool nvme_is_write(const struct nvme_command *cmd)
{
/*
* What a mess...
*
* Why can't we simply have a Fabrics In and Fabrics out command?
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH 3/5] nvme: take const cmd pointer in read-only helpers
2024-01-31 16:43 ` [PATCH 3/5] nvme: take const cmd pointer in read-only helpers Caleb Sander
@ 2024-01-31 17:33 ` Christoph Hellwig
2024-01-31 20:55 ` Sagi Grimberg
1 sibling, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2024-01-31 17:33 UTC (permalink / raw)
To: Caleb Sander
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
James Smart, linux-nvme
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/5] nvme: take const cmd pointer in read-only helpers
2024-01-31 16:43 ` [PATCH 3/5] nvme: take const cmd pointer in read-only helpers Caleb Sander
2024-01-31 17:33 ` Christoph Hellwig
@ 2024-01-31 20:55 ` Sagi Grimberg
1 sibling, 0 replies; 17+ messages in thread
From: Sagi Grimberg @ 2024-01-31 20:55 UTC (permalink / raw)
To: Caleb Sander, Keith Busch, Jens Axboe, Christoph Hellwig,
James Smart, linux-nvme
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 4/5] nvme: split out fabrics version of nvme_opcode_str()
2024-01-31 16:43 [PATCH 1/5] nvme: return string as char *, not unsigned char * Caleb Sander
2024-01-31 16:43 ` [PATCH 2/5] nvme: remove redundant status mask Caleb Sander
2024-01-31 16:43 ` [PATCH 3/5] nvme: take const cmd pointer in read-only helpers Caleb Sander
@ 2024-01-31 16:43 ` Caleb Sander
2024-01-31 17:34 ` Christoph Hellwig
2024-01-31 20:56 ` Sagi Grimberg
2024-01-31 16:43 ` [PATCH 5/5] nvme-fc: log human-readable opcode on timeout Caleb Sander
` (4 subsequent siblings)
7 siblings, 2 replies; 17+ messages in thread
From: Caleb Sander @ 2024-01-31 16:43 UTC (permalink / raw)
To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
James Smart, linux-nvme
Cc: Caleb Sander
nvme_opcode_str() currently supports admin, IO, and fabrics commands.
However, fabrics commands aren't allowed for the pci transport.
Currently the pci caller passes 0 as the fctype,
which means any fabrics command would be displayed as "Property Set".
Move fabrics command support into a function nvme_fabrics_opcode_str()
and remove the fctype argument to nvme_opcode_str().
This way, a fabrics command will display as "Unknown" for pci.
Convert the rdma and tcp transports to use nvme_fabrics_opcode_str().
Signed-off-by: Caleb Sander <csander@purestorage.com>
---
drivers/nvme/host/nvme.h | 13 ++++++++++---
drivers/nvme/host/pci.c | 2 +-
drivers/nvme/host/rdma.c | 7 +++----
drivers/nvme/host/tcp.c | 6 +++---
4 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 403df30fc3cc..a9dcd3ffcc18 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -1147,13 +1147,20 @@ static inline const char *nvme_get_fabrics_opcode_str(u8 opcode)
{
return "Fabrics Cmd";
}
#endif /* CONFIG_NVME_VERBOSE_ERRORS */
-static inline const char *nvme_opcode_str(int qid, u8 opcode, u8 fctype)
+static inline const char *nvme_opcode_str(int qid, u8 opcode)
{
- if (opcode == nvme_fabrics_command)
- return nvme_get_fabrics_opcode_str(fctype);
return qid ? nvme_get_opcode_str(opcode) :
nvme_get_admin_opcode_str(opcode);
}
+
+static inline const char *nvme_fabrics_opcode_str(
+ int qid, const struct nvme_command *cmd)
+{
+ if (nvme_is_fabrics(cmd))
+ return nvme_get_fabrics_opcode_str(cmd->fabrics.fctype);
+
+ return nvme_opcode_str(qid, cmd->common.opcode);
+}
#endif /* _NVME_H */
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 25eb72779541..e6267a6aa380 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1347,11 +1347,11 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req)
opcode = nvme_req(req)->cmd->common.opcode;
if (!nvmeq->qid || iod->aborted) {
dev_warn(dev->ctrl.device,
"I/O tag %d (%04x) opcode %#x (%s) QID %d timeout, reset controller\n",
req->tag, nvme_cid(req), opcode,
- nvme_opcode_str(nvmeq->qid, opcode, 0), nvmeq->qid);
+ nvme_opcode_str(nvmeq->qid, opcode), nvmeq->qid);
nvme_req(req)->flags |= NVME_REQ_CANCELLED;
goto disable;
}
if (atomic_dec_return(&dev->ctrl.abort_limit) < 0) {
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 3f393ee20281..6adf2c19a712 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1949,18 +1949,17 @@ static void nvme_rdma_complete_timed_out(struct request *rq)
static enum blk_eh_timer_return nvme_rdma_timeout(struct request *rq)
{
struct nvme_rdma_request *req = blk_mq_rq_to_pdu(rq);
struct nvme_rdma_queue *queue = req->queue;
struct nvme_rdma_ctrl *ctrl = queue->ctrl;
- u8 opcode = req->req.cmd->common.opcode;
- u8 fctype = req->req.cmd->fabrics.fctype;
+ struct nvme_command *cmd = req->req.cmd;
int qid = nvme_rdma_queue_idx(queue);
dev_warn(ctrl->ctrl.device,
"I/O tag %d (%04x) opcode %#x (%s) QID %d timeout\n",
- rq->tag, nvme_cid(rq), opcode,
- nvme_opcode_str(qid, opcode, fctype), qid);
+ rq->tag, nvme_cid(rq), cmd->common.opcode,
+ nvme_fabrics_opcode_str(qid, cmd), qid);
if (nvme_ctrl_state(&ctrl->ctrl) != NVME_CTRL_LIVE) {
/*
* If we are resetting, connecting or deleting we should
* complete immediately because we may block controller
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 4393cf244025..9f8dea2e2c7d 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -2426,17 +2426,17 @@ static void nvme_tcp_complete_timed_out(struct request *rq)
static enum blk_eh_timer_return nvme_tcp_timeout(struct request *rq)
{
struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq);
struct nvme_ctrl *ctrl = &req->queue->ctrl->ctrl;
struct nvme_tcp_cmd_pdu *pdu = nvme_tcp_req_cmd_pdu(req);
- u8 opc = pdu->cmd.common.opcode, fctype = pdu->cmd.fabrics.fctype;
+ struct nvme_command *cmd = &pdu->cmd;
int qid = nvme_tcp_queue_id(req->queue);
dev_warn(ctrl->device,
"I/O tag %d (%04x) type %d opcode %#x (%s) QID %d timeout\n",
- rq->tag, nvme_cid(rq), pdu->hdr.type, opc,
- nvme_opcode_str(qid, opc, fctype), qid);
+ rq->tag, nvme_cid(rq), pdu->hdr.type, cmd->common.opcode,
+ nvme_fabrics_opcode_str(qid, cmd), qid);
if (nvme_ctrl_state(ctrl) != NVME_CTRL_LIVE) {
/*
* If we are resetting, connecting or deleting we should
* complete immediately because we may block controller
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH 4/5] nvme: split out fabrics version of nvme_opcode_str()
2024-01-31 16:43 ` [PATCH 4/5] nvme: split out fabrics version of nvme_opcode_str() Caleb Sander
@ 2024-01-31 17:34 ` Christoph Hellwig
2024-01-31 20:56 ` Sagi Grimberg
1 sibling, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2024-01-31 17:34 UTC (permalink / raw)
To: Caleb Sander
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
James Smart, linux-nvme
> +static inline const char *nvme_fabrics_opcode_str(
> + int qid, const struct nvme_command *cmd)
Nit: We use two-tab (or aligned to opening brace) alignment for line
continuations, and the qid still fits onto the first line:
static inline const char *nvme_fabrics_opcode_str(int qid,
const struct nvme_command *cmd)
Otherwise looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4/5] nvme: split out fabrics version of nvme_opcode_str()
2024-01-31 16:43 ` [PATCH 4/5] nvme: split out fabrics version of nvme_opcode_str() Caleb Sander
2024-01-31 17:34 ` Christoph Hellwig
@ 2024-01-31 20:56 ` Sagi Grimberg
1 sibling, 0 replies; 17+ messages in thread
From: Sagi Grimberg @ 2024-01-31 20:56 UTC (permalink / raw)
To: Caleb Sander, Keith Busch, Jens Axboe, Christoph Hellwig,
James Smart, linux-nvme
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 5/5] nvme-fc: log human-readable opcode on timeout
2024-01-31 16:43 [PATCH 1/5] nvme: return string as char *, not unsigned char * Caleb Sander
` (2 preceding siblings ...)
2024-01-31 16:43 ` [PATCH 4/5] nvme: split out fabrics version of nvme_opcode_str() Caleb Sander
@ 2024-01-31 16:43 ` Caleb Sander
2024-01-31 17:34 ` Christoph Hellwig
2024-01-31 20:57 ` Sagi Grimberg
2024-01-31 17:33 ` [PATCH 1/5] nvme: return string as char *, not unsigned char * Christoph Hellwig
` (3 subsequent siblings)
7 siblings, 2 replies; 17+ messages in thread
From: Caleb Sander @ 2024-01-31 16:43 UTC (permalink / raw)
To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
James Smart, linux-nvme
Cc: Caleb Sander
The fc transport logs the opcode and fctype on command timeout.
This is sufficient information to identify the command issued,
but not very human-readable. Use the nvme_fabrics_opcode_str()
helper to also log the name of the command, as rdma and tcp already do.
Signed-off-by: Caleb Sander <csander@purestorage.com>
---
drivers/nvme/host/fc.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index e2308119f8f0..63a2e2839a78 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -2572,22 +2572,24 @@ nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg)
static enum blk_eh_timer_return nvme_fc_timeout(struct request *rq)
{
struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(rq);
struct nvme_fc_ctrl *ctrl = op->ctrl;
+ u16 qnum = op->queue->qnum;
struct nvme_fc_cmd_iu *cmdiu = &op->cmd_iu;
struct nvme_command *sqe = &cmdiu->sqe;
/*
* Attempt to abort the offending command. Command completion
* will detect the aborted io and will fail the connection.
*/
dev_info(ctrl->ctrl.device,
- "NVME-FC{%d.%d}: io timeout: opcode %d fctype %d w10/11: "
+ "NVME-FC{%d.%d}: io timeout: opcode %d fctype %d (%s) w10/11: "
"x%08x/x%08x\n",
- ctrl->cnum, op->queue->qnum, sqe->common.opcode,
- sqe->connect.fctype, sqe->common.cdw10, sqe->common.cdw11);
+ ctrl->cnum, qnum, sqe->common.opcode, sqe->fabrics.fctype,
+ nvme_fabrics_opcode_str(qnum, sqe),
+ sqe->common.cdw10, sqe->common.cdw11);
if (__nvme_fc_abort_op(ctrl, op))
nvme_fc_error_recovery(ctrl, "io timeout abort failed");
/*
* the io abort has been initiated. Have the reset timer
--
2.25.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH 5/5] nvme-fc: log human-readable opcode on timeout
2024-01-31 16:43 ` [PATCH 5/5] nvme-fc: log human-readable opcode on timeout Caleb Sander
@ 2024-01-31 17:34 ` Christoph Hellwig
2024-01-31 20:57 ` Sagi Grimberg
1 sibling, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2024-01-31 17:34 UTC (permalink / raw)
To: Caleb Sander
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
James Smart, linux-nvme
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 5/5] nvme-fc: log human-readable opcode on timeout
2024-01-31 16:43 ` [PATCH 5/5] nvme-fc: log human-readable opcode on timeout Caleb Sander
2024-01-31 17:34 ` Christoph Hellwig
@ 2024-01-31 20:57 ` Sagi Grimberg
1 sibling, 0 replies; 17+ messages in thread
From: Sagi Grimberg @ 2024-01-31 20:57 UTC (permalink / raw)
To: Caleb Sander, Keith Busch, Jens Axboe, Christoph Hellwig,
James Smart, linux-nvme
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/5] nvme: return string as char *, not unsigned char *
2024-01-31 16:43 [PATCH 1/5] nvme: return string as char *, not unsigned char * Caleb Sander
` (3 preceding siblings ...)
2024-01-31 16:43 ` [PATCH 5/5] nvme-fc: log human-readable opcode on timeout Caleb Sander
@ 2024-01-31 17:33 ` Christoph Hellwig
2024-01-31 20:54 ` Sagi Grimberg
` (2 subsequent siblings)
7 siblings, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2024-01-31 17:33 UTC (permalink / raw)
To: Caleb Sander
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
James Smart, linux-nvme
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH 1/5] nvme: return string as char *, not unsigned char *
2024-01-31 16:43 [PATCH 1/5] nvme: return string as char *, not unsigned char * Caleb Sander
` (4 preceding siblings ...)
2024-01-31 17:33 ` [PATCH 1/5] nvme: return string as char *, not unsigned char * Christoph Hellwig
@ 2024-01-31 20:54 ` Sagi Grimberg
2024-01-31 23:05 ` Chaitanya Kulkarni
2024-02-01 0:29 ` Keith Busch
7 siblings, 0 replies; 17+ messages in thread
From: Sagi Grimberg @ 2024-01-31 20:54 UTC (permalink / raw)
To: Caleb Sander, Keith Busch, Jens Axboe, Christoph Hellwig,
James Smart, linux-nvme
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH 1/5] nvme: return string as char *, not unsigned char *
2024-01-31 16:43 [PATCH 1/5] nvme: return string as char *, not unsigned char * Caleb Sander
` (5 preceding siblings ...)
2024-01-31 20:54 ` Sagi Grimberg
@ 2024-01-31 23:05 ` Chaitanya Kulkarni
2024-02-01 0:29 ` Keith Busch
7 siblings, 0 replies; 17+ messages in thread
From: Chaitanya Kulkarni @ 2024-01-31 23:05 UTC (permalink / raw)
To: Caleb Sander
Cc: Keith Busch, Sagi Grimberg, Christoph Hellwig, Jens Axboe,
linux-nvme@lists.infradead.org, James Smart
On 1/31/24 08:43, Caleb Sander wrote:
> The functions in drivers/nvme/host/constants.c returning human-readable
> status and opcode strings currently use type "const unsigned char *".
> Typically string constants use type "const char *",
> so remove "unsigned" from the return types.
> This is a purely cosmetic change to clarify that the functions
> return text strings instead of an array of bytes, for example.
>
> Signed-off-by: Caleb Sander <csander@purestorage.com>
> ---
>
looks good, for the entire series :-
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
-ck
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH 1/5] nvme: return string as char *, not unsigned char *
2024-01-31 16:43 [PATCH 1/5] nvme: return string as char *, not unsigned char * Caleb Sander
` (6 preceding siblings ...)
2024-01-31 23:05 ` Chaitanya Kulkarni
@ 2024-02-01 0:29 ` Keith Busch
7 siblings, 0 replies; 17+ messages in thread
From: Keith Busch @ 2024-02-01 0:29 UTC (permalink / raw)
To: Caleb Sander
Cc: Jens Axboe, Christoph Hellwig, Sagi Grimberg, James Smart,
linux-nvme
Thanks, applied to nvme-6.8.
^ permalink raw reply [flat|nested] 17+ messages in thread