Skip to contentSkip to conversation

Support for Open-Channel SSDs

PATCH Superseded Matias Bjørling 1 participant 6 messages Sep 21, 2015

Subsystems (4)

v8 of 14 Superseded Latest is v14 →

lore
Share & tools
lore
#0 lore raw

v8 cover Support for Open-Channel SSDs

These patches implement support for Open-Channel SSDs.

Applies against v4.2 and available through the lkml_v8 branch at:

https://github.com/OpenChannelSSD/linux

Major changes from last revision is:

- The NVMe driver is no longer forced to use a non-standard way to detect LightNVM devices. It now uses PCI IDs until the identification method have been standardized. Keith, is this good with you?
- The IOCTL management interface have been created. Devices can now be managed through the lightnvm-adm tool (ladm). This is available from:
https://github.com/OpenChannelSSD/lightnvm-adm.git
- The debugging management interface is now only available if debugging is enabled. (/sys/module/lnvm/parameters/configure_debug)

Any feedback is greatly appreciated.

Changes since v7:
- GCC compatibility fixes (Dongsheng Yang)
- Fix for BM initialization (Dongsheng Yang)
- Fix for error during rrpc init (Javier Gonzalez)
- Refactor NVMe driver to not expect non-standard behavior. Added PCI id identification for selected devices (qemu-nvme and cnex).
- Enable NVMe metadata to be passed from target.
- Create ioctl interface for management.
- Add NVM_DEBUG flag to explicit enable/diskable parameter configure_debug access. The interface is only available if debugging is enabled.
- Add support for physical block address commands.
- Added uapi/lightnvm.h header to expose ioctl interface.
- Fix qemu-nvme initialization extensions regarding L2P translation support.
- Clean up of dead code.
- Updated e-mails, copyrights, etc.

Changes since v6:
- Multipage support (Javier Gonzalez)
- General code cleanups
- Fixed memleak on register failure

Changes since v5:
Feedback from Christoph Hellwig.
- Created new null_nvm from null_blk to register itself as a lightnvm device.
- Changed the interface of register/unregister to only take disk_name. The gendisk alloc in nvme is kept. Most instantiations will involve the device gendisk, therefore wait with refactoring to a later time.
- Renamed global parameters in core.c and rrpc.c

Changes since v4:
- Remove gendisk->nvm dependency
- Remove device driver rq private field dependency.
- Update submission and completion. The flow is now

     Target -> Block Manager -> Device Driver, replacing callbacks in
     device driver.

- Abstracted out the block manager into its own module. Other block managers can now be implemented. For example to support fully host-based SSDs.
- No longer exposes the device driver gendisk to user-space.
- Management is moved into /sys/modules/lnvm/parameters/configure_debug

Changes since v3:

