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 v1 1/1] nvme-tcp: fix wrong status on deferred digest error
Date: Wed, 26 Aug 2026 09:30:00 +0800 [thread overview]
Message-ID: <1.nvme-tcp-req-status.v1.git.liuxixin@kylinos.cn> (raw)
In-Reply-To: <cover.nvme-tcp-req-status.v1.git.liuxixin@kylinos.cn>
A C2HData digest error stores a host status code in req status. Without
DATA_SUCCESS the request is completed later from the rsp path, which
passed that value straight into complete and could report the wrong
status code.
Keep req status as a host status code. On the rsp path, shift left when
a host error was already stored, otherwise use the completion status
field.
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 | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
--- a/drivers/nvme/host/tcp.c 2026-08-26 09:24:50.988099281 +0800
+++ b/drivers/nvme/host/tcp.c 2026-08-26 09:25:12.474510519 +0800
@@ -73,7 +73,7 @@
u32 h2cdata_left;
u32 h2cdata_offset;
u16 ttag;
- __le16 status;
+ u16 status;
struct list_head entry;
struct llist_node lentry;
__le32 ddgst;
@@ -617,6 +617,7 @@
{
struct nvme_tcp_request *req;
struct request *rq;
+ __le16 status;
rq = nvme_find_rq(nvme_tcp_tagset(queue), cqe->command_id);
if (!rq) {
@@ -628,10 +629,12 @@
}
req = blk_mq_rq_to_pdu(rq);
- if (req->status == cpu_to_le16(NVME_SC_SUCCESS))
- req->status = cqe->status;
+ if (req->status != NVME_SC_SUCCESS)
+ status = cpu_to_le16(req->status << 1);
+ else
+ status = cqe->status;
- if (!nvme_try_complete_req(rq, req->status, cqe->result))
+ if (!nvme_try_complete_req(rq, status, cqe->result))
nvme_complete_rq(rq);
queue->nr_cqe++;
@@ -961,8 +964,7 @@
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));
+ nvme_tcp_end_request(rq, req->status);
queue->nr_cqe++;
}
nvme_tcp_init_recv_ctx(queue);
@@ -996,7 +998,7 @@
pdu->command_id);
struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq);
- req->status = cpu_to_le16(NVME_SC_DATA_XFER_ERROR);
+ req->status = NVME_SC_DATA_XFER_ERROR;
dev_err(queue->ctrl->ctrl.device,
"data digest error: recv %#x expected %#x\n",
@@ -1009,7 +1011,7 @@
pdu->command_id);
struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq);
- nvme_tcp_end_request(rq, le16_to_cpu(req->status));
+ nvme_tcp_end_request(rq, req->status);
queue->nr_cqe++;
}
@@ -2733,7 +2735,7 @@
return ret;
req->state = NVME_TCP_SEND_CMD_PDU;
- req->status = cpu_to_le16(NVME_SC_SUCCESS);
+ req->status = NVME_SC_SUCCESS;
req->offset = 0;
req->data_sent = 0;
req->pdu_len = 0;
--
2.53.0
next prev parent reply other threads:[~2026-08-26 2:40 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 ` Xixin Liu [this message]
2026-08-26 9:39 ` [PATCH v1 1/1] " 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 ` [PATCH v3 1/1] " Xixin Liu
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.v1.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