Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1276599

[PATCH] lightnvm: remove targets when corresponding nvm device exit

From Wenwei Tao <ww.tao0320@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] lightnvm: remove targets when corresponding nvm device exit
Date 2015-11-24 17:10 +0100
Message-ID <qyoki-1XH-29@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


the target should be unreachable when underlying device was gone.

Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
---
 drivers/lightnvm/core.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index f659e60..b95c6c4 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -278,10 +278,18 @@ err:
 	return ret;
 }
 
+static void nvm_remove_target(struct nvm_target *t);
+
 static void nvm_exit(struct nvm_dev *dev)
 {
+	struct nvm_target *t, *n;
+
 	if (dev->ppalist_pool)
 		dev->ops->destroy_dma_pool(dev->ppalist_pool);
+	down_write(&nvm_lock);
+	list_for_each_entry_safe(t, n, &dev->online_targets, list)
+		nvm_remove_target(t);
+	up_write(&nvm_lock);
 	nvm_free(dev);
 
 	pr_info("nvm: successfully unloaded\n");
@@ -496,13 +504,13 @@ static int __nvm_configure_create(struct nvm_ioctl_create *create)
 
 static int __nvm_configure_remove(struct nvm_ioctl_remove *remove)
 {
-	struct nvm_target *t = NULL;
+	struct nvm_target *n, *t = NULL;
 	struct nvm_dev *dev;
 	int ret = -1;
 
 	down_write(&nvm_lock);
 	list_for_each_entry(dev, &nvm_devices, devices)
-		list_for_each_entry(t, &dev->online_targets, list) {
+		list_for_each_entry_safe(t, n, &dev->online_targets, list) {
 			if (!strcmp(remove->tgtname, t->disk->disk_name)) {
 				nvm_remove_target(t);
 				ret = 0;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] lightnvm: remove targets when corresponding nvm device exit Wenwei Tao <ww.tao0320@gmail.com> - 2015-11-24 17:10 +0100
  Re: [PATCH] lightnvm: remove targets when corresponding nvm device  exit Matias <mb@lightnvm.io> - 2015-11-24 20:00 +0100
    Re: [PATCH] lightnvm: remove targets when corresponding nvm device exit Wenwei Tao <ww.tao0320@gmail.com> - 2015-11-25 10:30 +0100

csiph-web