- Remove dependency on REQ_NVM_GC
- Refactor nvme integration to use nvme_submit_sync_cmd for internal commands.
- Fix race condition bug on multiple threads on RRPC target.
- Rename sysfs entry under the block device from nvm to lightnvm. The configuration is found in /sys/block/*/lightnvm/

Changes since v2:

Feedback from Paul Bolle:
- Fix license to GPLv2, documentation, compilation. Feedback from Keith Busch:
- nvme: Move lightnvm out and into nvme-lightnvm.c.
- nvme: Set controller css on lightnvm command set.
- nvme: Remove OACS.
Feedback from Christoph Hellwig:
- lightnvm: Move out of block layer into /drivers/lightnvm/core.c
- lightnvm: refactor request->phys_sector into device drivers.
- lightnvm: refactor prep/unprep into device drivers.
- lightnvm: move nvm_dev from request_queue to gendisk.

New
- Bad block table support (From Javier).
- Update maintainers file.

Changes since v1:

- Splitted LightNVM into two parts. A get/put interface for flash blocks and the respective targets that implement flash translation layer logic.
- Updated the patches according to the LightNVM specification changes.
- Added interface to add/remove targets for a block device.

Thanks to Jens Axboe, Christoph Hellwig, Keith Busch, Paul Bolle, Javier Gonzalez and Jesper Madsen for discussions and contributions.

Matias Bjørling (5):
lightnvm: Support for Open-Channel SSDs
lightnvm: Hybrid Open-Channel SSD block manager
lightnvm: RRPC target
null_nvm: LightNVM test driver
nvme: LightNVM support

 Documentation/ioctl/ioctl-number.txt |    1 +
 MAINTAINERS                          |    8 +
 drivers/Kconfig                      |    2 +
 drivers/Makefile                     |    4 +
 drivers/block/Makefile               |    2 +-
 drivers/block/nvme-core.c            |   38 +-
 drivers/block/nvme-lightnvm.c        |  607 ++++++++++++++++
 drivers/lightnvm/Kconfig             |   48 ++
 drivers/lightnvm/Makefile            |    8 +
 drivers/lightnvm/bm_hb.c             |  372 ++++++++++
 drivers/lightnvm/bm_hb.h             |   46 ++
 drivers/lightnvm/core.c              |  832 ++++++++++++++++++++++
 drivers/lightnvm/null_nvm.c          |  468 ++++++++++++
 drivers/lightnvm/rrpc.c              | 1303 ++++++++++++++++++++++++++++++++++
 drivers/lightnvm/rrpc.h              |  236 ++++++
 include/linux/lightnvm.h             |  350 +++++++++
 include/linux/nvme.h                 |    6 +
 17 files changed, 4319 insertions(+), 12 deletions(-)
 create mode 100644 drivers/block/nvme-lightnvm.c
 create mode 100644 drivers/lightnvm/Kconfig
 create mode 100644 drivers/lightnvm/Makefile
 create mode 100644 drivers/lightnvm/bm_hb.c
 create mode 100644 drivers/lightnvm/bm_hb.h
 create mode 100644 drivers/lightnvm/core.c
 create mode 100644 drivers/lightnvm/null_nvm.c
 create mode 100644 drivers/lightnvm/rrpc.c
 create mode 100644 drivers/lightnvm/rrpc.h
 create mode 100644 include/linux/lightnvm.h
Signature · 1 line
2.1.4
#1 lore raw

PATCH v8 1/5 lightnvm: Support for Open-Channel SSDs

Open-channel SSDs are devices that share responsibilities with the host in order to implement and maintain features that typical SSDs keep strictly in firmware. These include (i) the Flash Translation Layer (FTL), (ii) bad block management, and (iii) hardware units such as the flash controller, the interface controller, and large amounts of flash chips. In this way, Open-channels SSDs exposes direct access to their physical flash storage, while keeping a subset of the internal features of SSDs.

LightNVM is a specification that gives support to Open-channel SSDs LightNVM allows the host to manage data placement, garbage collection, and parallelism. Device specific responsibilities such as bad block management, FTL extensions to support atomic IOs, or metadata persistence are still handled by the device.

The implementation of LightNVM consists of two parts: core and (multiple) targets. The core implements functionality shared across targets. This is initialization, teardown and statistics. The targets implement the interface that exposes physical flash to user-space applications. Examples of such targets include key-value store, object-store, as well as traditional block devices, which can be application-specific.

Contributions in this patch from:

Javier Gonzalez <jg at lightnvm.io>
Dongsheng Yang <yangds.fnst at cn.fujitsu.com>
Jesper Madsen <jmad at itu.dk>

Signed-off-by Matias Bj?rling <m at bjorling.me>
---
 Documentation/ioctl/ioctl-number.txt |   1 +
 MAINTAINERS                          |   8 +
 drivers/Kconfig                      |   2 +
 drivers/Makefile                     |   4 +
 drivers/lightnvm/Kconfig             |  28 ++
 drivers/lightnvm/Makefile            |   5 +
 drivers/lightnvm/core.c              | 832 +++++++++++++++++++++++++++++++++++
 include/linux/lightnvm.h             | 350 +++++++++++++++
 8 files changed, 1230 insertions(+)
 create mode 100644 drivers/lightnvm/Kconfig
 create mode 100644 drivers/lightnvm/Makefile
 create mode 100644 drivers/lightnvm/core.c
 create mode 100644 include/linux/lightnvm.h
Documentation/ioctl/ioctl-number.txt +1 -0
index 611c522..df53920 100644
@@ -147,6 +147,7 @@ Code  Seq#(hex)	Include File		Comments
 'K'	all	linux/kd.h
 'L'	00-1F	linux/loop.h		conflict!
 'L'	10-1F	drivers/scsi/mpt2sas/mpt2sas_ctl.h	conflict!
+'L'	20-2F	linux/lightnvm.h
 'L'	E0-FF	linux/ppdd.h		encrypted disk device driver
 					<http://linux01.gwdg.de/~alatham/ppdd.html>
 'M'	all	linux/soundcard.h	conflict!
MAINTAINERS +8 -0
index b60e2b2..2bfb4e4 100644
@@ -6176,6 +6176,14 @@ S:	Supported
 F:	drivers/nvdimm/pmem.c
 F:	include/linux/pmem.h
 
+LIGHTNVM PLATFORM SUPPORT
+M:	Matias Bjorling <mb at lightnvm.io>
+W:	http://github/OpenChannelSSD
+S:	Maintained
+F:	drivers/lightnvm/
+F:	include/linux/lightnvm.h
+F:	include/uapi/linux/lightnvm.h
+
 LINUX FOR IBM pSERIES (RS/6000)
 M:	Paul Mackerras <paulus at au.ibm.com>
 W:	http://www.ibm.com/linux/ltc/projects/ppc
drivers/Kconfig +2 -0
index 6e973b8..3992902 100644
@@ -42,6 +42,8 @@ source "drivers/net/Kconfig"
 
 source "drivers/isdn/Kconfig"
 
+source "drivers/lightnvm/Kconfig"
+
 # input before char - char/joystick depends on it. As does USB.
 
 source "drivers/input/Kconfig"
drivers/Makefile +4 -0
index b64b49f..1a3ca98 100644
@@ -63,6 +63,10 @@ obj-$(CONFIG_FB_I810)           += video/fbdev/i810/
 obj-$(CONFIG_FB_INTEL)          += video/fbdev/intelfb/
 
 obj-$(CONFIG_PARPORT)		+= parport/
+
+# lightnvm/ comes before block to initialize bm before usage
+obj-$(CONFIG_NVM)		+= lightnvm/
+
 obj-y				+= base/ block/ misc/ mfd/ nfc/
 obj-$(CONFIG_LIBNVDIMM)		+= nvdimm/
 obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf/
drivers/lightnvm/Kconfig new file +28 -0
new file mode 100644
index 0000000..d4f309f
@@ -0,0 +1,28 @@
+#
+# Open-Channel SSD NVM configuration
+#
+
+menuconfig NVM
+	bool "Open-Channel SSD target support"
+	depends on BLOCK
+	help
+	  Say Y here to get to enable Open-channel SSDs.
+
+	  Open-Channel SSDs implement a set of extension to SSDs, that
+	  exposes direct access to the underlying non-volatile memory.
+
+	  If you say N, all options in this submenu will be skipped and disabled
+	  only do this if you know what you are doing.
+
+if NVM
+
+config NVM_DEBUG
+	bool "Open-Channel SSD debugging support"
+	---help---
+	Exposes a debug management interface to create/remove targets at:
+
+	  /sys/module/lnvm/parameters/configure_debug
+
+	It is required to create/remove targets without IOCTLs.
+
+endif # NVM
drivers/lightnvm/Makefile new file +5 -0
new file mode 100644
index 0000000..38185e9
@@ -0,0 +1,5 @@
+#
+# Makefile for Open-Channel SSDs.
+#
+
+obj-$(CONFIG_NVM)		:= core.o
drivers/lightnvm/core.c new file +832 -0

832 lines not on this page · raw message

include/linux/lightnvm.h new file +350 -0

350 lines not on this page · raw message

Signature · 1 line
2.1.4
#2 lore raw

PATCH v8 2/5 lightnvm: Hybrid Open-Channel SSD block manager

In reply to Matias Bjørling

The host implementation for Open-Channel SSDs is divided into block management and targets. This patch implements a basic block manager hybrid open-channel SSDs. On top of the block manager, a target can be initialized.

---
 drivers/lightnvm/Kconfig  |   7 +
 drivers/lightnvm/Makefile |   1 +
 drivers/lightnvm/bm_hb.c  | 372 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/lightnvm/bm_hb.h  |  46 ++++++
 4 files changed, 426 insertions(+)
 create mode 100644 drivers/lightnvm/bm_hb.c
 create mode 100644 drivers/lightnvm/bm_hb.h
drivers/lightnvm/Kconfig +7 -0
index d4f309f..15e507a 100644
@@ -25,4 +25,11 @@ config NVM_DEBUG
 
 	It is required to create/remove targets without IOCTLs.
 
+config NVM_BM_HB
+	tristate "Block manager for Hybrid Open-Channel SSD"
+	---help---
+	Block manager for SSDs that offload block management off to the device,
+	while keeping data placement and garbage collection decisions on the
+	host.
+
 endif # NVM
drivers/lightnvm/Makefile +1 -0
index 38185e9..5228f83 100644
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_NVM)		:= core.o
+obj-$(CONFIG_NVM_BM_HB) 	+= bm_hb.o
drivers/lightnvm/bm_hb.c new file +372 -0

372 lines not on this page · raw message

drivers/lightnvm/bm_hb.h new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
2.1.4
#3 lore raw

PATCH v8 3/5 lightnvm: RRPC target

In reply to Matias Bjørling

This target exposes an Open-Channel SSD as a block device.

It implements a round-robin approach for sector allocation, together with a greedy cost-based garbage collector.

---
 drivers/lightnvm/Kconfig  |    7 +
 drivers/lightnvm/Makefile |    1 +
 drivers/lightnvm/rrpc.c   | 1303 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/lightnvm/rrpc.h   |  236 ++++++++
 4 files changed, 1547 insertions(+)
 create mode 100644 drivers/lightnvm/rrpc.c
 create mode 100644 drivers/lightnvm/rrpc.h
drivers/lightnvm/Kconfig +7 -0
index 15e507a..21a271e 100644
@@ -32,4 +32,11 @@ config NVM_BM_HB
 	while keeping data placement and garbage collection decisions on the
 	host.
 
+config NVM_RRPC
+	tristate "Round-robin Hybrid Open-Channel SSD target"
+	---help---
+	Allows an open-channel SSD to be exposed as a block device to the
+	host. The target is implemented using a linear mapping table and
+	cost-based garbage collection. It is optimized for 4K IO sizes.
+
 endif # NVM
drivers/lightnvm/Makefile +1 -0
index 5228f83..1b7c00b 100644
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_NVM)		:= core.o
 obj-$(CONFIG_NVM_BM_HB) 	+= bm_hb.o
+obj-$(CONFIG_NVM_RRPC)		+= rrpc.o
drivers/lightnvm/rrpc.c new file +1303 -0

1,303 lines not on this page · raw message

drivers/lightnvm/rrpc.h new file +236 -0

236 lines not on this page · raw message

Signature · 1 line
2.1.4
#4 lore raw

PATCH v8 4/5 null_nvm: LightNVM test driver

In reply to Matias Bjørling

This driver implements the I/O flow for a LightNVM device driver. It does no transfers. It can be used to test setup/teardown of devices and evaluating performance of block managers and targets.

The framework of the driver is derived from the null_blk module.

Signed-off-by Matias Bj?rling <m at bjorling.me>
---
 drivers/lightnvm/Kconfig    |   6 +
 drivers/lightnvm/Makefile   |   1 +
 drivers/lightnvm/null_nvm.c | 468 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 475 insertions(+)
 create mode 100644 drivers/lightnvm/null_nvm.c
drivers/lightnvm/Kconfig +6 -0
index 21a271e..d34ba6a 100644
@@ -39,4 +39,10 @@ config NVM_RRPC
 	host. The target is implemented using a linear mapping table and
 	cost-based garbage collection. It is optimized for 4K IO sizes.
 
+config NVM_NULL_NVM
+	tristate "Null test LightNVM driver"
+	---help---
+	The null test driver can be used to evaluate targets without an
+	underlying device.
+
 endif # NVM
drivers/lightnvm/Makefile +1 -0
index 1b7c00b..145ee5d 100644
@@ -5,3 +5,4 @@
 obj-$(CONFIG_NVM)		:= core.o
 obj-$(CONFIG_NVM_BM_HB) 	+= bm_hb.o
 obj-$(CONFIG_NVM_RRPC)		+= rrpc.o
+obj-$(CONFIG_NVM_NULL_NVM)	+= null_nvm.o
drivers/lightnvm/null_nvm.c new file +468 -0

468 lines not on this page · raw message

Signature · 1 line
2.1.4
#5 lore raw

PATCH v8 5/5 nvme: LightNVM support

In reply to Matias Bjørling

The first generation of Open-Channel SSDs will be based on NVMe. The integration requires that a NVMe device register itself as a LightNVM device.

The detection is through PCI IDs. The current supported are the qemu nvme simulator and CNEX Labs Westlake SSD. The qemu nvme enables support through vendor specific bits in the namespace identification and the CNEX card is configured for LightNVM upon boot and does not need detection other than PCI id.

After detection, vendor specific codes are used to identify the device and enumerate supported features.

Signed-off-by Javier Gonz?lez <jg at lightnvm.io>
Signed-off-by Matias Bj?rling <m at bjorling.me>
---
 drivers/block/Makefile        |   2 +-
 drivers/block/nvme-core.c     |  38 ++-
 drivers/block/nvme-lightnvm.c | 607 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/nvme.h          |   6 +
 4 files changed, 641 insertions(+), 12 deletions(-)
 create mode 100644 drivers/block/nvme-lightnvm.c
drivers/block/Makefile +1 -1
index 02b688d..a01d7d8 100644
@@ -44,6 +44,6 @@ obj-$(CONFIG_BLK_DEV_RSXX) += rsxx/
 obj-$(CONFIG_BLK_DEV_NULL_BLK)	+= null_blk.o
 obj-$(CONFIG_ZRAM) += zram/
 
-nvme-y		:= nvme-core.o nvme-scsi.o
+nvme-y		:= nvme-core.o nvme-scsi.o nvme-lightnvm.o
 skd-y		:= skd_main.o
 swim_mod-y	:= swim.o swim_asm.o
drivers/block/nvme-core.c +27 -11
index 7920c27..0d7334f 100644
@@ -1958,6 +1958,16 @@ static int nvme_revalidate_disk(struct gendisk *disk)
 		return -ENODEV;
 	}
 
+	if (nvme_nvm_ns_supported(ns, id) && ns->type != NVME_NS_LIGHTNVM) {
+		if (nvme_nvm_register(ns->queue, disk->disk_name)) {
+			dev_warn(dev->dev,
+				    "%s: LightNVM init failure\n", __func__);
+			kfree(id);
+			return -ENODEV;
+		}
+		ns->type = NVME_NS_LIGHTNVM;
+	}
+
 	old_ms = ns->ms;
 	lbaf = id->flbas & NVME_NS_FLBAS_LBA_MASK;
 	ns->lba_shift = id->lbaf[lbaf].ds;
@@ -1989,7 +1999,8 @@ static int nvme_revalidate_disk(struct gendisk *disk)
 								!ns->ext)
 		nvme_init_integrity(ns);
 
-	if (ns->ms && !blk_get_integrity(disk))
+	if ((ns->ms && !blk_get_integrity(disk))
+						|| ns->type == NVME_NS_LIGHTNVM)
 		set_capacity(disk, 0);
 	else
 		set_capacity(disk, le64_to_cpup(&id->nsze) << (ns->lba_shift - 9));
@@ -2107,17 +2118,19 @@ static void nvme_alloc_ns(struct nvme_dev *dev, unsigned nsid)
 	if (nvme_revalidate_disk(ns->disk))
 		goto out_free_disk;
 
-	add_disk(ns->disk);
-	if (ns->ms) {
-		struct block_device *bd = bdget_disk(ns->disk, 0);
-		if (!bd)
-			return;
-		if (blkdev_get(bd, FMODE_READ, NULL)) {
-			bdput(bd);
-			return;
+	if (ns->type != NVME_NS_LIGHTNVM) {
+		add_disk(ns->disk);
+		if (ns->ms) {
+			struct block_device *bd = bdget_disk(ns->disk, 0);
+			if (!bd)
+				return;
+			if (blkdev_get(bd, FMODE_READ, NULL)) {
+				bdput(bd);
+				return;
+			}
+			blkdev_reread_part(bd);
+			blkdev_put(bd, FMODE_READ);
 		}
-		blkdev_reread_part(bd);
-		blkdev_put(bd, FMODE_READ);
 	}
 	return;
  out_free_disk:
@@ -2245,6 +2258,9 @@ static void nvme_free_namespace(struct nvme_ns *ns)
 {
 	list_del(&ns->list);
 
+	if (ns->type == NVME_NS_LIGHTNVM)
+		nvme_nvm_unregister(ns->disk->disk_name);
+
 	spin_lock(&dev_list_lock);
 	ns->disk->private_data = NULL;
 	spin_unlock(&dev_list_lock);
drivers/block/nvme-lightnvm.c new file +607 -0

607 lines not on this page · raw message

include/linux/nvme.h +6 -0
index c0d94ed..17a2f3c 100644
@@ -59,6 +59,8 @@ enum {
 	NVME_CSTS_SHST_OCCUR	= 1 << 2,
 	NVME_CSTS_SHST_CMPLT	= 2 << 2,
 	NVME_CSTS_SHST_MASK	= 3 << 2,
+
+	NVME_NS_LIGHTNVM	= 1,
 };
 
 extern unsigned char nvme_io_timeout;
@@ -121,6 +123,7 @@ struct nvme_ns {
 	u16 ms;
 	bool ext;
 	u8 pi_type;
+	int type;
 	u64 mode_select_num_blocks;
 	u32 mode_select_block_len;
 };
@@ -167,4 +170,7 @@ int nvme_sg_io(struct nvme_ns *ns, struct sg_io_hdr __user *u_hdr);
 int nvme_sg_io32(struct nvme_ns *ns, unsigned long arg);
 int nvme_sg_get_version_num(int __user *ip);
 
+int nvme_nvm_ns_supported(struct nvme_ns *ns, struct nvme_id_ns *id);
+int nvme_nvm_register(struct request_queue *q, char *disk_name);
+void nvme_nvm_unregister(char *disk_name);
 #endif /* _LINUX_NVME_H */
Signature · 1 line
2.1.4