Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp205845imj; Thu, 14 Feb 2019 18:40:14 -0800 (PST) X-Google-Smtp-Source: AHgI3IY2DvUzzuqSZyeY+WNrCTA3cPJ3pl7JSCxb2Xol53RbZq5m9C3q5C6Cx3v74KzmKg9Y8HKw X-Received: by 2002:a62:7042:: with SMTP id l63mr7349665pfc.1.1550198414246; Thu, 14 Feb 2019 18:40:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198414; cv=none; d=google.com; s=arc-20160816; b=eXDH4MAqE3tN6ekww//TUD347X7djPmH/6JyRjoLFsISDFlmU0/WRHnpH9dbB08BXb Gs9wl3P4V4m+oMH+wMx6Giyrmk80MtU2Lpoz0/P5C6Y3Gr/6qvxg5RmeP6ETmWekVMWl FYTy7irpmXNVd+yAM/X9225kVwEC7N9BEUjkdCJaDUAwBUjfZdGoZrtc5TT1aMtc6N+s IUtsV6Mjpcf9hOUpKksFsAI9p4z00MKjpYihFXky2E9DiLSrm3Vuq0fTOvQ8A84uTE8X 9Qf6Dp4YdnA2jgKwNTkz6fUYGD7mwYupvItxrjNKBWPWFb/ebpe5VCX3cB4+6r1VIskm O5FQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bqW3BEZYfk6huxj6GPo2OYPoKi0M+1duvuo+ZXlj8Zw=; b=C+D70nndtFcHXzg4A5CO/8ABT/gvu0/XxG6rgZSkggUF6Rbt+beZ6dnID6KzAWl9gZ nW7euz8kBwAK1gcExBz/VLjimQPdVSJfXbkuzYllWBXMi4BDAPGj6eKdBjHEfIP75sLr 2uceagDkl67vB5Ht4mRCYagvQ8iIk3fyiXxGfHGuwBnpn4VjeUP76WlH4sqXEjOyo+ij eUr9kur+FwwSaIXUzJxyiq1yuvGP2uFB/kt1RBJSDD5ZrtqxWlFJK13ClSse3C6Xkw/7 rNnSJIr8nCILxtEIJSaqzjlgKmEw/t+ijC1Vz7Kc8SHKLxjUGmMxwFIpe7XLJF0lEmg6 6zNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BwTqway9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s5si3820635pgp.64.2019.02.14.18.39.58; Thu, 14 Feb 2019 18:40:14 -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=BwTqway9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389061AbfBOChQ (ORCPT + 99 others); Thu, 14 Feb 2019 21:37:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:50750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390619AbfBOCKg (ORCPT ); Thu, 14 Feb 2019 21:10:36 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 770FC222D4; Fri, 15 Feb 2019 02:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196635; bh=nea4Wn8nOz0hjIBBYZWzQYPhtp1Y7vTYjTgDb096TvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BwTqway9V501o+w7Eq5QXvAeUxXOA9nf04GtX1QNFV0nyQzh9jWkn27HeGbycPNvq yPIntcyTcqpGRK+mkNTSaTGeQ9I0HkH1I4dVxdUAArSpguUsBvCmh164qMCL/gt/ZM FJcGpMR+fbPQ1OEX0Rm5DV/6g1361L4CF1zJH1Do= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sagi Grimberg , Jens Axboe , Sasha Levin , linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 4.20 60/77] nvme-rdma: fix timeout handler Date: Thu, 14 Feb 2019 21:08:38 -0500 Message-Id: <20190215020855.176727-60-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215020855.176727-1-sashal@kernel.org> References: <20190215020855.176727-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sagi Grimberg [ 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 ab6ec7295bf9..6e24b20304b5 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