From patchwork Fri Sep 4 08:27:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yang Dongsheng X-Patchwork-Id: 7120881 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5E9F6BEEC1 for ; Fri, 4 Sep 2015 08:33:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 670342073D for ; Fri, 4 Sep 2015 08:33:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CB8C20882 for ; Fri, 4 Sep 2015 08:33:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932677AbbIDId1 (ORCPT ); Fri, 4 Sep 2015 04:33:27 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:44487 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753412AbbIDIdV (ORCPT ); Fri, 4 Sep 2015 04:33:21 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208,223";a="100341186" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Sep 2015 16:36:19 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t848X7Ka023082; Fri, 4 Sep 2015 16:33:07 +0800 Received: from [10.167.226.66] (10.167.226.66) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Fri, 4 Sep 2015 16:33:16 +0800 Message-ID: <55E955DF.5020303@cn.fujitsu.com> Date: Fri, 4 Sep 2015 16:27:11 +0800 From: Dongsheng Yang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: =?UTF-8?B?TWF0aWFzIEJqw7hybGluZw==?= , , , , , CC: , , , =?UTF-8?B?TWF0aWFzIEJqw7hybGluZw==?= Subject: Re: [PATCH v7 1/5] lightnvm: Support for Open-Channel SSDs References: <1438957791-24632-1-git-send-email-mb@lightnvm.io> <1438957791-24632-2-git-send-email-mb@lightnvm.io> <55E67218.9010701@cn.fujitsu.com> <55E6D41A.5060100@bjorling.me> <55E94301.3010501@cn.fujitsu.com> <55E950BA.50203@bjorling.me> In-Reply-To: <55E950BA.50203@bjorling.me> X-Originating-IP: [10.167.226.66] Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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 -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