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


Groups > linux.kernel > #1307031

[PATCH 24/25] lightnvm: use system block for mm initialization

From Matias Bjørling <m@bjorling.me>
Newsgroups linux.kernel
Subject [PATCH 24/25] lightnvm: use system block for mm initialization
Date 2016-01-12 08:00 +0100
Message-ID <qQ15W-5F9-43@gated-at.bofh.it> (permalink)
References <qQ15T-5F9-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Use system block information to register the appropriate media manager.
This enables the LightNVM subsystem to instantiate a media manager
selected by the user, instead of relying on automatic detection by each
media manager loaded in the kernel.

A device must now be initialized before it can proceed to initialize its
media manager. Upon initialization, the configured media manager is
automatically initialized as well.

Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 drivers/lightnvm/core.c  | 25 +++++++++++++++++++++++--
 include/linux/lightnvm.h |  3 +++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index ee08fac..9e5712d 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -106,6 +106,9 @@ struct nvmm_type *nvm_init_mgr(struct nvm_dev *dev)
 	lockdep_assert_held(&nvm_lock);
 
 	list_for_each_entry(mt, &nvm_mgrs, list) {
+		if (strncmp(dev->sb.mmtype, mt->name, NVM_MMTYPE_LEN))
+			continue;
+
 		ret = mt->register_mgr(dev);
 		if (ret < 0) {
 			pr_err("nvm: media mgr failed to init (%d) on dev %s\n",
@@ -569,9 +572,16 @@ int nvm_register(struct request_queue *q, char *disk_name,
 		}
 	}
 
+	ret = nvm_get_sysblock(dev, &dev->sb);
+	if (!ret)
+		pr_err("nvm: device not initialized.\n");
+	else if (ret < 0)
+		pr_err("nvm: err (%d) on device initialization\n", ret);
+
 	/* register device with a supported media manager */
 	down_write(&nvm_lock);
-	dev->mt = nvm_init_mgr(dev);
+	if (ret > 0)
+		dev->mt = nvm_init_mgr(dev);
 	list_add(&dev->devices, &nvm_devices);
 	up_write(&nvm_lock);
 
@@ -1030,6 +1040,7 @@ static long __nvm_ioctl_dev_init(struct nvm_ioctl_dev_init *init)
 {
 	struct nvm_dev *dev;
 	struct nvm_sb_info info;
+	int ret;
 
 	down_write(&nvm_lock);
 	dev = nvm_find_nvm_dev(init->dev);
@@ -1044,7 +1055,17 @@ static long __nvm_ioctl_dev_init(struct nvm_ioctl_dev_init *init)
 	strncpy(info.mmtype, init->mmtype, NVM_MMTYPE_LEN);
 	info.fs_ppa.ppa = -1;
 
-	return nvm_init_sysblock(dev, &info);
+	ret = nvm_init_sysblock(dev, &info);
+	if (ret)
+		return ret;
+
+	memcpy(&dev->sb, &info, sizeof(struct nvm_sb_info));
+
+	down_write(&nvm_lock);
+	dev->mt = nvm_init_mgr(dev);
+	up_write(&nvm_lock);
+
+	return 0;
 }
 
 static long nvm_ioctl_dev_init(struct file *file, void __user *arg)
diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h
index 7ad22d3..02f36bd 100644
--- a/include/linux/lightnvm.h
+++ b/include/linux/lightnvm.h
@@ -301,6 +301,9 @@ struct nvm_dev {
 	struct nvmm_type *mt;
 	void *mp;
 
+	/* System blocks */
+	struct nvm_sb_info sb;
+
 	/* Device information */
 	int nr_chnls;
 	int nr_planes;
-- 
2.1.4

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


Thread

[PATCH 00/25] LightNVM patches for 4.5 Matias Bjørling <m@bjorling.me> - 2016-01-12 08:00 +0100
  [PATCH 24/25] lightnvm: use system block for mm initialization Matias Bjørling <m@bjorling.me> - 2016-01-12 08:00 +0100
  [PATCH 03/25] lightnvm: add check after mempool allocation Matias Bjørling <m@bjorling.me> - 2016-01-12 08:00 +0100
  [PATCH 07/25] lightnvm: refactor end_io functions for sync Matias Bjørling <m@bjorling.me> - 2016-01-12 08:00 +0100
  [PATCH 20/25] lightnvm: add mccap support Matias Bjørling <m@bjorling.me> - 2016-01-12 08:00 +0100
  [PATCH 05/25] lightnvm: move ppa erase logic to core Matias Bjørling <m@bjorling.me> - 2016-01-12 08:00 +0100
  [PATCH 09/25] lightnvm: check bi_error in gc Matias Bjørling <m@bjorling.me> - 2016-01-12 08:00 +0100
  [PATCH 22/25] lightnvm: core on-disk initialization Matias Bjørling <m@bjorling.me> - 2016-01-12 08:00 +0100
  Re: [PATCH 00/25] LightNVM patches for 4.5 Jens Axboe <axboe@fb.com> - 2016-01-12 16:20 +0100
    Re: [PATCH 00/25] LightNVM patches for 4.5 Matias Bjorling <m@bjorling.me> - 2016-01-13 01:10 +0100

csiph-web