From patchwork Fri Jan 22 22:08:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 8093661 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7D692BEEE5 for ; Fri, 22 Jan 2016 22:08:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A217F205BC for ; Fri, 22 Jan 2016 22:08:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 04228205BD for ; Fri, 22 Jan 2016 22:08:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753444AbcAVWII (ORCPT ); Fri, 22 Jan 2016 17:08:08 -0500 Received: from mga14.intel.com ([192.55.52.115]:3900 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751431AbcAVWIH (ORCPT ); Fri, 22 Jan 2016 17:08:07 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 22 Jan 2016 14:08:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,333,1449561600"; d="scan'208";a="866487583" Received: from kbusch-mobl4.amr.corp.intel.com (HELO localhost.localdomain) ([10.232.112.55]) by orsmga001.jf.intel.com with ESMTP; 22 Jan 2016 14:08:05 -0800 Date: Fri, 22 Jan 2016 22:08:05 +0000 From: Keith Busch To: Jens Axboe Cc: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org Subject: Re: [GIT PULL] NVMe changes for 4.5-rc1 Message-ID: <20160122220805.GA30907@localhost.localdomain> References: <20160121212738.GA15727@kernel.dk> <56A251C2.101@fb.com> <56A258F1.1060207@fb.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <56A258F1.1060207@fb.com> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Jan 22, 2016 at 09:29:37AM -0700, Jens Axboe wrote: > On 01/22/2016 09:26 AM, Linus Torvalds wrote: > > > >On Jan 22, 2016 7:59 AM, "Jens Axboe" >> wrote: > > >> > > >> - nvme_dev_remove() got renamed to nvme_remove_namespaces(), but also > > >> lost the "dev" argument (it takes "struct nvme_ctrl *ctrl" now). > > > > > > &dev->ctrl > > > >That's not the problem - the code does that already. > > > >But we want the dev argument *back*, since the function now wants to do > >that nvme_io_incapable() check and then cancel the IO on it. > > > >And I didn't know if you guys would want to use container_of() or just > >change the calling convention back to using "dev", or perhaps just > >decide to do the IO cleanup in the caller instead. That last option > >seems the cleanest, since now nvme_dev_remove_namespaces() is just about > >the namespace, and maybe it would be better to re-introduce a whole new > >nvme_dev_remove() that does the old thing. > > The latter is the cleanest approach, we'll get it fixed up. Looks like IO ending is the only conflict. The cleanup below will get the functionality back. You might notice nvme_dev_disable is called twice for a surprise removal, case, but that's okay. --- -- -- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 72ef832..5d31cfc 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2118,6 +2118,15 @@ static void nvme_remove(struct pci_dev *pdev) pci_set_drvdata(pdev, NULL); flush_work(&dev->reset_work); flush_work(&dev->scan_work); + + /* + * If the controller can't do IO (surprise removal, for example), we + * need to disable prior to deleting namespaces. This ends outstanding + * requests and prevents attempts to sync dirty data. + */ + if (nvme_io_incapable(&dev->ctrl)) + nvme_dev_disable(dev, true); + nvme_remove_namespaces(&dev->ctrl); nvme_uninit_ctrl(&dev->ctrl); nvme_dev_disable(dev, true);