From patchwork Tue Sep 18 10:19:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10604053 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F3A0913 for ; Tue, 18 Sep 2018 10:20:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 309A42A3B6 for ; Tue, 18 Sep 2018 10:20:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24ED42A3BF; Tue, 18 Sep 2018 10:20:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B203A2A3B6 for ; Tue, 18 Sep 2018 10:20:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729361AbeIRPwO (ORCPT ); Tue, 18 Sep 2018 11:52:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59850 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726768AbeIRPwN (ORCPT ); Tue, 18 Sep 2018 11:52:13 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6466E83F3C; Tue, 18 Sep 2018 10:20:18 +0000 (UTC) Received: from localhost (ovpn-8-16.pek2.redhat.com [10.72.8.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2C7C308BDA0; Tue, 18 Sep 2018 10:20:15 +0000 (UTC) From: Ming Lei To: linux-kernel@vger.kernel.org Cc: Ming Lei , Tejun Heo , Jianchao Wang , Kent Overstreet , linux-block@vger.kernel.org, Christoph Hellwig , linux-nvme@lists.infradead.org, Keith Busch Subject: [PATCH 4/4] nvme: don't drain IO in nvme_reset_work() Date: Tue, 18 Sep 2018 18:19:46 +0800 Message-Id: <20180918101946.13329-5-ming.lei@redhat.com> In-Reply-To: <20180918101946.13329-1-ming.lei@redhat.com> References: <20180918101946.13329-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 18 Sep 2018 10:20:18 +0000 (UTC) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After the controller is recovered, it isn't necessary to wait for completion of all in-flight IO. More importantly, it is easy to trigger deadlock if there is new IO timeout triggered. Cc: Tejun Heo Cc: Jianchao Wang Cc: Kent Overstreet Cc: linux-block@vger.kernel.org Cc: Christoph Hellwig Cc: linux-nvme@lists.infradead.org Cc: Keith Busch Signed-off-by: Ming Lei --- drivers/nvme/host/core.c | 12 ++++++++---- drivers/nvme/host/nvme.h | 2 +- drivers/nvme/host/pci.c | 3 +-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index dd8ec1dd9219..cf6a2267d44e 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1203,7 +1203,7 @@ static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects) if (effects & NVME_CMD_EFFECTS_LBCC) nvme_update_formats(ctrl); if (effects & (NVME_CMD_EFFECTS_LBCC | NVME_CMD_EFFECTS_CSE_MASK)) - nvme_unfreeze(ctrl); + nvme_unfreeze(ctrl, true); if (effects & NVME_CMD_EFFECTS_CCC) nvme_init_identify(ctrl); if (effects & (NVME_CMD_EFFECTS_NIC | NVME_CMD_EFFECTS_NCC)) @@ -3602,13 +3602,17 @@ void nvme_kill_queues(struct nvme_ctrl *ctrl) } EXPORT_SYMBOL_GPL(nvme_kill_queues); -void nvme_unfreeze(struct nvme_ctrl *ctrl) +void nvme_unfreeze(struct nvme_ctrl *ctrl, bool check_io_drained) { struct nvme_ns *ns; down_read(&ctrl->namespaces_rwsem); - list_for_each_entry(ns, &ctrl->namespaces, list) - blk_mq_unfreeze_queue(ns->queue); + list_for_each_entry(ns, &ctrl->namespaces, list) { + if (check_io_drained) + blk_mq_unfreeze_queue(ns->queue); + else + blk_mq_unfreeze_queue_no_drain_io(ns->queue); + } up_read(&ctrl->namespaces_rwsem); } EXPORT_SYMBOL_GPL(nvme_unfreeze); diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index bb4a2003c097..fd56270637d1 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -432,7 +432,7 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status, void nvme_stop_queues(struct nvme_ctrl *ctrl); void nvme_start_queues(struct nvme_ctrl *ctrl); void nvme_kill_queues(struct nvme_ctrl *ctrl); -void nvme_unfreeze(struct nvme_ctrl *ctrl); +void nvme_unfreeze(struct nvme_ctrl *ctrl, bool check_io_drained); void nvme_wait_freeze(struct nvme_ctrl *ctrl); void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout); void nvme_start_freeze(struct nvme_ctrl *ctrl); diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index d668682f91df..1c26a2e92063 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2328,11 +2328,10 @@ static void nvme_reset_work(struct work_struct *work) new_state = NVME_CTRL_ADMIN_ONLY; } else { nvme_start_queues(&dev->ctrl); - nvme_wait_freeze(&dev->ctrl); /* hit this only when allocate tagset fails */ if (nvme_dev_add(dev)) new_state = NVME_CTRL_ADMIN_ONLY; - nvme_unfreeze(&dev->ctrl); + nvme_unfreeze(&dev->ctrl, false); } /*