All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Keith Busch <keith.busch@intel.com>,
	Sagi Grimberg <sagi@grimberg.me>,
	linux-nvme@lists.infradead.org, linux-block@vger.kernel.org,
	Steve Blightman <steve.blightman@oracle.com>,
	Oliver Smith-Denny <osmithde@cisco.com>
Subject: [PATCH 17/17] nvme-tcp: support C2HData with SUCCESS flag
Date: Wed, 13 Mar 2019 18:55:10 +0100	[thread overview]
Message-ID: <20190313175510.20725-18-hch@lst.de> (raw)
In-Reply-To: <20190313175510.20725-1-hch@lst.de>

From: Sagi Grimberg <sagi@grimberg.me>

A C2HData PDU with the SUCCESS flag set indicates that the I/O was
completed by the controller successfully and means that a subsequent
completion response capsule PDU will be ommitted.

If we see this flag, fisrt we check that LAST_PDU flag is set as well,
and then we complete the request when the data transfer (and data digest
verification if its on) is done.

While we're at it, reuse a bit of code with nvme_fail_request.

Reported-by: Steve Blightman <steve.blightman@oracle.com>
Suggested-by: Oliver Smith-Denny <osmithde@cisco.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Oliver Smith-Denny <osmithde@cisco.com>
Tested-by: Oliver Smith-Denny <osmithde@cisco.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/tcp.c | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 208ee518af65..e7e08889865e 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -463,6 +463,15 @@ static int nvme_tcp_handle_c2h_data(struct nvme_tcp_queue *queue,
 
 	queue->data_remaining = le32_to_cpu(pdu->data_length);
 
+	if (pdu->hdr.flags & NVME_TCP_F_DATA_SUCCESS &&
+	    unlikely(!(pdu->hdr.flags & NVME_TCP_F_DATA_LAST))) {
+		dev_err(queue->ctrl->ctrl.device,
+			"queue %d tag %#x SUCCESS set but not last PDU\n",
+			nvme_tcp_queue_id(queue), rq->tag);
+		nvme_tcp_error_recovery(&queue->ctrl->ctrl);
+		return -EPROTO;
+	}
+
 	return 0;
 
 }
@@ -618,6 +627,14 @@ static int nvme_tcp_recv_pdu(struct nvme_tcp_queue *queue, struct sk_buff *skb,
 	return ret;
 }
 
+static inline void nvme_tcp_end_request(struct request *rq, __le16 status)
+{
+	union nvme_result res = {};
+
+	nvme_end_request(rq, cpu_to_le16(status << 1), res);
+}
+
+
 static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb,
 			      unsigned int *offset, size_t *len)
 {
@@ -685,6 +702,8 @@ static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb,
 			nvme_tcp_ddgst_final(queue->rcv_hash, &queue->exp_ddgst);
 			queue->ddgst_remaining = NVME_TCP_DIGEST_LENGTH;
 		} else {
+			if (pdu->hdr.flags & NVME_TCP_F_DATA_SUCCESS)
+				nvme_tcp_end_request(rq, NVME_SC_SUCCESS);
 			nvme_tcp_init_recv_ctx(queue);
 		}
 	}
@@ -695,6 +714,7 @@ static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb,
 static int nvme_tcp_recv_ddgst(struct nvme_tcp_queue *queue,
 		struct sk_buff *skb, unsigned int *offset, size_t *len)
 {
+	struct nvme_tcp_data_pdu *pdu = (void *)queue->pdu;
 	char *ddgst = (char *)&queue->recv_ddgst;
 	size_t recv_len = min_t(size_t, *len, queue->ddgst_remaining);
 	off_t off = NVME_TCP_DIGEST_LENGTH - queue->ddgst_remaining;
@@ -718,6 +738,13 @@ static int nvme_tcp_recv_ddgst(struct nvme_tcp_queue *queue,
 		return -EIO;
 	}
 
+	if (pdu->hdr.flags & NVME_TCP_F_DATA_SUCCESS) {
+		struct request *rq = blk_mq_tag_to_rq(nvme_tcp_tagset(queue),
+						pdu->command_id);
+
+		nvme_tcp_end_request(rq, NVME_SC_SUCCESS);
+	}
+
 	nvme_tcp_init_recv_ctx(queue);
 	return 0;
 }
@@ -815,10 +842,7 @@ static inline void nvme_tcp_done_send_req(struct nvme_tcp_queue *queue)
 
 static void nvme_tcp_fail_request(struct nvme_tcp_request *req)
 {
-	union nvme_result res = {};
-
-	nvme_end_request(blk_mq_rq_from_pdu(req),
-		cpu_to_le16(NVME_SC_DATA_XFER_ERROR), res);
+	nvme_tcp_end_request(blk_mq_rq_from_pdu(req), NVME_SC_DATA_XFER_ERROR);
 }
 
 static int nvme_tcp_try_send_data(struct nvme_tcp_request *req)
