From: Xixin Liu <liuxixin@kylinos.cn>
To: linux-nvme@lists.infradead.org
Cc: kbusch@kernel.org, axboe@kernel.dk, hch@lst.de, sagi@grimberg.me,
hare@suse.de, dwagner@suse.de, linux-kernel@vger.kernel.org,
liuxixin@kylinos.cn
Subject: [PATCH v3 1/1] nvme-tcp: fix wrong status on deferred digest error
Date: Mon, 31 Aug 2026 10:10:00 +0800 [thread overview]
Message-ID: <1.nvme-tcp-req-status.v3.git.liuxixin@kylinos.cn> (raw)
In-Reply-To: <cover.nvme-tcp-req-status.v3.git.liuxixin@kylinos.cn>
A C2HData digest error stores a host status code in req->status. Without
DATA_SUCCESS completion goes through the rsp path, which passed that host
value straight into complete as CQE Status wire encoding.
On the rsp path, pick host status from the CQE status field or from the
stored deferred error, then complete through nvme_tcp_end_request with
the CQE result.
Fixes: 1ba2e507f55c ("nvme-tcp: Do not reset transport on data digest errors")
Signed-off-by: Xixin Liu <liuxixin@kylinos.cn>
---
drivers/nvme/host/tcp.c | 36 +++++++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 15 deletions(-)
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -612,11 +612,19 @@ static void nvme_tcp_error_recovery(struct nvme_ctrl *ctrl)
queue_work(nvme_reset_wq, &to_tcp_ctrl(ctrl)->err_work);
}
+static inline void nvme_tcp_end_request(struct request *rq, u16 status,
+ union nvme_result result)
+{
+ if (!nvme_try_complete_req(rq, cpu_to_le16(status << 1), result))
+ nvme_complete_rq(rq);
+}
+
static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue,
struct nvme_completion *cqe)
{
struct nvme_tcp_request *req;
struct request *rq;
+ u16 status;
rq = nvme_find_rq(nvme_tcp_tagset(queue), cqe->command_id);
if (!rq) {
@@ -629,10 +637,11 @@ static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue,
req = blk_mq_rq_to_pdu(rq);
if (req->status == cpu_to_le16(NVME_SC_SUCCESS))
- req->status = cqe->status;
+ status = le16_to_cpu(cqe->status) >> 1;
+ else
+ status = le16_to_cpu(req->status);
- if (!nvme_try_complete_req(rq, req->status, cqe->result))
- nvme_complete_rq(rq);
+ nvme_tcp_end_request(rq, status, cqe->result);
queue->nr_cqe++;
return 0;
@@ -893,14 +902,6 @@ static int nvme_tcp_recv_pdu(struct nvme_tcp_queue *queue, struct sk_buff *skb,
return -EINVAL;
}
-static inline void nvme_tcp_end_request(struct request *rq, u16 status)
-{
- union nvme_result res = {};
-
- if (!nvme_try_complete_req(rq, cpu_to_le16(status << 1), res))
- nvme_complete_rq(rq);
-}
-
static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb,
unsigned int *offset, size_t *len)
{
@@ -961,8 +962,9 @@ static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb,
queue->ddgst_remaining = NVME_TCP_DIGEST_LENGTH;
} else {
if (pdu->hdr.flags & NVME_TCP_F_DATA_SUCCESS) {
- nvme_tcp_end_request(rq,
- le16_to_cpu(req->status));
+ union nvme_result res = {};
+
+ nvme_tcp_end_request(rq, le16_to_cpu(req->status), res);
queue->nr_cqe++;
}
nvme_tcp_init_recv_ctx(queue);
@@ -1009,7 +1011,9 @@ static int nvme_tcp_recv_ddgst(struct nvme_tcp_queue *queue,
pdu->command_id);
struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq);
- nvme_tcp_end_request(rq, le16_to_cpu(req->status));
+ union nvme_result res = {};
+
+ nvme_tcp_end_request(rq, le16_to_cpu(req->status), res);
queue->nr_cqe++;
}
@@ -1124,8 +1128,10 @@ static void nvme_tcp_fail_request(struct nvme_tcp_request *req)
nvme_complete_async_event(&req->queue->ctrl->ctrl,
cpu_to_le16(NVME_SC_HOST_PATH_ERROR), &res);
} else {
+ union nvme_result res = {};
+
nvme_tcp_end_request(blk_mq_rq_from_pdu(req),
- NVME_SC_HOST_PATH_ERROR);
+ NVME_SC_HOST_PATH_ERROR, res);
}
}
--
2.53.0
prev parent reply other threads:[~2026-08-31 2:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 2:15 [PATCH v1 0/1] nvme-tcp: fix wrong status on deferred digest error Xixin Liu
2026-08-26 1:30 ` [PATCH v1 1/1] " Xixin Liu
2026-08-26 9:39 ` Hannes Reinecke
2026-08-27 2:40 ` [PATCH v1 0/1] " Xixin Liu
2026-08-27 1:05 ` [PATCH v2 " Xixin Liu
2026-08-27 1:05 ` [PATCH v2 1/1] " Xixin Liu
2026-08-30 21:43 ` Sagi Grimberg
2026-08-31 2:15 ` Xixin Liu
2026-08-31 2:05 ` [PATCH v3 0/1] " Xixin Liu
2026-08-31 2:10 ` Xixin Liu [this message]
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=1.nvme-tcp-req-status.v3.git.liuxixin@kylinos.cn \
--to=liuxixin@kylinos.cn \
--cc=axboe@kernel.dk \
--cc=dwagner@suse.de \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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