From patchwork Mon Nov 28 21:39:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 9450513 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 5FBD06071C for ; Mon, 28 Nov 2016 21:40:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51D3427E3E for ; Mon, 28 Nov 2016 21:40:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46F5527F94; Mon, 28 Nov 2016 21:40:50 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 98CC727E3E for ; Mon, 28 Nov 2016 21:40:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755774AbcK1Vkj (ORCPT ); Mon, 28 Nov 2016 16:40:39 -0500 Received: from mail-wj0-f194.google.com ([209.85.210.194]:35917 "EHLO mail-wj0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755617AbcK1Vjw (ORCPT ); Mon, 28 Nov 2016 16:39:52 -0500 Received: by mail-wj0-f194.google.com with SMTP id jb2so15789714wjb.3 for ; Mon, 28 Nov 2016 13:39:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WrH7F+CsqzHmbZr1jmu7DAGwsO6JIAL4UH4Yr1bTDxQ=; b=vpSrX4G8QQNuH+6UcM/5WJZ+Nm/x0IN7LLYL/9fFNyOHj0A6TVJodtolD75L/FPwQU CcwJTW26/GokhADEODCvX+dwas9xEjTGi6HkJZsLSJV+dbpady8dN7K98kSnBv28aFoo sx0GXCkrkvo6V4IAnV3IHW+23hRykogqMVTo0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WrH7F+CsqzHmbZr1jmu7DAGwsO6JIAL4UH4Yr1bTDxQ=; b=gQ838pZ8I0ya55Vy4+2Q1EYOzgsYjTZvRAhU1BxKwJ/zEgQ7qiZ6DNeFqDo+Qz6BCT cG6O9uaLf+lDteaG8ZtGHK3tuIteXks+hDPRJpHrhjAZjLBsRK6Xdg8VqFdK2HIhaFOI RR6JhtIUTPtzzxDONFfCDUj1uCQX7T/bh0ecBD1H4p0IR5ijnWGauGML/iEGCeWuOkDC XOyqaMKuYTPw/cO9NDC6GA76/MlWYuJ2eIY78Df+NTDAg06nrAtrXDTrpojty2Dtd2RO dNW5iSTikhhZSg0mA0qbVmgxKOipsjsB7KwycvWfqX0+dN0vdHM28ezVOiiIq+nN/llJ x8DA== X-Gm-Message-State: AKaTC00DtXZHGHcvji1VczWWx/aXShBe/NDfdXzOwIOncMvvsTtSpYExwUETPAIQXubAEQ== X-Received: by 10.194.94.70 with SMTP id da6mr23892335wjb.180.1480369191130; Mon, 28 Nov 2016 13:39:51 -0800 (PST) Received: from Macroninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id w79sm30825843wmw.0.2016.11.28.13.39.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 13:39:50 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: axboe@fb.com, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 16/23] lightnvm: remove get_lun operation on gennvm Date: Mon, 28 Nov 2016 22:39:07 +0100 Message-Id: <20161128213914.12516-17-m@bjorling.me> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161128213914.12516-1-m@bjorling.me> References: <20161128213914.12516-1-m@bjorling.me> 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 From: Javier González Since LUNs are managed internally on the target, there is no need for the media manager to implement a get_lun operation. Signed-off-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/gennvm.c | 13 +------------ drivers/lightnvm/rrpc.c | 23 +++++++++++------------ include/linux/lightnvm.h | 8 ++------ 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c index 8791a2a..3cf5d59 100644 --- a/drivers/lightnvm/gennvm.c +++ b/drivers/lightnvm/gennvm.c @@ -159,7 +159,7 @@ static int gen_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) tdisk->fops = &gen_fops; tdisk->queue = tqueue; - targetdata = tt->init(tgt_dev, tdisk, s->lun_begin, s->lun_end); + targetdata = tt->init(tgt_dev, tdisk, &t->lun_list); if (IS_ERR(targetdata)) goto err_init; @@ -613,16 +613,6 @@ static int gen_erase_blk(struct nvm_dev *dev, struct nvm_block *blk, int flags) return nvm_erase_ppa(dev, &addr, 1, flags); } -static struct nvm_lun *gen_get_lun(struct nvm_dev *dev, int lunid) -{ - struct gen_dev *gn = dev->mp; - - if (unlikely(lunid >= dev->geo.nr_luns)) - return NULL; - - return &gn->luns[lunid]; -} - static void gen_lun_info_print(struct nvm_dev *dev) { struct gen_dev *gn = dev->mp; @@ -655,7 +645,6 @@ static struct nvmm_type gen = { .mark_blk = gen_mark_blk, - .get_lun = gen_get_lun, .lun_info_print = gen_lun_info_print, .get_area = gen_get_area, diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index 5377c7a..165b9d3 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -1199,10 +1199,11 @@ static void rrpc_luns_free(struct rrpc *rrpc) kfree(rrpc->luns); } -static int rrpc_luns_init(struct rrpc *rrpc, int lun_begin, int lun_end) +static int rrpc_luns_init(struct rrpc *rrpc, struct list_head *lun_list) { struct nvm_tgt_dev *dev = rrpc->dev; struct nvm_geo *geo = &dev->geo; + struct nvm_lun *lun; struct rrpc_lun *rlun; int i, j, ret = -EINVAL; @@ -1218,16 +1219,11 @@ static int rrpc_luns_init(struct rrpc *rrpc, int lun_begin, int lun_end) if (!rrpc->luns) return -ENOMEM; + i = 0; + /* 1:1 mapping */ - for (i = 0; i < rrpc->nr_luns; i++) { - int lunid = lun_begin + i; - struct nvm_lun *lun; - - lun = dev->mt->get_lun(dev->parent, lunid); - if (!lun) - goto err; - - rlun = &rrpc->luns[i]; + list_for_each_entry(lun, lun_list, list) { + rlun = &rrpc->luns[i++]; rlun->parent = lun; rlun->blocks = vzalloc(sizeof(struct rrpc_block) * geo->blks_per_lun); @@ -1256,6 +1252,8 @@ static int rrpc_luns_init(struct rrpc *rrpc, int lun_begin, int lun_end) spin_lock_init(&rlun->lock); } + WARN_ON(i != rrpc->nr_luns); + return 0; err: return ret; @@ -1410,12 +1408,13 @@ static int rrpc_luns_configure(struct rrpc *rrpc) static struct nvm_tgt_type tt_rrpc; static void *rrpc_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk, - int lun_begin, int lun_end) + struct list_head *lun_list) { struct request_queue *bqueue = dev->q; struct request_queue *tqueue = tdisk->queue; struct nvm_geo *geo = &dev->geo; struct rrpc *rrpc; + int lun_begin = (list_first_entry(lun_list, struct nvm_lun, list))->id; sector_t soffset; int ret; @@ -1450,7 +1449,7 @@ static void *rrpc_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk, } rrpc->soffset = soffset; - ret = rrpc_luns_init(rrpc, lun_begin, lun_end); + ret = rrpc_luns_init(rrpc, lun_list); if (ret) { pr_err("nvm: rrpc: could not initialize luns\n"); goto err; diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 1f1588c..e56c352 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -504,8 +504,8 @@ static inline int ppa_to_slc(struct nvm_dev *dev, int slc_pg) typedef blk_qc_t (nvm_tgt_make_rq_fn)(struct request_queue *, struct bio *); typedef sector_t (nvm_tgt_capacity_fn)(void *); -typedef void *(nvm_tgt_init_fn)(struct nvm_tgt_dev *, struct gendisk *, int, - int); +typedef void *(nvm_tgt_init_fn)(struct nvm_tgt_dev *, struct gendisk *, + struct list_head *lun_list); typedef void (nvm_tgt_exit_fn)(void *); struct nvm_tgt_type { @@ -541,7 +541,6 @@ typedef int (nvmm_remove_tgt_fn)(struct nvm_dev *, struct nvm_ioctl_remove *); typedef int (nvmm_submit_io_fn)(struct nvm_dev *, struct nvm_rq *); typedef int (nvmm_erase_blk_fn)(struct nvm_dev *, struct nvm_block *, int); typedef void (nvmm_mark_blk_fn)(struct nvm_dev *, struct ppa_addr, int); -typedef struct nvm_lun *(nvmm_get_lun_fn)(struct nvm_dev *, int); typedef void (nvmm_lun_info_print_fn)(struct nvm_dev *); typedef int (nvmm_get_area_fn)(struct nvm_dev *, sector_t *, sector_t); @@ -563,9 +562,6 @@ struct nvmm_type { /* Bad block mgmt */ nvmm_mark_blk_fn *mark_blk; - /* Configuration management */ - nvmm_get_lun_fn *get_lun; - /* Statistics */ nvmm_lun_info_print_fn *lun_info_print;