-- 
2.20.1


WARNING: multiple messages have this Message-ID (diff)
From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH 17/17] nvme-tcp: support C2HData with SUCCESS flag
Date: Wed, 13 Mar 2019 18:55:10 +0100	[thread overview]
Message-ID: <20190313175510.20725-18-hch@lst.de> (raw)
In-Reply-To: <20190313175510.20725-1-hch@lst.de>

From: Sagi Grimberg <sagi@grimberg.me>

A C2HData PDU with the SUCCESS flag set indicates that the I/O was
completed by the controller successfully and means that a subsequent
completion response capsule PDU will be ommitted.

If we see this flag, fisrt we check that LAST_PDU flag is set as well,
and then we complete the request when the data transfer (and data digest
verification if its on) is done.

While we're at it, reuse a bit of code with nvme_fail_request.

Reported-by: Steve Blightman <steve.blightman at oracle.com>
Suggested-by: Oliver Smith-Denny <osmithde at cisco.com>
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
Reviewed-by: Oliver Smith-Denny <osmithde at cisco.com>
Tested-by: Oliver Smith-Denny <osmithde at cisco.com>
Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/tcp.c | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 208ee518af65..e7e08889865e 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -463,6 +463,15 @@ static int nvme_tcp_handle_c2h_data(struct nvme_tcp_queue *queue,
 
 	queue->data_remaining = le32_to_cpu(pdu->data_length);
 
+	if (pdu->hdr.flags & NVME_TCP_F_DATA_SUCCESS &&
+	    unlikely(!(pdu->hdr.flags & NVME_TCP_F_DATA_LAST))) {
+		dev_err(queue->ctrl->ctrl.device,
+			"queue %d tag %#x SUCCESS set but not last PDU\n",
+			nvme_tcp_queue_id(queue), rq->tag);
+		nvme_tcp_error_recovery(&queue->ctrl->ctrl);
+		return -EPROTO;
+	}
+
 	return 0;
 
 }
@@ -618,6 +627,14 @@ static int nvme_tcp_recv_pdu(struct nvme_tcp_queue *queue, struct sk_buff *skb,
 	return ret;
 }
 
+static inline void nvme_tcp_end_request(struct request *rq, __le16 status)
+{
+	union nvme_result res = {};
+
+	nvme_end_request(rq, cpu_to_le16(status << 1), res);
+}
+
+
 static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb,
 			      unsigned int *offset, size_t *len)
 {
@@ -685,6 +702,8 @@ static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb,
 			nvme_tcp_ddgst_final(queue->rcv_hash, &queue->exp_ddgst);
 			queue->ddgst_remaining = NVME_TCP_DIGEST_LENGTH;
 		} else {
+			if (pdu->hdr.flags & NVME_TCP_F_DATA_SUCCESS)
+				nvme_tcp_end_request(rq, NVME_SC_SUCCESS);
 			nvme_tcp_init_recv_ctx(queue);
 		}
 	}
@@ -695,6 +714,7 @@ static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb,
 static int nvme_tcp_recv_ddgst(struct nvme_tcp_queue *queue,
 		struct sk_buff *skb, unsigned int *offset, size_t *len)
 {
+	struct nvme_tcp_data_pdu *pdu = (void *)queue->pdu;
 	char *ddgst = (char *)&queue->recv_ddgst;
 	size_t recv_len = min_t(size_t, *len, queue->ddgst_remaining);
 	off_t off = NVME_TCP_DIGEST_LENGTH - queue->ddgst_remaining;
@@ -718,6 +738,13 @@ static int nvme_tcp_recv_ddgst(struct nvme_tcp_queue *queue,
 		return -EIO;
 	}
 
+	if (pdu->hdr.flags & NVME_TCP_F_DATA_SUCCESS) {
+		struct request *rq = blk_mq_tag_to_rq(nvme_tcp_tagset(queue),
+						pdu->command_id);
+
+		nvme_tcp_end_request(rq, NVME_SC_SUCCESS);
+	}
+
 	nvme_tcp_init_recv_ctx(queue);
 	return 0;
 }
@@ -815,10 +842,7 @@ static inline void nvme_tcp_done_send_req(struct nvme_tcp_queue *queue)
 
 static void nvme_tcp_fail_request(struct nvme_tcp_request *req)
 {
-	union nvme_result res = {};
-
-	nvme_end_request(blk_mq_rq_from_pdu(req),
-		cpu_to_le16(NVME_SC_DATA_XFER_ERROR), res);
+	nvme_tcp_end_request(blk_mq_rq_from_pdu(req), NVME_SC_DATA_XFER_ERROR);
 }
 
 static int nvme_tcp_try_send_data(struct nvme_tcp_request *req)
