Received: by 10.223.185.116 with SMTP id b49csp2392846wrg; Mon, 12 Feb 2018 08:51:33 -0800 (PST) X-Google-Smtp-Source: AH8x226jyaINV6McKca/9umHywO4uJbvUfKT3JiB0HjNO+aL0QGCBwRPSVlwhQ4WmtpDZpCLcUjw X-Received: by 2002:a17:902:8496:: with SMTP id c22-v6mr11161577plo.36.1518454293332; Mon, 12 Feb 2018 08:51:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518454293; cv=none; d=google.com; s=arc-20160816; b=PR97BdcmB+/LWjkKSW7cw8V0YEXmbC0/6rLCghi1cdy7eTEIOGjxHZujhOFFpATRsC O03FV02MjW0jzgUmcPFlZ8a6spDMgmrtdkQlCdLw8vxbKOA56TZTLWnGLnQUqwmR4WqK a/62SS/MB4pSPLtoohisJHO7DxFy9cClcQ6Ozdt2TfEYTHNv5EEU+GdVV4xikYmvY6VQ Cdyxt7Wac6d5Te3n9Tmozz0gymPBMtIMANKOuJ/2TNB/mPX0CnwCFeCszoW2wqaExqzq LuNG1xKxZ0rKP0YGoComZi80RIq1cEstvcu8dAihmXsURv1lK6JaA19A0Mr1kjlEHLbx 4SnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=hL+RNZlxQ7c+/AK654KSj7ZAMgsjd/lKUjkoz1L+77o=; b=XUjiG7+GfsiacSopp1fh5P3+FpGWz4/V/3Ko6n5HCc5ACBHv2HsDYpPTGFmlpStXnQ EVYS8u8oDq4LNgpdQzA5vXZSNPtA87Q/puhfep7Vgbs/fg0FfiT0M4VHReunXtObRgNv G61jaDVv3lCoUYhztgfhsgHgauEDSTdIcF1OFf9pvhsdqx+gZyMVJY5pEMvXfOdrwN4c nuAJ9yYperf185o+ByuhLXcE0HaITvXRyy45dSMKtfImgzeVsRJtgUx89S78OKNEDQ8R O9AjPnWeJRUGHHArwTOo2yjLt+G9TmlCZkhg0od47nHYRVTkcE1sZBTDyk+RG137uxpW AkwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=hvYYPLXv; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m21si4979468pfg.367.2018.02.12.08.51.18; Mon, 12 Feb 2018 08:51:33 -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=@oracle.com header.s=corp-2017-10-26 header.b=hvYYPLXv; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935106AbeBLM6I (ORCPT + 99 others); Mon, 12 Feb 2018 07:58:08 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:57020 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935054AbeBLM6A (ORCPT ); Mon, 12 Feb 2018 07:58:00 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1CCvOpf109830; Mon, 12 Feb 2018 12:57:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2017-10-26; bh=hL+RNZlxQ7c+/AK654KSj7ZAMgsjd/lKUjkoz1L+77o=; b=hvYYPLXvWgZbVuS2HrdF8kar0hiNMwIgBnVw1b4VTgiT5ymCHBHXpr4JpI0IUpuffmU2 5zsGIChDoek0VbcI3S3tE3XtgDGHJcKMrDNkumtTv+gRewXnJQL1P4EKFBRrx9Auv8br q0Fl6mBoZQRKSlBuNE5pNjhPkbeoIqVqP4bZKxg+EKBtDnFQ6DzsFgGfPbqZJ8WJynT2 FtonHPhQzK5vF9MNXiBxXq35IQLPXkgnFMIZi5G28HbeX+dpxkO4IZ4+5F7wtFJqGaC7 xx8c2Jp2/9hiM3JjG21XzofyLILWrO6m68ANrMcz7fLU/IT9QiwMlceLuGB5W5gbaBpu sw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2g3ahv8788-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Feb 2018 12:57:30 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w1CCurgo029174 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 12 Feb 2018 12:56:53 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w1CCur72013835; Mon, 12 Feb 2018 12:56:53 GMT Received: from will-ThinkCentre-M910s.cn.oracle.com (/10.182.70.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 12 Feb 2018 04:56:52 -0800 From: Jianchao Wang To: keith.busch@intel.com, axboe@fb.com, hch@lst.de, sagi@grimberg.me Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] nvme-pci: drain the entered requests after ctrl is shutdown Date: Mon, 12 Feb 2018 20:57:02 +0800 Message-Id: <1518440222-652-1-git-send-email-jianchao.w.wang@oracle.com> X-Mailer: git-send-email 2.7.4 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8802 signatures=668668 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=761 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802120168 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, we will unquiesce the queues after the controller is shutdown to avoid residual requests to be stuck. In fact, we can do it more cleanly, just wait freeze and drain the queue in nvme_dev_disable and finally leave the queues quiesced. Signed-off-by: Jianchao Wang --- drivers/nvme/host/pci.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 4a7c420..6e5d2ca 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2183,10 +2183,8 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) * Give the controller a chance to complete all entered requests if * doing a safe shutdown. */ - if (!dead) { - if (shutdown) - nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT); - } + if (!dead && shutdown) + nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT); nvme_stop_queues(&dev->ctrl); @@ -2211,12 +2209,15 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) blk_mq_tagset_busy_iter(&dev->admin_tagset, nvme_cancel_request, &dev->ctrl); /* - * The driver will not be starting up queues again if shutting down so - * must flush all entered requests to their failed completion to avoid - * deadlocking blk-mq hot-cpu notifier. + * For shutdown case, controller will not be setup again soon. If any + * residual requests here, the controller must have go wrong. Drain and + * fail all the residual entered IO requests. */ - if (shutdown) + if (shutdown) { nvme_start_queues(&dev->ctrl); + nvme_wait_freeze(&dev->ctrl); + nvme_stop_queues(&dev->ctrl); + } mutex_unlock(&dev->shutdown_lock); } -- 2.7.4