Re: [PATCH v7 1/5] lightnvm: Support for Open-Channel SSDs
On 09/04/2015 10:27 AM, Dongsheng Yang wrote: On 09/04/2015 04:05 PM, Matias Bjørling wrote: So here is a suggestion, register_bm again if we found nvm_dev->bm == NULL in create_target(). And if it is still NULL after that. return an error "nvm: no compatible bm was found" and stop target creating. Otherwise, there would be a NULL Pointer reference problem. That's a real problem I met in my testing and I did this change in my local using. I hope that's useful to you. Hi Yang, ac Similar to this? Okey, I attached two changes in my local using. I hope that useful to you. Thanks! Applied and pushed to master. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v7 1/5] lightnvm: Support for Open-Channel SSDs
On 09/04/2015 04:05 PM, Matias Bjørling wrote: So here is a suggestion, register_bm again if we found nvm_dev->bm == NULL in create_target(). And if it is still NULL after that. return an error "nvm: no compatible bm was found" and stop target creating. Otherwise, there would be a NULL Pointer reference problem. That's a real problem I met in my testing and I did this change in my local using. I hope that's useful to you. Hi Yang, ac Similar to this? Okey, I attached two changes in my local using. I hope that useful to you. Yang diff --git i/drivers/lightnvm/core.c w/drivers/lightnvm/core.c index 5e4c2b8..0d2e5e3 100644 --- i/drivers/lightnvm/core.c +++ w/drivers/lightnvm/core.c @@ -262,8 +262,9 @@ int nvm_init(struct nvm_dev *dev) } if (!ret) { - pr_info("nvm: no compatible bm was found.\n"); - return 0; + pr_info("nvm: %s was not initialized due to no compatible bm.\n", + dev->name); + return -EINVAL; } pr_info("nvm: registered %s with luns: %u blocks: %lu sector size: %d\n", . >From 2060232d379328679b22753587d16249f01fa219 Mon Sep 17 00:00:00 2001 From: Dongsheng Yang Date: Fri, 4 Sep 2015 08:10:13 +0900 Subject: [PATCH 2/2] lightNVM: register bm in nvm_create_target if dev->bm is NULL When we create target, we need to make sure dev->bm is not NULL. If it's NULL try to register bm again. If we still fail to find a proper bm for this dev, return error rather than continue to provide a NULL pointer dereference problem later. Signed-off-by: Dongsheng Yang --- drivers/lightnvm/core.c | 20 1 file changed, 20 insertions(+) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 5e4c2b8..9c75ea4 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -293,10 +293,30 @@ static int nvm_create_target(struct nvm_dev *dev, char *ttname, char *tname, int lun_begin, int lun_end) { struct request_queue *tqueue; + struct nvm_bm_type *bt; struct gendisk *tdisk; struct nvm_tgt_type *tt; struct nvm_target *t; void *targetdata; + int ret = 0; + + if (!dev->bm) { + /* register with device with a supported BM */ + list_for_each_entry(bt, &nvm_bms, list) { + ret = bt->register_bm(dev); + if (ret < 0) +return ret; /* initialization failed */ + if (ret > 0) { +dev->bm = bt; +break; /* successfully initialized */ + } + } + + if (!ret) { + pr_info("nvm: no compatible bm was found.\n"); + return -ENODEV; + } + } tt = nvm_find_target_type(ttname); if (!tt) { -- 1.8.4.2 >From 699d279ee0dbf3db5a4e7a78d52fb93e954294a1 Mon Sep 17 00:00:00 2001 From: Dongsheng Yang Date: Mon, 31 Aug 2015 17:22:23 -0400 Subject: [PATCH 1/2] lightNVM: fix a compatibility problem in compiling. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some old gcc version, such as [gcc version 4.4.7 20120313 (Red Hat 4.4.7-4)] there is a compiling error with this kind of code: struct test { union { int data; }; }; int main() { struct test ins = { .data = 1, }; return 0; } # gcc test.c # test.c: In function âmainâ: # test.c:12: error: unknown field âdataâ specified in initializer This patch fix this problem to initialize it in a compatible way. Signed-off-by: Dongsheng Yang --- drivers/block/nvme-lightnvm.c | 58 +++ 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/drivers/block/nvme-lightnvm.c b/drivers/block/nvme-lightnvm.c index 8ad84c9..d1dbc67 100644 --- a/drivers/block/nvme-lightnvm.c +++ b/drivers/block/nvme-lightnvm.c @@ -184,13 +184,13 @@ static int init_chnls(struct request_queue *q, struct nvm_id *nvm_id, struct nvme_nvm_id_chnl *src = nvme_nvm_id->chnls; struct nvm_id_chnl *dst = nvm_id->chnls; struct nvme_ns *ns = q->queuedata; - struct nvme_nvm_command c = { - .nvm_identify.opcode = nvme_nvm_admin_identify, - .nvm_identify.nsid = cpu_to_le32(ns->ns_id), - }; + struct nvme_nvm_command c = {}; unsigned int len = nvm_id->nchannels; int i, end, ret, off = 0; + c.nvm_identify.opcode = nvme_nvm_admin_identify; + c.nvm_identify.nsid = cpu_to_le32(ns->ns_id); + while (len) { end = min_t(u32, NVME_NVM_CHNLS_PR_REQ, len); @@ -230,13 +230,12 @@ static int nvme_nvm_identify(struct request_queue *q, struct nvm_id *nvm_id) { struct nvme_ns *ns = q->queuedata; struct nvme_nvm_id *nvme_nvm_id; - struct nvme_nvm_command c = { - .nvm_identify.opcode = nvme_nvm_admin_identify, - .nvm_identify.nsid = cpu_to_le32(ns->ns_id), - .nvm_identify.chnl_off = 0, - }; + struct nvme_nvm_command c = {}; int ret; + c.nvm_identify.opcode = nvme_nvm_admin_identify; + c.nvm_identify.nsid = cpu_to_le32(ns->ns_id); + c.nvm_identify.chnl_off = 0; nvme_nvm_id = kmalloc(4096, GFP_KERNEL); if (!nvme_nvm_id) return -E
Re: [PATCH v7 1/5] lightnvm: Support for Open-Channel SSDs
So here is a suggestion, register_bm again if we found nvm_dev->bm == NULL in create_target(). And if it is still NULL after that. return an error "nvm: no compatible bm was found" and stop target creating. Otherwise, there would be a NULL Pointer reference problem. That's a real problem I met in my testing and I did this change in my local using. I hope that's useful to you. Hi Yang, Similar to this? diff --git i/drivers/lightnvm/core.c w/drivers/lightnvm/core.c index 5e4c2b8..0d2e5e3 100644 --- i/drivers/lightnvm/core.c +++ w/drivers/lightnvm/core.c @@ -262,8 +262,9 @@ int nvm_init(struct nvm_dev *dev) } if (!ret) { - pr_info("nvm: no compatible bm was found.\n"); - return 0; + pr_info("nvm: %s was not initialized due to no compatible bm.\n", + dev->name); + return -EINVAL; } pr_info("nvm: registered %s with luns: %u blocks: %lu sector size: %d\n", -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v7 1/5] lightnvm: Support for Open-Channel SSDs
On 09/02/2015 06:48 PM, Matias Bjørling wrote: + +/* register with device with a supported BM */ +list_for_each_entry(bt, &nvm_bms, list) { +ret = bt->register_bm(dev); +if (ret < 0) +goto err; /* initialization failed */ +if (ret > 0) { +dev->bm = bt; +break; /* successfully initialized */ +} +} Why just search it from head to tail? Can user specific it in nvm_create_target()? Hi Yang, Currently only the rrpc and a couple of out of tree block managers are built. The register_bm only tries to find a block manager that supports the device, when it finds it, that one is initialized. It is an open question on how we choose the right block manager, e.g. a proprietary and a open-source block manager is in place. Priorities might be a way to go? or mark certain block managers as a catch all? Hopefully we will get away with only a single or two block managers in the future, so we won't have one for each type of device. + +if (!ret) { +pr_info("nvm: no compatible bm was found.\n"); +return 0; +} If we allow nvm_device registered with no bm, we would get a NULL pointer reference problem in later using. Yes, definitely. So here is a suggestion, register_bm again if we found nvm_dev->bm == NULL in create_target(). And if it is still NULL after that. return an error "nvm: no compatible bm was found" and stop target creating. Otherwise, there would be a NULL Pointer reference problem. That's a real problem I met in my testing and I did this change in my local using. I hope that's useful to you. Thanx Yang In the care that happens, I envision it should be possible to register a block manager after a device is loaded, and then any outstanding devices (which does not have a registered block manager), will be probed again. As mentioned above, why we have to choose bm for nvm in nvm_register? Without a block manager, we don't know the structure of the device and how to interact with it. I want to initialize that as soon as possible. So that layers on top can start interacting. Thanx Yang . -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v7 1/5] lightnvm: Support for Open-Channel SSDs
+ +/* register with device with a supported BM */ +list_for_each_entry(bt, &nvm_bms, list) { +ret = bt->register_bm(dev); +if (ret < 0) +goto err; /* initialization failed */ +if (ret > 0) { +dev->bm = bt; +break; /* successfully initialized */ +} +} Why just search it from head to tail? Can user specific it in nvm_create_target()? Hi Yang, Currently only the rrpc and a couple of out of tree block managers are built. The register_bm only tries to find a block manager that supports the device, when it finds it, that one is initialized. It is an open question on how we choose the right block manager, e.g. a proprietary and a open-source block manager is in place. Priorities might be a way to go? or mark certain block managers as a catch all? Hopefully we will get away with only a single or two block managers in the future, so we won't have one for each type of device. + +if (!ret) { +pr_info("nvm: no compatible bm was found.\n"); +return 0; +} If we allow nvm_device registered with no bm, we would get a NULL pointer reference problem in later using. Yes, definitely. In the care that happens, I envision it should be possible to register a block manager after a device is loaded, and then any outstanding devices (which does not have a registered block manager), will be probed again. As mentioned above, why we have to choose bm for nvm in nvm_register? Without a block manager, we don't know the structure of the device and how to interact with it. I want to initialize that as soon as possible. So that layers on top can start interacting. Thanx Yang -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v7 1/5] lightnvm: Support for Open-Channel SSDs
On 08/07/2015 10:29 PM, Matias Bjørling wrote: 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 Jesper Madsen Signed-off-by: Matias Bjørling --- MAINTAINERS | 8 + drivers/Kconfig | 2 + drivers/Makefile | 5 + drivers/lightnvm/Kconfig | 16 ++ drivers/lightnvm/Makefile | 5 + drivers/lightnvm/core.c | 590 ++ include/linux/lightnvm.h | 335 ++ 7 files changed, 961 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 diff --git a/MAINTAINERS b/MAINTAINERS index 2d3d55c..d149104 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6162,6 +6162,14 @@ S: Supported F:drivers/nvdimm/pmem.c F:include/linux/pmem.h +LIGHTNVM PLATFORM SUPPORT +M: Matias Bjorling +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 W:http://www.ibm.com/linux/ltc/projects/ppc diff --git a/drivers/Kconfig b/drivers/Kconfig index 6e973b8..3992902 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -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" diff --git a/drivers/Makefile b/drivers/Makefile index b64b49f..75978ab 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -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/ + diff --git a/drivers/lightnvm/Kconfig b/drivers/lightnvm/Kconfig new file mode 100644 index 000..1f8412c --- /dev/null +++ b/drivers/lightnvm/Kconfig @@ -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. + diff --git a/drivers/lightnvm/Makefile b/drivers/lightnvm/Makefile new file mode 100644 index 000..38185e9 --- /dev/null +++ b/drivers/lightnvm/Makefile @@ -0,0 +1,5 @@ +# +# Makefile for Open-Channel SSDs. +# + +obj-$(CONFIG_NVM) := core.o diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c new file mode 100644 index 000..6499922 --- /dev/null +++ b/drivers/lightnvm/core.c @@ -0,0 +1,590 @@ +/* + * Copyright (C) 2015 IT University of Copenhagen + * Initial release: Matias Bjorling + * + * 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 t
[PATCH v7 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 Jesper Madsen Signed-off-by: Matias Bjørling --- MAINTAINERS | 8 + drivers/Kconfig | 2 + drivers/Makefile | 5 + drivers/lightnvm/Kconfig | 16 ++ drivers/lightnvm/Makefile | 5 + drivers/lightnvm/core.c | 590 ++ include/linux/lightnvm.h | 335 ++ 7 files changed, 961 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 diff --git a/MAINTAINERS b/MAINTAINERS index 2d3d55c..d149104 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6162,6 +6162,14 @@ S: Supported F: drivers/nvdimm/pmem.c F: include/linux/pmem.h +LIGHTNVM PLATFORM SUPPORT +M: Matias Bjorling +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 W: http://www.ibm.com/linux/ltc/projects/ppc diff --git a/drivers/Kconfig b/drivers/Kconfig index 6e973b8..3992902 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -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" diff --git a/drivers/Makefile b/drivers/Makefile index b64b49f..75978ab 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -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/ + diff --git a/drivers/lightnvm/Kconfig b/drivers/lightnvm/Kconfig new file mode 100644 index 000..1f8412c --- /dev/null +++ b/drivers/lightnvm/Kconfig @@ -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. + diff --git a/drivers/lightnvm/Makefile b/drivers/lightnvm/Makefile new file mode 100644 index 000..38185e9 --- /dev/null +++ b/drivers/lightnvm/Makefile @@ -0,0 +1,5 @@ +# +# Makefile for Open-Channel SSDs. +# + +obj-$(CONFIG_NVM) := core.o diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c new file mode 100644 index 000..6499922 --- /dev/null +++ b/drivers/lightnvm/core.c @@ -0,0 +1,590 @@ +/* + * Copyright (C) 2015 IT University of Copenhagen + * Initial release: Matias Bjorling + * + * 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; wi