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


Groups > linux.kernel > #1284841 > unrolled thread

[PATCH 0/9] Fixes for LightNVM

Started byMatias Bjørling <m@bjorling.me>
First post2015-12-06 11:30 +0100
Last post2015-12-07 19:00 +0100
Articles 6 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/9] Fixes for LightNVM Matias Bjørling <m@bjorling.me> - 2015-12-06 11:30 +0100
    [PATCH 5/9] lightnvm: comments on constants Matias Bjørling <m@bjorling.me> - 2015-12-06 11:30 +0100
    [PATCH 7/9] lightnvm: fix media mgr registration Matias Bjørling <m@bjorling.me> - 2015-12-06 11:30 +0100
    [PATCH 8/9] lightnvm: prevent gennvm module unload on use Matias Bjørling <m@bjorling.me> - 2015-12-06 11:30 +0100
    Re: [PATCH 0/9] Fixes for LightNVM Jens Axboe <axboe@fb.com> - 2015-12-07 17:20 +0100
      Re: [PATCH 0/9] Fixes for LightNVM Matias Bjørling <m@bjorling.me> - 2015-12-07 19:00 +0100

#1284841 — [PATCH 0/9] Fixes for LightNVM

FromMatias Bjørling <m@bjorling.me>
Date2015-12-06 11:30 +0100
Subject[PATCH 0/9] Fixes for LightNVM
Message-ID<qCEJP-5Hj-3@gated-at.bofh.it>
Hi Jens,

A couple more fixes for LightNVM.

The first three patches are fixed from Tao on rrpc and gennvm. The next
five patches are small fixes and refactoring to prepare for system
blocks. The last patch defaults debugging to not be compiled in and
thereby not expose the parameter configuration interface.

Thanks! Please pick up when convenient.

Matias Bjørling (6):
  lightnvm: check mm before use
  lightnvm: comments on constants
  lightnvm: replace req queue with nvmdev for lld
  lightnvm: fix media mgr registration
  lightnvm: prevent gennvm module unload on use
  lightnvm: do not compile in debugging by default

Wenwei Tao (3):
  lightnvm: use flags in rrpc_get_blk
  lightnvm: put blks when luns configure failed
  lightnvm: refactor spin_unlock in gennvm_get_blk

 drivers/block/null_blk.c     |  9 ++---
 drivers/lightnvm/Kconfig     |  1 +
 drivers/lightnvm/core.c      | 85 ++++++++++++++++++++++----------------------
 drivers/lightnvm/gennvm.c    | 20 ++++++-----
 drivers/lightnvm/rrpc.c      | 25 ++++++++++---
 drivers/nvme/host/lightnvm.c | 26 +++++++-------
 include/linux/lightnvm.h     | 21 +++++++----
 7 files changed, 108 insertions(+), 79 deletions(-)

-- 
2.1.4

--
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/

[toc] | [next] | [standalone]


#1284842 — [PATCH 5/9] lightnvm: comments on constants

