All of lore.kernel.org
 help / color / mirror / Atom feed
From: keith.busch@linux.intel.com (Keith Busch)
Subject: [PATCH v2 1/2] nvme-pci: release iomap and prp_pools in nvme_pci_free_ctrl
Date: Wed, 11 Jul 2018 09:03:12 -0600	[thread overview]
Message-ID: <20180711150311.GE11548@localhost.localdomain> (raw)
In-Reply-To: <CAA70yB6+DKHz0wzXoRyBCv5+TxkKZzDSQajhCf6qT45zLaLCow@mail.gmail.com>

On Wed, Jul 11, 2018@09:38:34PM +0800, Weiping Zhang wrote:
> Keith Busch <keith.busch at linux.intel.com> ?2018?7?10??? ??10:46???
> >
> > I'm getting the following warning with this patch:
> >
> Hi Keith,
> 
> How to reproduce this problem, I cann't reproduce it (apply these two
> patch on 4.18.0-rc4) as following steps:
> 1. rmmod nvme
> 2. git am these 2 patchs
> 3. make modules SUBDIRS=drivers/nvme
> 4. insmod drivers/nvme/host/nvme.ko
> 5. fdisk /dev/nvme0n1 and create a partition
> 6. mkfs.ext4 /dev/nvme0n1p1
> 7. mount /dev/nvme0n1p1 /mnt
> 8. echo aaaaaa > /mnt/b.log

8.1: Hot remove /dev/nvme0

The reference counting is to ensure that resources needed to close a
a holder (the mount point, in your example) aren't released during
the 'remove'. We have to release the prp pools and the io memory before
returning from the driver's 'remove' because the pci driver is going
to release their dependencies.

Anyway, I think the right thing to do is reorder the allocations to
something more appropriate:

---
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index ba943f211687..ddd441b1516a 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2556,11 +2556,6 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	quirks |= check_vendor_combination_bug(pdev);
 
-	result = nvme_init_ctrl(&dev->ctrl, &pdev->dev, &nvme_pci_ctrl_ops,
-			quirks);
-	if (result)
-		goto release_pools;
-
 	/*
 	 * Double check that our mempool alloc size will cover the biggest
 	 * command we support.
@@ -2578,6 +2573,11 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		goto release_pools;
 	}
 
+	result = nvme_init_ctrl(&dev->ctrl, &pdev->dev, &nvme_pci_ctrl_ops,
+			quirks);
+	if (result)
+		goto release_mempool;
+
 	dev_info(dev->ctrl.device, "pci function %s\n", dev_name(&pdev->dev));
 
 	nvme_get_ctrl(&dev->ctrl);
@@ -2585,6 +2585,8 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	return 0;
 
+ release_mempool:
+	mempool_destroy(dev->iod_mempool);
  release_pools:
 	nvme_release_prp_pools(dev);
  unmap:
--

> 9. umount /mnt

  reply	other threads:[~2018-07-11 15:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-02 16:35 [PATCH v2 0/2] release /dev/nvmeX if nvme_probe failed Weiping Zhang
2018-07-02 16:35 ` [PATCH v2 1/2] nvme-pci: release iomap and prp_pools in nvme_pci_free_ctrl Weiping Zhang
2018-07-10 14:45   ` Keith Busch
2018-07-11 13:38     ` Weiping Zhang
2018-07-11 15:03       ` Keith Busch [this message]
2018-07-11 15:38         ` Weiping Zhang
2018-07-11 16:04           ` Keith Busch
2018-07-02 16:35 ` [PATCH v2 2/2] nvme-pci: release nvme_ctrl if failed to alloc memory in nvme_probe Weiping Zhang
2018-07-10 14:45   ` Keith Busch
2018-07-10 11:32 ` [PATCH v2 0/2] release /dev/nvmeX if nvme_probe failed Christoph Hellwig
2018-07-10 14:09   ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180711150311.GE11548@localhost.localdomain \
    --to=keith.busch@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.