From patchwork Wed May 17 01:27:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9729895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2F80F60386 for ; Wed, 17 May 2017 01:28:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22A4C286D9 for ; Wed, 17 May 2017 01:28:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 163C6286F4; Wed, 17 May 2017 01:28: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=-6.9 required=2.0 tests=BAYES_00,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 BA132286D9 for ; Wed, 17 May 2017 01:28:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751569AbdEQB2T (ORCPT ); Tue, 16 May 2017 21:28:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58840 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750970AbdEQB2S (ORCPT ); Tue, 16 May 2017 21:28:18 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD6C4C04B923; Wed, 17 May 2017 01:28:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CD6C4C04B923 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ming.lei@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CD6C4C04B923 Received: from localhost (vpn1-5-82.pek2.redhat.com [10.72.5.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67FE317258; Wed, 17 May 2017 01:28:09 +0000 (UTC) From: Ming Lei To: Jens Axboe , Keith Busch , Christoph Hellwig , Sagi Grimberg Cc: linux-nvme@lists.infradead.org, Zhang Yi , linux-block@vger.kernel.org, Ming Lei , stable@vger.kernel.org Subject: [PATCH 2/2] nvme: avoid to hang in remove disk Date: Wed, 17 May 2017 09:27:29 +0800 Message-Id: <20170517012729.13469-3-ming.lei@redhat.com> In-Reply-To: <20170517012729.13469-1-ming.lei@redhat.com> References: <20170517012729.13469-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 17 May 2017 01:28: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 If some writeback requests are submitted just before queue is killed, and these requests may not be canceled in nvme_dev_disable() because they are not started yet, it is still possible for blk-mq to hold these requests in .requeue list. So we have to abort these requests first before del_gendisk(), because del_gendisk() may wait for completion of these requests. Cc: stable@vger.kernel.org Signed-off-by: Ming Lei --- drivers/nvme/host/core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index d5e0906262ea..8eaeea86509a 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2097,6 +2097,14 @@ static void nvme_ns_remove(struct nvme_ns *ns) &nvme_ns_attr_group); if (ns->ndev) nvme_nvm_unregister_sysfs(ns); + /* + * If queue is dead, we have to abort requests in + * requeue list because fsync_bdev() in removing disk + * path may wait for these IOs, which can't + * be submitted to hardware too. + */ + if (blk_queue_dying(ns->queue)) + blk_mq_abort_requeue_list(ns->queue); del_gendisk(ns->disk); blk_mq_abort_requeue_list(ns->queue); blk_cleanup_queue(ns->queue);