Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3603268pxb; Mon, 30 Aug 2021 06:25:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl6noWNHiKqWFuFYHjYhiByfhrEuBd8lJgSC4MtaBoB3UZT4GctN7vsMjngN9XK6ryedI7 X-Received: by 2002:a92:d2cb:: with SMTP id w11mr16277175ilg.17.1630329907350; Mon, 30 Aug 2021 06:25:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630329907; cv=none; d=google.com; s=arc-20160816; b=C6KXZBab67ZX3MhgAZfw4kciEzA/Ir70sxUH+KuUCANN7WCFwBpWRjPndZDyoNm5H/ /0vgMlAY2ib6DsJaW2PkWGjwZbQVC/i0SsbnERhZToaHG+HQuJYXmOiXka1S5YdYUiO1 SImKCibCa0YeHmMBhELrjT7VUkCg9H9JxjE+5DtgXMI8yACAb26J6z3aOid50tPPUEo+ dFxKgAiecGR+FDy9QEAQj8wqKYCZANcbRb7yvvoEDLqRVHPh8YzrWdgPBVg+zOkn2qUE BIMQ3qBLqeCE2BZ1K0MXIwba5rGzNSpcc3uOVIcn++d5u8zZ/tWBupTVYJ6YxyjcyIyp dMBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=C0QGhhQnnEnbnmqwmodFy3da4bHlaCYyNmG51CR9+u8=; b=Odmrt82oVn5Qv1JOkiSFRObwjGd+96eZWlXc2XV/WQmQUTNgF0SfNAJNhbqF9fGFdM VPlSXH4qBUZxdWIb5i+4xMcn4bmcF8c5TpDx5pIP+mUY/KC+PtyNjuplEQeIxhbvmR/x j/IaAeJ8WmwuA7Xv1Cdn78uXaP82YowY13R2d7hL6bVGSrH8bYby1la97bDR8JBkPtLA JlhFR/n8edIgvOCcPF9FmeeCOu44py3Q6zK+BYBibIp8I6nrhWRR6VappB9dtdSCMgI0 NDxA612I45TvrsEILzbEno03GYkRP+a8tbOGk2wP2ZdF3TTVTSZDgxNQ7qAS9oy7YDWU RGQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="ac/CYvqn"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=nWex+pFq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v11si13893087iol.46.2021.08.30.06.24.55; Mon, 30 Aug 2021 06:25:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="ac/CYvqn"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=nWex+pFq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234032AbhH3NYC (ORCPT + 99 others); Mon, 30 Aug 2021 09:24:02 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:43050 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbhH3NYB (ORCPT ); Mon, 30 Aug 2021 09:24:01 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4B551200A0; Mon, 30 Aug 2021 13:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1630329787; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=C0QGhhQnnEnbnmqwmodFy3da4bHlaCYyNmG51CR9+u8=; b=ac/CYvqnpZOb3ueQReKlyDY8JHlNaio+X1H5IT4jeXLEu94oUIy1szi3EVD5+PGWqPA3hA qmif4eEigiN0NvlMx54CmBAd3Y31bAUucJHQQbBhnHEcVYSlJH6JeLgFLPYm6ddJ2iQBMD t7XdadmaCGnk5+EHEv8V8EwL4iPnDk4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1630329787; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=C0QGhhQnnEnbnmqwmodFy3da4bHlaCYyNmG51CR9+u8=; b=nWex+pFqFZC9S9LefuBJTKt8JtQGuRx6eLeLOa2JKsPPoul3EbMh17nKyIXxdFLY6MISQ+ 2TvLemk186SoEpAw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 13C8EA3B8C; Mon, 30 Aug 2021 13:23:07 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 17828) id 04CE1518DCE5; Mon, 30 Aug 2021 15:23:06 +0200 (CEST) From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Hannes Reinecke , Sagi Grimberg , yi.he@emc.com, Daniel Wagner , kernel test robot Subject: [PATCH v5] nvme-tcp: Do not reset transport on data digest errors Date: Mon, 30 Aug 2021 15:23:06 +0200 Message-Id: <20210830132306.126387-1-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The spec says 7.4.6.1 Digest Error handling When a host detects a data digest error in a C2HData PDU, that host shall continue processing C2HData PDUs associated with the command and when the command processing has completed, if a successful status was returned by the controller, the host shall fail the command with a non-fatal transport error. Currently the transport is reseted when a data digest error is detected. Instead, when a digest error is detected, mark the final status as NVME_SC_DATA_XFER_ERROR and let the upper layer handle the error. In order to keep track of the final result maintain a status field in nvme_tcp_request object and use it to overwrite the completion queue status (which might be successful even though a digest error has been detected) when completing the request. Reviewed-by: Hannes Reinecke Cc: kernel test robot Signed-off-by: Daniel Wagner --- v5: - use __le16 instead of u16 for status type. Reported by lkp v4: - https://lore.kernel.org/linux-nvme/20210830113822.104516-1-dwagner@suse.de/ - use req->status directly, avoid local variable. Suggested by Sagi. v3: - https://lore.kernel.org/linux-nvme/20210826082137.23826-1-dwagner@suse.de/ - initialize req->status in nvme_tcp_setup_cmd_pdu() - add rb tag from Hannes v2: - https://lore.kernel.org/linux-nvme/20210825124259.28707-1-dwagner@suse.de/ - moved 'status' from nvme_tcp_queue to nvme_tcp_request. v1: - https://lore.kernel.org/linux-nvme/20210805121541.77613-1-dwagner@suse.de/ drivers/nvme/host/tcp.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 645025620154..e5c801d0b442 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -45,6 +45,7 @@ struct nvme_tcp_request { u32 pdu_len; u32 pdu_sent; u16 ttag; + __le16 status; struct list_head entry; struct llist_node lentry; __le32 ddgst; @@ -485,6 +486,7 @@ static void nvme_tcp_error_recovery(struct nvme_ctrl *ctrl) static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue, struct nvme_completion *cqe) { + struct nvme_tcp_request *req; struct request *rq; rq = nvme_find_rq(nvme_tcp_tagset(queue), cqe->command_id); @@ -496,7 +498,11 @@ static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue, return -EINVAL; } - if (!nvme_try_complete_req(rq, cqe->status, cqe->result)) + req = blk_mq_rq_to_pdu(rq); + if (req->status == NVME_SC_SUCCESS) + req->status = cqe->status; + + if (!nvme_try_complete_req(rq, req->status, cqe->result)) nvme_complete_rq(rq); queue->nr_cqe++; @@ -758,7 +764,7 @@ 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, NVME_SC_SUCCESS); + nvme_tcp_end_request(rq, req->status); queue->nr_cqe++; } nvme_tcp_init_recv_ctx(queue); @@ -788,18 +794,24 @@ static int nvme_tcp_recv_ddgst(struct nvme_tcp_queue *queue, return 0; if (queue->recv_ddgst != queue->exp_ddgst) { + struct request *rq = nvme_cid_to_rq(nvme_tcp_tagset(queue), + pdu->command_id); + struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); + + req->status = NVME_SC_DATA_XFER_ERROR; + dev_err(queue->ctrl->ctrl.device, "data digest error: recv %#x expected %#x\n", le32_to_cpu(queue->recv_ddgst), le32_to_cpu(queue->exp_ddgst)); - return -EIO; } if (pdu->hdr.flags & NVME_TCP_F_DATA_SUCCESS) { struct request *rq = nvme_cid_to_rq(nvme_tcp_tagset(queue), pdu->command_id); + struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq); - nvme_tcp_end_request(rq, NVME_SC_SUCCESS); + nvme_tcp_end_request(rq, req->status); queue->nr_cqe++; } @@ -2293,6 +2305,7 @@ static blk_status_t nvme_tcp_setup_cmd_pdu(struct nvme_ns *ns, return ret; req->state = NVME_TCP_SEND_CMD_PDU; + req->status = NVME_SC_SUCCESS; req->offset = 0; req->data_sent = 0; req->pdu_len = 0; -- 2.29.2