From patchwork Wed Feb 21 09:26:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= X-Patchwork-Id: 10231663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E8E760209 for ; Wed, 21 Feb 2018 09:31:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D0F428AA6 for ; Wed, 21 Feb 2018 09:31:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0176F28AAA; Wed, 21 Feb 2018 09:31:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1450F28AA6 for ; Wed, 21 Feb 2018 09:31:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932444AbeBUJbL (ORCPT ); Wed, 21 Feb 2018 04:31:11 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:43387 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753292AbeBUJ1Q (ORCPT ); Wed, 21 Feb 2018 04:27:16 -0500 Received: by mail-wr0-f196.google.com with SMTP id u49so2421969wrc.10 for ; Wed, 21 Feb 2018 01:27:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p1ip1H7L+3BC4MsPeZdNN88R2NS8r67L8ksSQsWxLO4=; b=k5B0SFQbPQLdyN76VhIdKPgLglmekXHDaJ5oxbSw8BoV5gTxzHAUCqcMe3a4ffEdqL wU4jpd17iYfR6gRNvEDKJstK0JiatJpF4vHRSuy6bBvo0uYKg7BMPthIc5RZm6UYJK/8 I8iZ2W9ZsNpHEXdSXpEOGp8WCFkh5PdXrGXoDF4Z7jBG2/dfHVRzTNg8Ba0gw9WjuoJu WtaLy7vAXb/gEMV0u2C2m9ZELCgilE/XSRxzWgwBlKF2iXcxPeX9oGwj87Ayptm2y/d1 uABMZSfpRpsFrJe/EAqWCswpxYJ3NHk0fX6NXEbzddRAPtASTf4s7ms3DgBA8O38Vffx oq8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p1ip1H7L+3BC4MsPeZdNN88R2NS8r67L8ksSQsWxLO4=; b=o+rxx6HJQ5IBeYYs5/pRg+LUmHNLitZvYu+Jnwq+zXoapPNa+Ce96kGqKqXGbE+3ir L+POp1ZUGg/VCPJi1GYs2GeldUCgd5PoQw7BZwawNJz7+OymfE2rFmll869Vk0g6RjhX O4ADlb6VZTWHuS7Jlt/INKvEvMI2ijjO7V1owpq5N/pJL7ppoc8qFohgYcIa0PCxwiC7 OgaXr8RSdQQoqymCmFSZQnbQyCh8p9TCdj6iCl0g5N84i44OfMQdm3Ot0rJLz87wqfQ5 J7rlTNIvk+ZRVnVlpsuq5La6ErzM5dR+W7tMBmwz0CDH0vdjk4MuYtP/ttxmUSwEy4oH 8nJA== X-Gm-Message-State: APf1xPBxMYEwwTkJ0epi2J7URNSkBLXFLeZV8yLu4ddPWL5SljAbbuK2 bIBTl7mIIv4EJlxYriCHPRPqbr7V X-Google-Smtp-Source: AH8x226Y5sokNqRqkOunE8D90X0hxaXnKz+pQrEss+fl0vDwXjd/ChUDBsF027PlryvGQ2K4PZYD7Q== X-Received: by 10.80.171.78 with SMTP id t14mr4080764edc.170.1519205234905; Wed, 21 Feb 2018 01:27:14 -0800 (PST) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id a17sm3389955eda.42.2018.02.21.01.27.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Feb 2018 01:27:14 -0800 (PST) From: "=?UTF-8?q?Javier=20Gonz=C3=A1lez?=" X-Google-Original-From: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= To: mb@lightnvm.io Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= Subject: [PATCH 05/20] lightnvm: rename number of channels and luns Date: Wed, 21 Feb 2018 10:26:43 +0100 Message-Id: <1519205218-26994-6-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519205218-26994-1-git-send-email-javier@cnexlabs.com> References: <1519205218-26994-1-git-send-email-javier@cnexlabs.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Normalize nomenclature for naming number of channels and number of luns in order to improve readability. Use num_ch and num_lun. Signed-off-by: Javier González --- drivers/lightnvm/core.c | 69 ++++++++++++++++++++++---------------------- drivers/lightnvm/pblk-core.c | 4 +-- drivers/lightnvm/pblk-init.c | 16 +++++----- drivers/lightnvm/pblk.h | 6 ++-- drivers/nvme/host/lightnvm.c | 20 ++++++------- include/linux/lightnvm.h | 8 ++--- 6 files changed, 61 insertions(+), 62 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index dc9ec6baff45..f70a907223e2 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -36,13 +36,13 @@ static DECLARE_RWSEM(nvm_lock); /* Map between virtual and physical channel and lun */ struct nvm_ch_map { int ch_off; - int nr_luns; + int num_lun; int *lun_offs; }; struct nvm_dev_map { struct nvm_ch_map *chnls; - int nr_chnls; + int num_ch; }; static struct nvm_target *nvm_find_target(struct nvm_dev *dev, const char *name) @@ -115,15 +115,15 @@ static void nvm_remove_tgt_dev(struct nvm_tgt_dev *tgt_dev, int clear) struct nvm_dev_map *dev_map = tgt_dev->map; int i, j; - for (i = 0; i < dev_map->nr_chnls; i++) { + for (i = 0; i < dev_map->num_ch; i++) { struct nvm_ch_map *ch_map = &dev_map->chnls[i]; int *lun_offs = ch_map->lun_offs; int ch = i + ch_map->ch_off; if (clear) { - for (j = 0; j < ch_map->nr_luns; j++) { + for (j = 0; j < ch_map->num_lun; j++) { int lun = j + lun_offs[j]; - int lunid = (ch * dev_geo->nr_luns) + lun; + int lunid = (ch * dev_geo->num_lun) + lun; WARN_ON(!test_and_clear_bit(lunid, dev->lun_map)); @@ -149,47 +149,46 @@ static struct nvm_tgt_dev *nvm_create_tgt_dev(struct nvm_dev *dev, struct nvm_dev_map *dev_rmap = dev->rmap; struct nvm_dev_map *dev_map; struct ppa_addr *luns; - int nr_luns = lun_end - lun_begin + 1; - int luns_left = nr_luns; - int nr_chnls = nr_luns / dev_geo->nr_luns; - int nr_chnls_mod = nr_luns % dev_geo->nr_luns; - int bch = lun_begin / dev_geo->nr_luns; - int blun = lun_begin % dev_geo->nr_luns; + int num_lun = lun_end - lun_begin + 1; + int luns_left = num_lun; + int num_ch = num_lun / dev_geo->num_lun; + int num_ch_mod = num_lun % dev_geo->num_lun; + int bch = lun_begin / dev_geo->num_lun; + int blun = lun_begin % dev_geo->num_lun; int lunid = 0; int lun_balanced = 1; - int sec_per_lun, prev_nr_luns; + int sec_per_lun, prev_num_lun; int i, j; - nr_chnls = (nr_chnls_mod == 0) ? nr_chnls : nr_chnls + 1; + num_ch = (num_ch_mod == 0) ? num_ch : num_ch + 1; dev_map = kmalloc(sizeof(struct nvm_dev_map), GFP_KERNEL); if (!dev_map) goto err_dev; - dev_map->chnls = kcalloc(nr_chnls, sizeof(struct nvm_ch_map), - GFP_KERNEL); + dev_map->chnls = kcalloc(num_ch, sizeof(struct nvm_ch_map), GFP_KERNEL); if (!dev_map->chnls) goto err_chnls; - luns = kcalloc(nr_luns, sizeof(struct ppa_addr), GFP_KERNEL); + luns = kcalloc(num_lun, sizeof(struct ppa_addr), GFP_KERNEL); if (!luns) goto err_luns; - prev_nr_luns = (luns_left > dev_geo->nr_luns) ? - dev_geo->nr_luns : luns_left; - for (i = 0; i < nr_chnls; i++) { + prev_num_lun = (luns_left > dev_geo->num_lun) ? + dev_geo->num_lun : luns_left; + for (i = 0; i < num_ch; i++) { struct nvm_ch_map *ch_rmap = &dev_rmap->chnls[i + bch]; int *lun_roffs = ch_rmap->lun_offs; struct nvm_ch_map *ch_map = &dev_map->chnls[i]; int *lun_offs; - int luns_in_chnl = (luns_left > dev_geo->nr_luns) ? - dev_geo->nr_luns : luns_left; + int luns_in_chnl = (luns_left > dev_geo->num_lun) ? + dev_geo->num_lun : luns_left; - if (lun_balanced && prev_nr_luns != luns_in_chnl) + if (lun_balanced && prev_num_lun != luns_in_chnl) lun_balanced = 0; ch_map->ch_off = ch_rmap->ch_off = bch; - ch_map->nr_luns = luns_in_chnl; + ch_map->num_lun = luns_in_chnl; lun_offs = kcalloc(luns_in_chnl, sizeof(int), GFP_KERNEL); if (!lun_offs) @@ -211,22 +210,22 @@ static struct nvm_tgt_dev *nvm_create_tgt_dev(struct nvm_dev *dev, luns_left -= luns_in_chnl; } - dev_map->nr_chnls = nr_chnls; + dev_map->num_ch = num_ch; tgt_dev = kmalloc(sizeof(struct nvm_tgt_dev), GFP_KERNEL); if (!tgt_dev) goto err_ch; /* Target device only owns a portion of the physical device */ - tgt_dev->geo.nr_chnls = nr_chnls; - tgt_dev->geo.nr_luns = (lun_balanced) ? prev_nr_luns : -1; - tgt_dev->geo.all_luns = nr_luns; - tgt_dev->geo.all_chunks = nr_luns * dev_geo->c.num_chk; + tgt_dev->geo.num_ch = num_ch; + tgt_dev->geo.num_lun = (lun_balanced) ? prev_num_lun : -1; + tgt_dev->geo.all_luns = num_lun; + tgt_dev->geo.all_chunks = num_lun * dev_geo->c.num_chk; tgt_dev->geo.op = op; sec_per_lun = dev_geo->c.clba * dev_geo->c.num_chk; - tgt_dev->geo.total_secs = nr_luns * sec_per_lun; + tgt_dev->geo.total_secs = num_lun * sec_per_lun; tgt_dev->geo.c = dev_geo->c; @@ -511,20 +510,20 @@ static int nvm_register_map(struct nvm_dev *dev) if (!rmap) goto err_rmap; - rmap->chnls = kcalloc(dev_geo->nr_chnls, sizeof(struct nvm_ch_map), + rmap->chnls = kcalloc(dev_geo->num_ch, sizeof(struct nvm_ch_map), GFP_KERNEL); if (!rmap->chnls) goto err_chnls; - for (i = 0; i < dev_geo->nr_chnls; i++) { + for (i = 0; i < dev_geo->num_ch; i++) { struct nvm_ch_map *ch_rmap; int *lun_roffs; - int luns_in_chnl = dev_geo->nr_luns; + int luns_in_chnl = dev_geo->num_lun; ch_rmap = &rmap->chnls[i]; ch_rmap->ch_off = -1; - ch_rmap->nr_luns = luns_in_chnl; + ch_rmap->num_lun = luns_in_chnl; lun_roffs = kcalloc(luns_in_chnl, sizeof(int), GFP_KERNEL); if (!lun_roffs) @@ -554,7 +553,7 @@ static void nvm_unregister_map(struct nvm_dev *dev) struct nvm_dev_map *rmap = dev->rmap; int i; - for (i = 0; i < dev_geo->nr_chnls; i++) + for (i = 0; i < dev_geo->num_ch; i++) kfree(rmap->chnls[i].lun_offs); kfree(rmap->chnls); @@ -910,7 +909,7 @@ static int nvm_init(struct nvm_dev *dev) pr_info("nvm: registered %s [%u/%u/%u/%u/%u]\n", dev->name, dev_geo->c.ws_min, dev_geo->c.ws_opt, dev_geo->c.num_chk, dev_geo->all_luns, - dev_geo->nr_chnls); + dev_geo->num_ch); return 0; err: pr_err("nvm: failed to initialize nvm\n"); diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index 519af8b9eab7..7c726003a8d2 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -1752,10 +1752,10 @@ void pblk_up_rq(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas, struct nvm_tgt_dev *dev = pblk->dev; struct nvm_geo *geo = &dev->geo; struct pblk_lun *rlun; - int nr_luns = geo->all_luns; + int num_lun = geo->all_luns; int bit = -1; - while ((bit = find_next_bit(lun_bitmap, nr_luns, bit + 1)) < nr_luns) { + while ((bit = find_next_bit(lun_bitmap, num_lun, bit + 1)) < num_lun) { rlun = &pblk->luns[bit]; up(&rlun->wr_sem); } diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index 95ecb0ec736b..455fc63a9409 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -162,15 +162,15 @@ static int pblk_set_addrf_12(struct nvm_geo *geo, int power_len; /* Re-calculate channel and lun format to adapt to configuration */ - power_len = get_count_order(geo->nr_chnls); - if (1 << power_len != geo->nr_chnls) { + power_len = get_count_order(geo->num_ch); + if (1 << power_len != geo->num_ch) { pr_err("pblk: supports only power-of-two channel config.\n"); return -EINVAL; } dst->ch_len = power_len; - power_len = get_count_order(geo->nr_luns); - if (1 << power_len != geo->nr_luns) { + power_len = get_count_order(geo->num_lun); + if (1 << power_len != geo->num_lun) { pr_err("pblk: supports only power-of-two LUN config.\n"); return -EINVAL; } @@ -498,7 +498,7 @@ static int pblk_luns_init(struct pblk *pblk, struct ppa_addr *luns) int i; /* TODO: Implement unbalanced LUN support */ - if (geo->nr_luns < 0) { + if (geo->num_lun < 0) { pr_err("pblk: unbalanced LUN config.\n"); return -EINVAL; } @@ -510,9 +510,9 @@ static int pblk_luns_init(struct pblk *pblk, struct ppa_addr *luns) for (i = 0; i < geo->all_luns; i++) { /* Stripe across channels */ - int ch = i % geo->nr_chnls; - int lun_raw = i / geo->nr_chnls; - int lunid = lun_raw + ch * geo->nr_luns; + int ch = i % geo->num_ch; + int lun_raw = i / geo->num_ch; + int lunid = lun_raw + ch * geo->num_lun; rlun = &pblk->luns[i]; rlun->bppa = luns[lunid]; diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index 67ffb53608f7..1f32284b0aec 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -941,7 +941,7 @@ static inline int pblk_ppa_to_line(struct ppa_addr p) static inline int pblk_ppa_to_pos(struct nvm_geo *geo, struct ppa_addr p) { - return p.g.lun * geo->nr_chnls + p.g.ch; + return p.g.lun * geo->num_ch + p.g.ch; } static inline struct ppa_addr addr_to_gen_ppa(struct pblk *pblk, u64 paddr, @@ -1214,8 +1214,8 @@ static inline int pblk_boundary_ppa_checks(struct nvm_tgt_dev *tgt_dev, ppa = &ppas[i]; if (!ppa->c.is_cached && - ppa->g.ch < geo->nr_chnls && - ppa->g.lun < geo->nr_luns && + ppa->g.ch < geo->num_ch && + ppa->g.lun < geo->num_lun && ppa->g.pl < geo->c.num_pln && ppa->g.blk < geo->c.num_chk && ppa->g.pg < geo->c.num_pg && diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index 71b4ac57a668..f22331e61cef 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -299,9 +299,9 @@ static int nvme_nvm_setup_12(struct nvme_nvm_id12 *id, dev_geo->major_ver_id = id->ver_id; dev_geo->minor_ver_id = 2; - dev_geo->nr_chnls = src->num_ch; - dev_geo->nr_luns = src->num_lun; - dev_geo->all_luns = dev_geo->nr_chnls * dev_geo->nr_luns; + dev_geo->num_ch = src->num_ch; + dev_geo->num_lun = src->num_lun; + dev_geo->all_luns = dev_geo->num_ch * dev_geo->num_lun; dev_geo->c.num_chk = le16_to_cpu(src->num_chk); dev_geo->c.csecs = le16_to_cpu(src->csecs); @@ -387,9 +387,9 @@ static int nvme_nvm_setup_20(struct nvme_nvm_id20 *id, return -EINVAL; } - dev_geo->nr_chnls = le16_to_cpu(id->num_grp); - dev_geo->nr_luns = le16_to_cpu(id->num_pu); - dev_geo->all_luns = dev_geo->nr_chnls * dev_geo->nr_luns; + dev_geo->num_ch = le16_to_cpu(id->num_grp); + dev_geo->num_lun = le16_to_cpu(id->num_pu); + dev_geo->all_luns = dev_geo->num_ch * dev_geo->num_lun; dev_geo->c.num_chk = le32_to_cpu(id->num_chk); dev_geo->c.clba = le32_to_cpu(id->clba); @@ -980,9 +980,9 @@ static ssize_t nvm_dev_attr_show_12(struct device *dev, } else if (strcmp(attr->name, "flash_media_type") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.fmtype); } else if (strcmp(attr->name, "num_channels") == 0) { - return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->nr_chnls); + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->num_ch); } else if (strcmp(attr->name, "num_luns") == 0) { - return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->nr_luns); + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->num_lun); } else if (strcmp(attr->name, "num_planes") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.num_pln); } else if (strcmp(attr->name, "num_blocks") == 0) { /* u16 */ @@ -1030,9 +1030,9 @@ static ssize_t nvm_dev_attr_show_20(struct device *dev, attr = &dattr->attr; if (strcmp(attr->name, "groups") == 0) { - return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->nr_chnls); + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->num_ch); } else if (strcmp(attr->name, "punits") == 0) { - return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->nr_luns); + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->num_lun); } else if (strcmp(attr->name, "chunks") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.num_chk); } else if (strcmp(attr->name, "clba") == 0) { diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 5af0b8837095..28d429e0a1c9 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -246,8 +246,8 @@ struct nvm_dev_geo { u8 minor_ver_id; /* full device geometry */ - u16 nr_chnls; - u16 nr_luns; + u16 num_ch; + u16 num_lun; /* calculated values */ u16 all_luns; @@ -323,8 +323,8 @@ enum { /* Instance geometry */ struct nvm_geo { /* instance specific geometry */ - int nr_chnls; - int nr_luns; /* per channel */ + int num_ch; + int num_lun; /* per channel */ int op;