Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2280148imb; Mon, 4 Mar 2019 00:38:07 -0800 (PST) X-Google-Smtp-Source: APXvYqz2OdQdsk1aXolmCR0vEy63xBNKe6OsiotP3960pUYszPwuscWMndUgrzgsH34s1HS803IB X-Received: by 2002:a17:902:8346:: with SMTP id z6mr19677559pln.74.1551688687920; Mon, 04 Mar 2019 00:38:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551688687; cv=none; d=google.com; s=arc-20160816; b=tvzCzSzO1yuBQIulf6clR5K01+44DphU/+LlU+uyl4F9gC6H4gaX8wbGlcr8BLLBHU cy09Q6D1oAYuGnDTJ9q1gALFK3D4KAMBFdYRwMurgYayYtEQXVcsGCYadMJZWaAy8MYA l+CE1SuL0kC5CL6e9QWU4aCV+Nnp++uAfvyd5PNp7Ml7NZ+TwOqJZH5juf512D9DzyJM jsOCfU075CXknsTneAn+Rk2kU+AIi8AwkwpBx1DHdJ28WvhdsZwgFrSooNIPRxnUS6iD h+/om0PcW+RLGH87q0w+hCd+QcpTe2sUS/IQfowUBuxVYVwvre8rGQXnnPJwYtE3j4by lA3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rcBnrrr4z1K3OdoWW9rIyaD2moxQ7iGLN6k1gdJvHwQ=; b=FqqQkBZQoVehOlf2DEjYxxYzYvEcRGdYiNymQyunI/WrWB0lSlUCbNG76Lz/BpLSW/ a+6dZPnwUsamfdHBB+GVhV3aXGc+UDqTZZrKNqPDOtDipyWaRc8/DxnrlBBMSS+v90Eg 6McoC9PBCmQhWUEn1kp8KHKwZitGImRDzAXohmoio3V7esR2Z4SmxY1NORobU7n1tOEp wZ11srGFNOjwynHL0e+HjBiqd63lwxXch/0kGOmnRB7xdrbQ9nHqudpIoBlFEEcPUA61 JcWjPsTdt7+ZMZ16pS3516C8lx8/qVo7QWeL7I1uCFIjZzsRe2w1sIizTg5k8NdI2NV5 kqnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X5q4XOoV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8si4563456pgu.224.2019.03.04.00.37.52; Mon, 04 Mar 2019 00:38:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X5q4XOoV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728702AbfCDIgY (ORCPT + 99 others); Mon, 4 Mar 2019 03:36:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:45250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726425AbfCDIgS (ORCPT ); Mon, 4 Mar 2019 03:36:18 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3431220823; Mon, 4 Mar 2019 08:36:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551688577; bh=1r1N73xnHBn841DlmplQwerHWnWZdswoUXwKuLRtSKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X5q4XOoVXlGHcONvVxIqCv30gPhS0S/KUS9XmmKLNjgISBBynHJR+3rzdc2G1sUTM JQNSHWeL1iXh/AMinOS16vrpRpAKFNHzcuD9s++KxV3sIAdukjLgEcC0bps8viOvLG G+095Yh0gmzFIvN1f/W/dra5CjyRd18BjbkHgINE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jaesoo Lee , Christoph Hellwig , Sagi Grimberg , Jens Axboe , Sasha Levin Subject: [PATCH 4.20 53/88] nvme-rdma: fix timeout handler Date: Mon, 4 Mar 2019 09:22:36 +0100 Message-Id: <20190304081632.640708219@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190304081630.610632175@linuxfoundation.org> References: <20190304081630.610632175@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 4c174e6366746ae8d49f9cc409f728eebb7a9ac9 ] Currently, we have several problems with the timeout handler: 1. If we timeout on the controller establishment flow, we will hang because we don't execute the error recovery (and we shouldn't because the create_ctrl flow needs to fail and cleanup on its own) 2. We might also hang if we get a disconnet on a queue while the controller is already deleting. This racy flow can cause the controller disable/shutdown admin command to hang. We cannot complete a timed out request from the timeout handler without mutual exclusion from the teardown flow (e.g. nvme_rdma_error_recovery_work). So we serialize it in the timeout handler and teardown io and admin queues to guarantee that no one races with us from completing the request. Reported-by: Jaesoo Lee Reviewed-by: Christoph Hellwig Signed-off-by: Sagi Grimberg Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/nvme/host/rdma.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index ab6ec7295bf90..6e24b20304b53 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -1679,18 +1679,28 @@ static enum blk_eh_timer_return nvme_rdma_timeout(struct request *rq, bool reserved) { 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; - dev_warn(req->queue->ctrl->ctrl.device, - "I/O %d QID %d timeout, reset controller\n", - rq->tag, nvme_rdma_queue_idx(req->queue)); + dev_warn(ctrl->ctrl.device, "I/O %d QID %d timeout\n", + rq->tag, nvme_rdma_queue_idx(queue)); - /* queue error recovery */ - nvme_rdma_error_recovery(req->queue->ctrl); + if (ctrl->ctrl.state != NVME_CTRL_LIVE) { + /* + * Teardown immediately if controller times out while starting + * or we are already started error recovery. all outstanding + * requests are completed on shutdown, so we return BLK_EH_DONE. + */ + flush_work(&ctrl->err_work); + nvme_rdma_teardown_io_queues(ctrl, false); + nvme_rdma_teardown_admin_queue(ctrl, false); + return BLK_EH_DONE; + } - /* fail with DNR on cmd timeout */ - nvme_req(rq)->status = NVME_SC_ABORT_REQ | NVME_SC_DNR; + dev_warn(ctrl->ctrl.device, "starting error recovery\n"); + nvme_rdma_error_recovery(ctrl); - return BLK_EH_DONE; + return BLK_EH_RESET_TIMER; } static blk_status_t nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx, -- 2.19.1