From patchwork Mon Feb 26 13:17:07 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: 10242275 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 C996A602DC for ; Mon, 26 Feb 2018 13:19:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B827628A1A for ; Mon, 26 Feb 2018 13:19:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC9B62A000; Mon, 26 Feb 2018 13:19:52 +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 B880728A1A for ; Mon, 26 Feb 2018 13:19:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753171AbeBZNTu (ORCPT ); Mon, 26 Feb 2018 08:19:50 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34059 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753155AbeBZNRg (ORCPT ); Mon, 26 Feb 2018 08:17:36 -0500 Received: by mail-wm0-f66.google.com with SMTP id a20so16957028wmd.1 for ; Mon, 26 Feb 2018 05:17:35 -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=01ZFK9XXZGjQXpp+PuG+y7IbkFprWOvrj58ntTI6VB0=; b=YlWK0c/N+CoRAcmSSf+qeYu82St9S21WOuMaOo/+tEUsyI52wC36Ly/AZPsjc0kNqC DZLP9BNcNUNzYFqQlIEZaDk7bv6UlX9R3UiSkjOogOqki0ERkMjgSr1ZzZUsAVwsDdgC dKY9BYAHiWBt6UsfgccunD7l01YyLMVl8wyTyPLdJ920+uLCON3TLrXGZGiuwp8tf58n SpX0rWWH+/tPHYf5WRGhLaYkpG+iprSA25NqjfRKetaRMhUNklv0OeUGdJjMwuPiWwgG 17172k4xSKnckVzSIGbEYWvPR49afrtB524OvDQK3BzPz9bvzYM+tUEmDwn5+rvJ9Z3e D2OA== 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=01ZFK9XXZGjQXpp+PuG+y7IbkFprWOvrj58ntTI6VB0=; b=OcppvDcBkuCkMdAS4Q/yhJ6YZKDaE9A+2eCO3IhvUVFk9SPlqyW9rczZzQZ3D3hq5E lfQctOa7iGun1HqrENjMZqdxBn8iWEzlGHll8VyFsvJbd3srJM+e53+eOHdqj+1k2hGm 8I5O8LE4i2a0N8Uvdky8unWfqOH3wuXax/UTb5p7rk7R3v76a2e9nBnxQHUhFpqidLEr EYqvv880HEaer0IqAP76+7Dwsr4n8dSH4sQslOAF17q0Iq4Y18Qjt1yQTdhUa7gH5spt 7Ybsp2xWZgip5ct5UcYp/8PnqJEfS4JktPlOegxMMGshys89D4HFMpRYOcvNEowiN4yu JepA== X-Gm-Message-State: APf1xPAY5PDOr3A3wiS6YUIk9oM5SlOY1NhC9CIfbwn5rwuU6fFy7p7S dtJVQ1+VWhncXeiRV0owYcnUjw== X-Google-Smtp-Source: AH8x226Uk3fTLV7vdmjrPQaXVARGyvdv+GZnO7221f6qBCbnaGhcM0pt4BPFrFJK5JLQybPipa/o7Q== X-Received: by 10.80.173.10 with SMTP id y10mr14220593edc.247.1519651054916; Mon, 26 Feb 2018 05:17:34 -0800 (PST) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id g59sm7097451ede.19.2018.02.26.05.17.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 05:17:34 -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 08/19] lightnvm: rename number of channels and luns Date: Mon, 26 Feb 2018 14:17:07 +0100 Message-Id: <1519651038-16845-9-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519651038-16845-1-git-send-email-javier@cnexlabs.com> References: <1519651038-16845-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 | 4 +-- 6 files changed, 59 insertions(+), 60 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 96f4e62d383b..45bed54488f9 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 6e0567971cf6..7e3297be517d 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 4ea553c91756..f3f524dc1389 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -302,9 +302,9 @@ static int nvme_nvm_setup_12(struct nvme_nvm_id12 *id, /* Set compacted version for upper layers */ dev_geo->c.version = NVM_OCSSD_SPEC_12; - 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); @@ -404,9 +404,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); @@ -1005,9 +1005,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 */ @@ -1055,9 +1055,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 e8e6bfd4d0d4..797594d6519f 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -323,8 +323,8 @@ struct nvm_geo { u8 minor_ver_id; /* instance specific geometry */ - int nr_chnls; - int nr_luns; /* per channel */ + int num_ch; + int num_lun; /* per channel */ int op; /* over-provision in instance */