Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1978768pxb; Fri, 5 Mar 2021 04:38:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJynKVGvNvpLlntIuQR8Vdqvpss2PSnfUxyAuV81zG4hZYTRSSqZLtK6Uulnej57Ciq31OXq X-Received: by 2002:a05:6402:22bb:: with SMTP id cx27mr8842535edb.148.1614947927826; Fri, 05 Mar 2021 04:38:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614947927; cv=none; d=google.com; s=arc-20160816; b=M+T5bN/up05bq46epJfqiwwq1GgKhRENNOBntVqoxLWkwaLYTlpD0BRSV1td5xSaWP /Gu8X8nYejcm9QjZzFc94vjKnLP4NrI92/QgDGsbRoR/4LBvLn6D2zX+EtJynhzJ1imE B+OqLvMd+I8VD8BhZy4FSSEz1KO2HJ1hYtZ29l+iQmadSt5MBxYkp7OedApqtP4bYSDL K7i0QBVJDZBz2GQtmZMs3wveQ8xPZ3efYsRQWLV9x4crPpybUf4xpqJnq4KjRRDvHr9t Ce58niSDeq/Z1nMjwRYzvsRKICHC3HnyVAUro2eNnwmRfT1CU77TMXGTP55JfOyxJTSp VHNw== 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=F6YFq0y6k2f1SqswAFW5aNRvXF4MQi4LEopPruTiTnY=; b=noaeII/DEoS4Dtcq1lyA7Ou3PXKRKIMZjLJpp82k5t8dyta7sVXgdaSGyawBGEMDRD /HKJF1Uou4TtznmeSeIHTkksNHXRAbu6TEsUvWVu7eaxTKikVSVoecr7jcXlxxFw/44M Gh+leMGKZZx7ynYbDtpH/PF/A2SphfNLtYYxo8bOqo/Z8V+9U/N6+LmqStRjiLF6Pm0G j2UIMs6mp4yqvMnyBHSAN5/RoIwChWtMAWw+aovGXvspVwvuJaNIQDHWw0CQST5PL2OA 9Hr3w/KVzVyDcZ9BZ7Vr57BRcvIY14n77J8M2o5Fie5W60anBRBQ+R/vr18fRoznAUsM JxZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TnJHfER+; 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 e7si1254600ejz.428.2021.03.05.04.38.24; Fri, 05 Mar 2021 04:38:47 -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=TnJHfER+; 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 S232787AbhCEMf0 (ORCPT + 99 others); Fri, 5 Mar 2021 07:35:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:46586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232622AbhCEMez (ORCPT ); Fri, 5 Mar 2021 07:34:55 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4362E65004; Fri, 5 Mar 2021 12:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614947694; bh=7LvsaCfDa1TCk6O/mpR1GthSEw6hM0lMlVR1G/Nqdmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TnJHfER+/7Zs3ZO40GusTuGWqRkmH28mLEX/h6CTDvEYU3LGe3Y30/O9EdLeNDlFi P2X80abpJzctl2Vm/gcygTLuiXEfb/B8Qq6KGUzjrdp5xU5OU7VWQJK4wi9NBUzhgr YUuf48hisSLYc8nZ7X5JkvhR2SMerJ9kMVbalpP0= 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 50/72] nvme-rdma: add clean action for failed reconnection Date: Fri, 5 Mar 2021 13:21:52 +0100 Message-Id: <20210305120859.783651998@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 958dc1d32c80566f58d18f05ef1f05bd32d172c1 ] A crash happens when inject failed reconnection. 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/rdma.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 8a62c2fe5a5e..da6030010432 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -835,12 +835,16 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl, error = nvme_init_identify(&ctrl->ctrl); if (error) - goto out_stop_queue; + goto out_quiesce_queue; return 0; +out_quiesce_queue: + blk_mq_quiesce_queue(ctrl->ctrl.admin_q); + blk_sync_queue(ctrl->ctrl.admin_q); out_stop_queue: nvme_rdma_stop_queue(&ctrl->queues[0]); + nvme_cancel_admin_tagset(&ctrl->ctrl); out_cleanup_queue: if (new) blk_cleanup_queue(ctrl->ctrl.admin_q); @@ -917,8 +921,10 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new) out_wait_freeze_timed_out: nvme_stop_queues(&ctrl->ctrl); + nvme_sync_io_queues(&ctrl->ctrl); nvme_rdma_stop_io_queues(ctrl); out_cleanup_connect_q: + nvme_cancel_tagset(&ctrl->ctrl); if (new) blk_cleanup_queue(ctrl->ctrl.connect_q); out_free_tag_set: @@ -1054,10 +1060,18 @@ static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new) return 0; destroy_io: - if (ctrl->ctrl.queue_count > 1) + if (ctrl->ctrl.queue_count > 1) { + nvme_stop_queues(&ctrl->ctrl); + nvme_sync_io_queues(&ctrl->ctrl); + nvme_rdma_stop_io_queues(ctrl); + nvme_cancel_tagset(&ctrl->ctrl); nvme_rdma_destroy_io_queues(ctrl, new); + } destroy_admin: + blk_mq_quiesce_queue(ctrl->ctrl.admin_q); + blk_sync_queue(ctrl->ctrl.admin_q); nvme_rdma_stop_queue(&ctrl->queues[0]); + nvme_cancel_admin_tagset(&ctrl->ctrl); nvme_rdma_destroy_admin_queue(ctrl, new); return ret; } -- 2.30.1