Support for Open-Channel SSDs
Subsystems (3)
v6 cover Support for Open-Channel SSDs
These patches implement support for Open-Channel SSDs.
Applies against axboe's linux-block/for-4.3/drivers, and can be found in the lkml_v6 branch at https://github.com/OpenChannelSSD/linux
Any feedback is greatly appreciated.
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 RRPC target
lightnvm: Hybrid Open-Channel SSD block manager
null_nvm: Lightnvm test driver
nvme: LightNVM support
MAINTAINERS | 8 + drivers/Kconfig | 2 + drivers/Makefile | 5 + drivers/block/Makefile | 2 +- drivers/block/nvme-core.c | 22 +- drivers/block/nvme-lightnvm.c | 509 ++++++++++++++++++ drivers/lightnvm/Kconfig | 36 ++ drivers/lightnvm/Makefile | 8 + drivers/lightnvm/bm_hb.c | 379 +++++++++++++ drivers/lightnvm/bm_hb.h | 31 ++ drivers/lightnvm/core.c | 580 ++++++++++++++++++++ drivers/lightnvm/null_nvm.c | 420 +++++++++++++++ drivers/lightnvm/rrpc.c | 1190 +++++++++++++++++++++++++++++++++++++++++ drivers/lightnvm/rrpc.h | 220 ++++++++ include/linux/lightnvm.h | 385 +++++++++++++ include/linux/nvme.h | 6 + include/uapi/linux/nvme.h | 3 + 17 files changed, 3802 insertions(+), 4 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
PATCH v6 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>
Jesper Madsen <jmad at itu.dk>
--- MAINTAINERS | 8 + drivers/Kconfig | 2 + drivers/Makefile | 5 + drivers/lightnvm/Kconfig | 16 ++ drivers/lightnvm/Makefile | 5 + drivers/lightnvm/core.c | 580 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/lightnvm.h | 385 ++++++++++++++++++++++++++++++ 7 files changed, 1001 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
MAINTAINERS +8 -0
@@ -6162,6 +6162,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
@@ -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 +5 -0
@@ -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/
@@ -165,3 +169,4 @@ obj-$(CONFIG_RAS) += ras/ obj-$(CONFIG_THUNDERBOLT) += thunderbolt/ obj-$(CONFIG_CORESIGHT) += hwtracing/coresight/ obj-$(CONFIG_ANDROID) += android/ +
drivers/lightnvm/Kconfig new file +16 -0
@@ -0,0 +1,16 @@ +# +# 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. +
drivers/lightnvm/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for Open-Channel SSDs. +# + +obj-$(CONFIG_NVM) := core.o
drivers/lightnvm/core.c new file +580 -0
580 lines not on this page · raw message
include/linux/lightnvm.h new file +385 -0
385 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v6 2/5 lightnvm: Hybrid Open-Channel SSD RRPC target
In reply to Matias BjørlingThis target implements a simple strategy FTL for Open-Channel SSDs. It does round-robin selection across channels and luns. It uses a simple greedy cost-based garbage collector and exposes the physical flash as a block device.
--- drivers/lightnvm/Kconfig | 10 + drivers/lightnvm/Makefile | 1 + drivers/lightnvm/rrpc.c | 1190 +++++++++++++++++++++++++++++++++++++++++++++ drivers/lightnvm/rrpc.h | 220 +++++++++ 4 files changed, 1421 insertions(+) create mode 100644 drivers/lightnvm/rrpc.c create mode 100644 drivers/lightnvm/rrpc.h
drivers/lightnvm/Kconfig +10 -0
@@ -14,3 +14,13 @@ menuconfig NVM 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_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
@@ -3,3 +3,4 @@ # obj-$(CONFIG_NVM) := core.o +obj-$(CONFIG_NVM_RRPC) += rrpc.o
drivers/lightnvm/rrpc.c new file +1190 -0
1,190 lines not on this page · raw message
drivers/lightnvm/rrpc.h new file +220 -0
220 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v6 3/5 lightnvm: Hybrid Open-Channel SSD block manager
In reply to Matias BjørlingThe host implementation for Open-Channel SSDs is divided into block management and targets. This patch implements the block manager for hybrid open-channel SSDs. On top a target, such as rrpc is initialized.
--- drivers/lightnvm/Kconfig | 7 + drivers/lightnvm/Makefile | 1 + drivers/lightnvm/bm_hb.c | 379 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/lightnvm/bm_hb.h | 31 ++++ 4 files changed, 418 insertions(+) create mode 100644 drivers/lightnvm/bm_hb.c create mode 100644 drivers/lightnvm/bm_hb.h
drivers/lightnvm/Kconfig +7 -0
@@ -23,4 +23,11 @@ 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_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
@@ -4,3 +4,4 @@ obj-$(CONFIG_NVM) := core.o obj-$(CONFIG_NVM_RRPC) += rrpc.o +obj-$(CONFIG_NVM_BM_HB) += bm_hb.o
drivers/lightnvm/bm_hb.c new file +379 -0
379 lines not on this page · raw message
drivers/lightnvm/bm_hb.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Copyright: Matias Bjorling <mb at lightnvm.io> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version +* 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +*/ + +#ifndef BM_HB_H_ +#define BM_HB_H_ + +#include <linux/module.h> +#include <linux/vmalloc.h> + +#include <linux/lightnvm.h> + +struct bm_hb { +struct nvm_lun *luns; +}; + +#define bm_for_each_lun (dev, bm, lun, i) \ + for ((i) = 0, lun = &(bm)->luns[0]; \ + (i) < (dev)->nr_luns; (i)++, lun = &(bm)->luns[(i)]) + +#endif /* BM_HB_H_ */
Signature · 1 line
2.1.4
PATCH v6 4/5 null_nvm: Lightnvm test driver
In reply to Matias BjørlingThis 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.
--- drivers/lightnvm/Kconfig | 3 + drivers/lightnvm/Makefile | 1 + drivers/lightnvm/null_nvm.c | 420 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 424 insertions(+) create mode 100644 drivers/lightnvm/null_nvm.c
drivers/lightnvm/Kconfig +3 -0
@@ -30,4 +30,7 @@ config NVM_BM_HB while keeping data placement and garbage collection decisions on the host. +config NVM_NULL_NVM + tristate "Null test LightNVM driver" + endif # NVM
drivers/lightnvm/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-$(CONFIG_NVM) := core.o obj-$(CONFIG_NVM_RRPC) += rrpc.o obj-$(CONFIG_NVM_BM_HB) += bm_hb.o +obj-$(CONFIG_NVM_NULL_NVM) += null_nvm.o
drivers/lightnvm/null_nvm.c new file +420 -0
420 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v6 5/5 nvme: LightNVM support
In reply to Matias BjørlingThe first generation of Open-Channel SSDs will be based on NVMe. The integration requires that a NVMe device exposes itself as a LightNVM device. The way this is done currently is by hooking into the Controller Capabilities (CAP register) and a bit in NSFEAT for each namespace.
After detection, vendor specific codes are used to identify the device and enumerate supported features.
--- drivers/block/Makefile | 2 +- drivers/block/nvme-core.c | 22 +- drivers/block/nvme-lightnvm.c | 509 ++++++++++++++++++++++++++++++++++++++++++ include/linux/nvme.h | 6 + include/uapi/linux/nvme.h | 3 + 5 files changed, 538 insertions(+), 4 deletions(-) create mode 100644 drivers/block/nvme-lightnvm.c
drivers/block/Makefile +1 -1
@@ -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 +19 -3
@@ -40,6 +40,7 @@#include <linux/slab.h> #include <linux/t10-pi.h> #include <linux/types.h> +#include <linux/lightnvm.h> #include <scsi/sg.h> #include <asm-generic/io-64-nonatomic-lo-hi.h>
@@ -1751,7 +1752,8 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev) dev->page_size =1 << page_shift; - dev->ctrl_config =NVME_CC_CSS_NVM ; + dev->ctrl_config =NVME_CAP_LIGHTNVM (cap) ? +NVME_CC_CSS_LIGHTNVM :NVME_CC_CSS_NVM ; dev->ctrl_config |= (page_shift -12 ) <<NVME_CC_MPS_SHIFT ; dev->ctrl_config |=NVME_CC_ARB_RR |NVME_CC_SHN_NONE ; dev->ctrl_config |=NVME_CC_IOSQES |NVME_CC_IOCQES ;
@@ -1997,6 +1999,16 @@ static int nvme_revalidate_disk(struct gendisk *disk)return -ENODEV ; } +if ((dev->ctrl_config &NVME_CC_CSS_LIGHTNVM ) && + id->nsfeat &NVME_NS_FEAT_NVM && ns->type !=NVME_NS_NVM ) { +if (nvme_nvm_register (ns->queue, disk->disk_name)) { +dev_warn (dev->dev, +"%s: LightNVM init failure\n" , __func__); +return -ENODEV ; + } + ns->type =NVME_NS_NVM ; + } + old_ms = ns->ms; lbaf = id->flbas &NVME_NS_FLBAS_LBA_MASK ; ns->lba_shift = id->lbaf[lbaf].ds;
@@ -2028,7 +2040,7 @@ 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_NVM )set_capacity (disk,0 );else set_capacity (disk,le64_to_cpup (&id->nsze) << (ns->lba_shift -9 ));
@@ -2146,7 +2158,8 @@ 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->type !=NVME_NS_NVM ) +add_disk (ns->disk);if (ns->ms) {struct block_device *bd =bdget_disk (ns->disk,0 );if (!bd)
@@ -2345,6 +2358,9 @@ static void nvme_free_namespace(struct nvme_ns *ns) {list_del (&ns->list); +if (ns->type ==NVME_NS_NVM ) +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 +509 -0
509 lines not on this page · raw message
include/linux/nvme.h +6 -0
@@ -19,6 +19,7 @@#include <linux/pci.h> #include <linux/kref.h> #include <linux/blk-mq.h> +#include <linux/lightnvm.h> struct nvme_bar {__u64 cap;/* Controller Capabilities */
@@ -41,6 +42,7 @@ struct nvme_bar {#define NVME_CAP_STRIDE (cap) (((cap) >> 32) & 0xf)#define NVME_CAP_MPSMIN (cap) (((cap) >> 48) & 0xf)#define NVME_CAP_MPSMAX (cap) (((cap) >> 52) & 0xf) +#define NVME_CAP_LIGHTNVM (cap) (((cap) >> 38) & 0x1)#define NVME_CMB_BIR (cmbloc) ((cmbloc) & 0x7)#define NVME_CMB_OFST (cmbloc) (((cmbloc) >> 12) & 0xfffff)
@@ -56,6 +58,7 @@ struct nvme_bar {enum {NVME_CC_ENABLE =1 <<0 ,NVME_CC_CSS_NVM =0 <<4 , +NVME_CC_CSS_LIGHTNVM =1 <<4 ,NVME_CC_MPS_SHIFT =7 ,NVME_CC_ARB_RR =0 <<11 ,NVME_CC_ARB_WRRU =1 <<11 ,
@@ -138,6 +141,7 @@ struct nvme_ns {u16 ms;bool ext;u8 pi_type; +int type;u64 mode_select_num_blocks;u32 mode_select_block_len; };
@@ -184,4 +188,6 @@ 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_register (struct request_queue *q,char *disk_name); +void nvme_nvm_unregister (char *disk_name);#endif /* _LINUX_NVME_H */
include/uapi/linux/nvme.h +3 -0
@@ -130,6 +130,7 @@ struct nvme_id_ns {enum {NVME_NS_FEAT_THIN =1 <<0 , +NVME_NS_FEAT_NVM =1 <<3 ,NVME_NS_FLBAS_LBA_MASK =0xf ,NVME_NS_FLBAS_META_EXT =0x10 ,NVME_LBAF_RP_BEST =0 ,
@@ -146,6 +147,8 @@ enum {NVME_NS_DPS_PI_TYPE1 =1 ,NVME_NS_DPS_PI_TYPE2 =2 ,NVME_NS_DPS_PI_TYPE3 =3 , + + NVME_NS_NVM = 1, }; struct nvme_smart_log {
Signature · 1 line
2.1.4
Re: [PATCH v6 5/5] nvme: LightNVM support
Hi!
Quoted 5 lines
drivers/block/nvme-lightnvm.c new file +5
-0+struct nvme_nvm_hb_rw { +__u8 opcode; +__u8 flags; +__u16 command_id; +__le32 nsid;
drivers/block/nvme-lightnvm.c line 60
Quoted 10 lines
drivers/block/nvme-lightnvm.c new file +10
-0+__u64 rsvd2; +__le64 metadata; +__le64 prp1; +__le64 prp2; +__le64 slba; +__le16 length; +__le16 control; +__le32 dsmgmt; +__le64 phys_addr; +};
You are not exporting this to userland, so you can get rid of "__"s.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v6 5/5] nvme: LightNVM support
Quoted 20 lines · Pavel Machek
Hi!
Quoted 5 lines
drivers/block/nvme-lightnvm.c new file +5
-0+struct nvme_nvm_hb_rw { +__u8 opcode; +__u8 flags; +__u16 command_id; +__le32 nsid;drivers/block/nvme-lightnvm.c line 60
Quoted 10 lines
drivers/block/nvme-lightnvm.c new file +10
-0+__u64 rsvd2; +__le64 metadata; +__le64 prp1; +__le64 prp2; +__le64 slba; +__le16 length; +__le16 control; +__le32 dsmgmt; +__le64 phys_addr; +};You are not exporting this to userland, so you can get rid of "__"s.
Quoted 3 lines
Pavel
Thanks. I will get them removed. It was a leftover for when it was in the nvme uapi header.
Hi Matias,
the architecture looks fine to me. Probab;y not worth merging until your have the multipage I/O sorted out and real hardware, or do you want to aim for fast inclusion?
Quoted 6 lines · Christoph Hellwig
Hi Matias,
the architecture looks fine to me. Probab;y not worth merging until your have the multipage I/O sorted out and real hardware, or do you want to aim for fast inclusion?
Hi Christoph,
The multipage will come in v7. Javier has it flushed out, and we are just going through the last nitpicks on it.
I'll like to get it included. There is some out-of-tree work that is based on it, which requires that the kernel and the modules are compiled together. Having the core part in the kernel will be very helpful.
(resending to the lists. Forgot to put gmail in plain text mode)