Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1977441pxb; Fri, 5 Mar 2021 04:36:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwi7yjviAaBMekCFcp4B7nklohi5ZJUllZkaqqY2TndPMSA2tDC4K5MxTPyrAkG1sDCZoC0 X-Received: by 2002:a17:906:c414:: with SMTP id u20mr1988577ejz.215.1614947810494; Fri, 05 Mar 2021 04:36:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614947810; cv=none; d=google.com; s=arc-20160816; b=KV7/OOw1jdWHT/pVwVCXwlHHxwS6SoF3qGmL+/ct56aH4RQF1PJfPPf/Hm5gtOZBTz e29gMMEZeSxpmLXUxqNiIWhf41FpYJop0pKCg2+RVeXbSLbyCIlhBMZXHXtavmwWNf+y U0CgLKLyEcvG/MlDZBJBLtuLjk/2FT1yBLbqyizPOBP0XHpshbBXk6blclTmGwEsXjvM C51eg1r6khAUgh7Q+BJIIbCiOiopg8AjLH1M9w1SZLeao4St47D9M8kZwM0B30fCCPq6 tPcC8IMqdLtfrvhlApyamitcK1gFaNORv7xxwKA+Uum/0317xLqlDSLywzACaVbOqwd8 Pcjw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DSlLhBnMxho3d0+WiWp5m94hA1Ed8K8driCn3M3PfIA=; b=NbMZjON/h8hYBkgKMV5qkqA2HASq+PZw7ReBoKEGdNOg5bbPm1JMmgc4Byg4i6om9P wUCfpFlDmTQA6yo+9nr06ljQAUpWgrNcDcLCc6d+P7Y/MOuqC3igH9wBKyknQq09TsyF 8cL88tPCmVJ5Txrj8y0XYu2x7nZy4jOItdGpfnM52HBmWdNXANydR4baI0U3DR4evJgC 5ivcgqSilEtiLoMG95hO1lYeFd6LLlRbW7nWNZtP1DrFh/RVgBRCzLx5AruOgjFf5D70 HnftunQjx7y1m2T0qlZZ2RGlaI8O82ReHrjM7Y6vFdKumSc9c+CUBFKnGZejzdWGUjSd D/7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cTCu6wZA; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bc12si1456181edb.241.2021.03.05.04.36.27; Fri, 05 Mar 2021 04:36:50 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=cTCu6wZA; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231881AbhCEMfc (ORCPT + 99 others); Fri, 5 Mar 2021 07:35:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:46606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232435AbhCEMe5 (ORCPT ); Fri, 5 Mar 2021 07:34:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E88D46501A; Fri, 5 Mar 2021 12:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614947697; bh=mMbMGvK82PX3oQrM7vu6NF1qOcbTscHtxXFdvBBeSeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cTCu6wZArQAMOtQydOH+pVJXdZCeBXvgbn6YYXwNmuXLOUBNGZwhbONWAESyCIDly RXtNrM+PC+falFjmkhQUR25kczUroZllo/wNMy6/mkH4Y0pmfqpNJRy2+Z1gaelv6J an80gKlxEEyVL9IXBQ3A4dwar6aTn7cCN6sngC98= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Leng , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.4 51/72] nvme-tcp: add clean action for failed reconnection Date: Fri, 5 Mar 2021 13:21:53 +0100 Message-Id: <20210305120859.833090797@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305120857.341630346@linuxfoundation.org> References: <20210305120857.341630346@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chao Leng [ Upstream commit 70a99574a79f1cd4dc7ad56ea37be40844bfb97b ] If reconnect failed after start io queues, the queues will be unquiesced and new requests continue to be delivered. Reconnection error handling process directly free queues without cancel suspend requests. The suppend request will time out, and then crash due to use the queue after free. Add sync queues and cancel suppend requests for reconnection error handling. Signed-off-by: Chao Leng Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/tcp.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index a554021e1ab9..77a3c488ec12 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -1710,8 +1710,10 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new) out_wait_freeze_timed_out: nvme_stop_queues(ctrl); + nvme_sync_io_queues(ctrl); nvme_tcp_stop_io_queues(ctrl); out_cleanup_connect_q: + nvme_cancel_tagset(ctrl); if (new) blk_cleanup_queue(ctrl->connect_q); out_free_tag_set: @@ -1773,12 +1775,16 @@ static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new) error = nvme_init_identify(ctrl); if (error) - goto out_stop_queue; + goto out_quiesce_queue; return 0; +out_quiesce_queue: + blk_mq_quiesce_queue(ctrl->admin_q); + blk_sync_queue(ctrl->admin_q); out_stop_queue: nvme_tcp_stop_queue(ctrl, 0); + nvme_cancel_admin_tagset(ctrl); out_cleanup_queue: if (new) blk_cleanup_queue(ctrl->admin_q); @@ -1892,10 +1898,18 @@ static int nvme_tcp_setup_ctrl(struct nvme_ctrl *ctrl, bool new) return 0; destroy_io: - if (ctrl->queue_count > 1) + if (ctrl->queue_count > 1) { + nvme_stop_queues(ctrl); + nvme_sync_io_queues(ctrl); + nvme_tcp_stop_io_queues(ctrl); + nvme_cancel_tagset(ctrl); nvme_tcp_destroy_io_queues(ctrl, new); + } destroy_admin: + blk_mq_quiesce_queue(ctrl->admin_q); + blk_sync_queue(ctrl->admin_q); nvme_tcp_stop_queue(ctrl, 0); + nvme_cancel_admin_tagset(ctrl); nvme_tcp_destroy_admin_queue(ctrl, new); return ret; } -- 2.30.1