diff mbox

[v7,1/5] lightnvm: Support for Open-Channel SSDs

Message ID 55E955DF.5020303@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yang Dongsheng Sept. 4, 2015, 8:27 a.m. UTC
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",
>
>
>
> .
>

Comments

Matias Bjørling Sept. 4, 2015, 8:49 a.m. UTC | #1
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-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

From 699d279ee0dbf3db5a4e7a78d52fb93e954294a1 Mon Sep 17 00:00:00 2001
From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
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 <yangds.fnst@cn.fujitsu.com>
---
 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 -ENOMEM;
@@ -270,14 +269,13 @@  static int nvme_nvm_get_features(struct request_queue *q,
 						struct nvm_get_features *gf)
 {
 	struct nvme_ns *ns = q->queuedata;
-	struct nvme_nvm_command c = {
-		.common.opcode = nvme_nvm_admin_get_features,
-		.common.nsid = ns->ns_id,
-	};
+	struct nvme_nvm_command c = {};
 	int sz = sizeof(struct nvm_get_features);
 	int ret;
 	u64 *resp;
 
+	c.common.opcode = nvme_nvm_admin_get_features;
+	c.common.nsid = ns->ns_id;
 	resp = kmalloc(sz, GFP_KERNEL);
 	if (!resp)
 		return -ENOMEM;
@@ -297,12 +295,11 @@  done:
 static int nvme_nvm_set_resp(struct request_queue *q, u64 resp)
 {
 	struct nvme_ns *ns = q->queuedata;
-	struct nvme_nvm_command c = {
-		.nvm_resp.opcode = nvme_nvm_admin_set_resp,
-		.nvm_resp.nsid = cpu_to_le32(ns->ns_id),
-		.nvm_resp.resp = cpu_to_le64(resp),
-	};
+	struct nvme_nvm_command c = {};
 
+	c.nvm_resp.opcode = nvme_nvm_admin_set_resp;
+	c.nvm_resp.nsid = cpu_to_le32(ns->ns_id);
+	c.nvm_resp.resp = cpu_to_le64(resp);
 	return nvme_submit_sync_cmd(q, (struct nvme_command *)&c, NULL, 0);
 }
 
@@ -311,16 +308,15 @@  static int nvme_nvm_get_l2p_tbl(struct request_queue *q, u64 slba, u64 nlb,
 {
 	struct nvme_ns *ns = q->queuedata;
 	struct nvme_dev *dev = ns->dev;
-	struct nvme_nvm_command c = {
-		.nvm_l2p.opcode = nvme_nvm_admin_get_l2p_tbl,
-		.nvm_l2p.nsid = cpu_to_le32(ns->ns_id),
-	};
+	struct nvme_nvm_command c = {};
 	u32 len = queue_max_hw_sectors(q) << 9;
 	u64 nlb_pr_rq = len / sizeof(u64);
 	u64 cmd_slba = slba;
 	void *entries;
 	int ret = 0;
 
+	c.nvm_l2p.opcode = nvme_nvm_admin_get_l2p_tbl;
+	c.nvm_l2p.nsid = cpu_to_le32(ns->ns_id);
 	entries = kmalloc(len, GFP_KERNEL);
 	if (!entries)
 		return -ENOMEM;
@@ -365,15 +361,14 @@  static int nvme_nvm_get_bb_tbl(struct request_queue *q, int lunid,
 {
 	struct nvme_ns *ns = q->queuedata;
 	struct nvme_dev *dev = ns->dev;
-	struct nvme_nvm_command c = {
-		.nvm_get_bb.opcode = nvme_nvm_admin_get_bb_tbl,
-		.nvm_get_bb.nsid = cpu_to_le32(ns->ns_id),
-		.nvm_get_bb.lbb = cpu_to_le32(lunid),
-	};
+	struct nvme_nvm_command c = {};
 	void *bb_bitmap;
 	u16 bb_bitmap_size;
 	int ret = 0;
 
+	c.nvm_get_bb.opcode = nvme_nvm_admin_get_bb_tbl;
+	c.nvm_get_bb.nsid = cpu_to_le32(ns->ns_id);
+	c.nvm_get_bb.lbb = cpu_to_le32(lunid);
 	bb_bitmap_size = ((nr_blocks >> 15) + 1) * PAGE_SIZE;
 	bb_bitmap = kmalloc(bb_bitmap_size, GFP_KERNEL);
 	if (!bb_bitmap)
@@ -471,12 +466,11 @@  static int nvme_nvm_submit_io(struct request_queue *q, struct nvm_rq *rqd)
 static int nvme_nvm_erase_block(struct request_queue *q, sector_t block_id)
 {
 	struct nvme_ns *ns = q->queuedata;
-	struct nvme_nvm_command c = {
-		.nvm_erase.opcode = nvme_nvm_cmd_erase,
-		.nvm_erase.nsid = cpu_to_le32(ns->ns_id),
-		.nvm_erase.blk_addr = cpu_to_le64(block_id),
-	};
+	struct nvme_nvm_command c = {};
 
+	c.nvm_erase.opcode = nvme_nvm_cmd_erase;
+	c.nvm_erase.nsid = cpu_to_le32(ns->ns_id);
+	c.nvm_erase.blk_addr = cpu_to_le64(block_id);
 	return nvme_submit_sync_cmd(q, (struct nvme_command *)&c, NULL, 0);
 }
 
-- 
1.8.4.2