From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752876AbeBKJjP (ORCPT ); Sun, 11 Feb 2018 04:39:15 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:33558 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752273AbeBKJjM (ORCPT ); Sun, 11 Feb 2018 04:39:12 -0500 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 6/9] nvme-pci: drain the entered requests after ctrl is shutdown Date: Sun, 11 Feb 2018 17:38:37 +0800 Message-Id: <1518341920-1060-7-git-send-email-jianchao.w.wang@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518341920-1060-1-git-send-email-jianchao.w.wang@oracle.com> References: <1518341920-1060-1-git-send-email-jianchao.w.wang@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8801 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=804 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802110127 Sender: linux-kernel-owner@vger.kernel.org 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 them before nvme_dev_disable return. Signed-off-by: Jianchao Wang --- drivers/nvme/host/pci.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index c5c1365..f3e0eae 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2187,10 +2187,9 @@ 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); if (!dead) { @@ -2219,12 +2218,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