FromMatias Bjørling <m@bjorling.me>
Date2015-12-06 11:30 +0100
Subject[PATCH 5/9] lightnvm: comments on constants
Message-ID<qCEJQ-5Hj-17@gated-at.bofh.it>
In reply to#1284841
It is not obvious what NVM_IO_* and NVM_BLK_T_* are used for. Make sure
to comment them appropriately as the other constants.

Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 include/linux/lightnvm.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h
index c6916ae..935ef38 100644
--- a/include/linux/lightnvm.h
+++ b/include/linux/lightnvm.h
@@ -50,9 +50,16 @@ enum {
 	NVM_IO_DUAL_ACCESS	= 0x1,
 	NVM_IO_QUAD_ACCESS	= 0x2,
 
+	/* NAND Access Modes */
 	NVM_IO_SUSPEND		= 0x80,
 	NVM_IO_SLC_MODE		= 0x100,
 	NVM_IO_SCRAMBLE_DISABLE	= 0x200,
+
+	/* Block Types */
+	NVM_BLK_T_FREE		= 0x0,
+	NVM_BLK_T_BAD		= 0x1,
+	NVM_BLK_T_DEV		= 0x2,
+	NVM_BLK_T_HOST		= 0x4,
 };
 
 struct nvm_id_group {
-- 
2.1.4

--
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/

[toc] | [prev] | [next] | [standalone]


#1284843 — [PATCH 7/9] lightnvm: fix media mgr registration

FromMatias Bjørling <m@bjorling.me>
Date2015-12-06 11:30 +0100
Subject[PATCH 7/9] lightnvm: fix media mgr registration
Message-ID<qCEJQ-5Hj-21@gated-at.bofh.it>
In reply to#1284841
This patch fixes two issues during media manager registration.

1. The ppa pool can be used at media manager registration. Allocate the
ppa pool before that.

2. If a media manager can't be found, this should not lead to the
device being unallocated. A media manager can be registered later, that
can manage the device. Only warn if a media manager fails
initialization.

Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 drivers/lightnvm/core.c | 78 ++++++++++++++++++++++++-------------------------
 1 file changed, 39 insertions(+), 39 deletions(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 4a8d1fe..8f41b24 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -97,15 +97,47 @@ static struct nvmm_type *nvm_find_mgr_type(const char *name)
 	return NULL;
 }
 
+struct nvmm_type *nvm_init_mgr(struct nvm_dev *dev)
+{
+	struct nvmm_type *mt;
+	int ret;
+
+	lockdep_assert_held(&nvm_lock);
+
+	list_for_each_entry(mt, &nvm_mgrs, list) {
+		ret = mt->register_mgr(dev);
+		if (ret < 0) {
+			pr_err("nvm: media mgr failed to init (%d) on dev %s\n",
+								ret, dev->name);
+			return NULL; /* initialization failed */
+		} else if (ret > 0)
+			return mt;
+	}
+
+	return NULL;
+}
+
 int nvm_register_mgr(struct nvmm_type *mt)
 {
+	struct nvm_dev *dev;
 	int ret = 0;
 
 	down_write(&nvm_lock);
-	if (nvm_find_mgr_type(mt->name))
+	if (nvm_find_mgr_type(mt->name)) {
 		ret = -EEXIST;
-	else
+		goto finish;
+	} else {
 		list_add(&mt->list, &nvm_mgrs);
+	}
+
+	/* try to register media mgr if any device have none configured */
+	list_for_each_entry(dev, &nvm_devices, devices) {
+		if (dev->mt)
+			continue;
+
+		dev->mt = nvm_init_mgr(dev);
+	}
+finish:
 	up_write(&nvm_lock);
 
 	return ret;
@@ -123,26 +155,6 @@ void nvm_unregister_mgr(struct nvmm_type *mt)
 }
 EXPORT_SYMBOL(nvm_unregister_mgr);
 
-/* register with device with a supported manager */
-static int register_mgr(struct nvm_dev *dev)
-{
-	struct nvmm_type *mt;
-	int ret = 0;
-
-	list_for_each_entry(mt, &nvm_mgrs, list) {
-		ret = mt->register_mgr(dev);
-		if (ret > 0) {
-			dev->mt = mt;
-			break; /* successfully initialized */
-		}
-	}
-
-	if (!ret)
-		pr_info("nvm: no compatible nvm manager found.\n");
-
-	return ret;
-}
-
 static struct nvm_dev *nvm_find_nvm_dev(const char *name)
 {
 	struct nvm_dev *dev;
@@ -271,14 +283,6 @@ static int nvm_init(struct nvm_dev *dev)
 		goto err;
 	}
 
-	down_write(&nvm_lock);
-	ret = register_mgr(dev);
-	up_write(&nvm_lock);
-	if (ret < 0)
-		goto err;
-	if (!ret)
-		return 0;
-
 	pr_info("nvm: registered %s [%u/%u/%u/%u/%u/%u]\n",
 			dev->name, dev->sec_per_pg, dev->nr_planes,
 			dev->pgs_per_blk, dev->blks_per_lun, dev->nr_luns,
@@ -334,7 +338,9 @@ int nvm_register(struct request_queue *q, char *disk_name,
 		}
 	}
 
+	/* register device with a supported media manager */
 	down_write(&nvm_lock);
+	dev->mt = nvm_init_mgr(dev);
 	list_add(&dev->devices, &nvm_devices);
 	up_write(&nvm_lock);
 
@@ -379,19 +385,13 @@ static int nvm_create_target(struct nvm_dev *dev,
 	struct nvm_tgt_type *tt;
 	struct nvm_target *t;
 	void *targetdata;
-	int ret = 0;
 
-	down_write(&nvm_lock);
 	if (!dev->mt) {
-		ret = register_mgr(dev);
-		if (!ret)
-			ret = -ENODEV;
-		if (ret < 0) {
-			up_write(&nvm_lock);
-			return ret;
-		}
+		pr_info("nvm: device has no media manager registered.\n");
+		return -ENODEV;
 	}
 
+	down_write(&nvm_lock);
 	tt = nvm_find_target_type(create->tgttype);
 	if (!tt) {
 		pr_err("nvm: target type %s not found\n", create->tgttype);
-- 
2.1.4

--
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/

[toc] | [prev] | [next] | [standalone]


#1284844 — [PATCH 8/9] lightnvm: prevent gennvm module unload on use

FromMatias Bjørling <m@bjorling.me>
Date2015-12-06 11:30 +0100
Subject[PATCH 8/9] lightnvm: prevent gennvm module unload on use
Message-ID<qCEJQ-5Hj-23@gated-at.bofh.it>
In reply to#1284841
After the gennvm module has been initialized. It might be attached to
one or several devices. In that case, the module is in use. Make sure
that it can not be unloaded.

Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 drivers/lightnvm/gennvm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c
index 52b513a..f434e89 100644
--- a/drivers/lightnvm/gennvm.c
+++ b/drivers/lightnvm/gennvm.c
@@ -219,6 +219,9 @@ static int gennvm_register(struct nvm_dev *dev)
 	struct gen_nvm *gn;
 	int ret;
 
+	if (!try_module_get(THIS_MODULE))
+		return -ENODEV;
+
 	gn = kzalloc(sizeof(struct gen_nvm), GFP_KERNEL);
 	if (!gn)
 		return -ENOMEM;
@@ -242,12 +245,14 @@ static int gennvm_register(struct nvm_dev *dev)
 	return 1;
 err:
 	gennvm_free(dev);
+	module_put(THIS_MODULE);
 	return ret;
 }
 
 static void gennvm_unregister(struct nvm_dev *dev)
 {
 	gennvm_free(dev);
+	module_put(THIS_MODULE);
 }
 
 static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev,
-- 
2.1.4

--
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/

[toc] | [prev] | [next] | [standalone]


#1285748

FromJens Axboe <axboe@fb.com>
Date2015-12-07 17:20 +0100
Message-ID<qD6G7-6S6-45@gated-at.bofh.it>
In reply to#1284841
On Sun, Dec 06 2015, Matias Bjørling wrote:
> Hi Jens,
> 
> A couple more fixes for LightNVM.
> 
> The first three patches are fixed from Tao on rrpc and gennvm. The next
> five patches are small fixes and refactoring to prepare for system
> blocks. The last patch defaults debugging to not be compiled in and
> thereby not expose the parameter configuration interface.
> 
> Thanks! Please pick up when convenient.

Applied for 4.4. Let's ensure that we push new developments to a 4.5
related branch, and only submit for 4.4 what really needs to go into
4.4.

-- 
Jens Axboe

--
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/

[toc] | [prev] | [next] | [standalone]


#1285831

FromMatias Bjørling <m@bjorling.me>
Date2015-12-07 19:00 +0100
Message-ID<qD8eS-7I5-15@gated-at.bofh.it>
In reply to#1285748
On Mon, Dec 7, 2015 at 5:11 PM, Jens Axboe <axboe@fb.com> wrote:
> On Sun, Dec 06 2015, Matias Bjørling wrote:
>> Hi Jens,
>>
>> A couple more fixes for LightNVM.
>>
>> The first three patches are fixed from Tao on rrpc and gennvm. The next
>> five patches are small fixes and refactoring to prepare for system
>> blocks. The last patch defaults debugging to not be compiled in and
>> thereby not expose the parameter configuration interface.
>>
>> Thanks! Please pick up when convenient.
>
> Applied for 4.4. Let's ensure that we push new developments to a 4.5
> related branch, and only submit for 4.4 what really needs to go into
> 4.4.

Thanks Jens. Will do. Already have a couple larger ones queued up wrt
to recovery. :)
--
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/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web