-- 
2.20.1

  parent reply	other threads:[~2019-03-13 17:56 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13 17:54 [PATCHBOMB] nvme fixes for 5.1 Christoph Hellwig
2019-03-13 17:54 ` Christoph Hellwig
2019-03-13 17:54 ` [PATCH 01/17] nvme: add get-feature to admin cmds tracer Christoph Hellwig
2019-03-13 17:54   ` Christoph Hellwig
2019-03-13 17:54 ` [PATCH 02/17] nvme: don't warn on block content change effects Christoph Hellwig
2019-03-13 17:54   ` Christoph Hellwig
2019-03-13 17:54 ` [PATCH 03/17] nvme-trace: fix cdw10 buffer overrun Christoph Hellwig
2019-03-13 17:54   ` Christoph Hellwig
2019-03-13 17:54 ` [PATCH 04/17] nvme: put ns_head ref if namespace fails allocation Christoph Hellwig
2019-03-13 17:54   ` Christoph Hellwig
2019-03-13 17:54 ` [PATCH 05/17] nvme: update comment to make the code easier to read Christoph Hellwig
2019-03-13 17:54   ` Christoph Hellwig
2019-03-13 17:54 ` [PATCH 06/17] nvme-loop: init nvmet_ctrl fatal_err_work when allocate Christoph Hellwig
2019-03-13 17:54   ` Christoph Hellwig
2019-03-13 17:55 ` [PATCH 07/17] nvme-fc: use nr_phys_segments to determine existence of sgl Christoph Hellwig
2019-03-13 17:55   ` Christoph Hellwig
2019-03-14  9:57   ` Max Gurtovoy
2019-03-14  9:57     ` Max Gurtovoy
2019-03-14 21:43     ` Sagi Grimberg
2019-03-14 21:43       ` Sagi Grimberg
2019-03-13 17:55 ` [PATCH 08/17] nvme-fc: fix numa_node when dev is null Christoph Hellwig
2019-03-13 17:55   ` Christoph Hellwig
2019-03-13 17:55 ` [PATCH 09/17] nvme-fc: reject reconnect if io queue count is reduced to zero Christoph Hellwig
2019-03-13 17:55   ` Christoph Hellwig
2019-03-13 17:55 ` [PATCH 10/17] nvmet-fc: fix issues with targetport assoc_list list walking Christoph Hellwig
2019-03-13 17:55   ` Christoph Hellwig
2019-03-13 18:53   ` James Smart
2019-03-13 18:53     ` James Smart
2019-03-13 18:58     ` Jens Axboe
2019-03-13 18:58       ` Jens Axboe
2019-03-13 17:55 ` [PATCH 11/17] nvmet-fc: bring Disconnect into compliance with FC-NVME spec Christoph Hellwig
2019-03-13 17:55   ` Christoph Hellwig
2019-03-13 17:55 ` [PATCH 12/17] nvme: disable Write Zeroes for qemu controllers Christoph Hellwig
2019-03-13 17:55   ` Christoph Hellwig
2019-03-13 17:55 ` [PATCH 13/17] nvme: remove nvme_ns_config_oncs Christoph Hellwig
2019-03-13 17:55   ` Christoph Hellwig
2019-03-13 17:55 ` [PATCH 14/17] nvme: add proper discard setup for the multipath device Christoph Hellwig
2019-03-13 17:55   ` Christoph Hellwig
2019-03-13 17:55 ` [PATCH 15/17] nvme: add proper write zeroes " Christoph Hellwig
2019-03-13 17:55   ` Christoph Hellwig
2019-03-13 17:55 ` [PATCH 16/17] nvmet: ignore EOPNOTSUPP for discard Christoph Hellwig
2019-03-13 17:55   ` Christoph Hellwig
2019-03-13 17:55 ` Christoph Hellwig [this message]
2019-03-13 17:55   ` [PATCH 17/17] nvme-tcp: support C2HData with SUCCESS flag Christoph Hellwig
2019-03-13 19:12   ` Sagi Grimberg
2019-03-13 19:12     ` Sagi Grimberg
2019-03-13 19:14     ` Sagi Grimberg
2019-03-13 19:14       ` Sagi Grimberg
2019-03-13 18:06 ` [PATCHBOMB] nvme fixes for 5.1 Jens Axboe
2019-03-13 18:06   ` Jens Axboe

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=20190313175510.20725-18-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=keith.busch@intel.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=osmithde@cisco.com \
    --cc=sagi@grimberg.me \
    --cc=steve.blightman@oracle.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.