From patchwork Tue Jan 31 12:17:14 2017 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: 9547051 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 299B3604DF for ; Tue, 31 Jan 2017 12:20:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1822F28372 for ; Tue, 31 Jan 2017 12:20:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D01E28389; Tue, 31 Jan 2017 12:20:11 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 65EEC28372 for ; Tue, 31 Jan 2017 12:20:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752003AbdAaMUI (ORCPT ); Tue, 31 Jan 2017 07:20:08 -0500 Received: from mail-bn3nam01on0058.outbound.protection.outlook.com ([104.47.33.58]:53760 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751990AbdAaMSJ (ORCPT ); Tue, 31 Jan 2017 07:18:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cnexlabs.onmicrosoft.com; s=selector1-cnexlabs-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=kSmEfcJddMRdvkQIEPkI8pCLyXW2wHhBO8/uVwRustI=; b=WvyO04LJYC3i6zI3T4gp+UqG/O7cDWf5WEjDont6AAmj8P2ji50eVnhmtoHQSTTyZak/Oay7oBqc2NW/Wph6XgUHBfm/jvRFtvwxZbb2O3+7dgxK7F/j3kCYZMi6OVW6rXwtSgln8EalrxV03xvaiuw3z9lDZKlKphrFFRlyhFs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matias@cnexlabs.com; Received: from skyninja.cnexlabs.com (193.106.164.211) by DM5PR06MB2777.namprd06.prod.outlook.com (10.175.107.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.874.12; Tue, 31 Jan 2017 12:17:54 +0000 From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: CC: , , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 06/12] lightnvm: cleanup nvm transformation functions Date: Tue, 31 Jan 2017 13:17:14 +0100 Message-ID: <20170131121720.10971-7-matias@cnexlabs.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170131121720.10971-1-matias@cnexlabs.com> References: <20170131121720.10971-1-matias@cnexlabs.com> MIME-Version: 1.0 X-Originating-IP: [193.106.164.211] X-ClientProxiedBy: DB6PR0601CA0024.eurprd06.prod.outlook.com (10.168.88.162) To DM5PR06MB2777.namprd06.prod.outlook.com (10.175.107.139) X-MS-Office365-Filtering-Correlation-Id: 26f36e48-8f41-406c-318c-08d449d32f7d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DM5PR06MB2777; X-Microsoft-Exchange-Diagnostics: 1; DM5PR06MB2777; 3:J8rmg92thN2DC6KIV4GMgeZNTwu7hFX5+79A+ITP/UPfBfNKnfkJY5g2Ir3YCmDG17kBAoMic+A8cjsXe6p1HpVmCL2O0udv9x98F8LtLvGphz0eB3OyAMlwkO4hE27b5wSV0dbnn4CGnHzcbKqYwiTZNn6P3xX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Cx/bVZQH6aqeRRiotpKO0412FQ65smZZY1M= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123560025)(20161123555025)(20161123562025)(20161123564025)(6042181)(6072148); SRVR:DM5PR06MB2777; BCL:0; PCL:0; RULEID:; SRVR:DM5PR06MB2777; X-Microsoft-Exchange-Diagnostics: 1; DM5PR06MB2777; 4:uyFR7+7nGXa7kYHaPqfkkuZ9Ft1VQGxLw4k1PctBwCHBSvzCKwkTUQC3xJjAJhOZFablOKknDa/h+SlO6lwdmScGWbif0TYKhpxqiIEeLzUdUsfUn2YIm0OrhbX6ieXBZKhMc5itp5YV1jUL4N0q979xiYJamJMOEqlE07ZLQuGj2YDL/4wY8cLbbUj8OlwI6zm8PQs3GTYQph/Q/siQ1VqKNE6V6UsPs3V+LlIYsDIxRKb7Mk7oZbFFqTHga3x8rESSPsUidY5lL/bVd7bWPwWfQICJIh/YVFqnsb4uU3AhP5i+5HQxWX8ocgWjDa9Kx3yfzU0fudihGHu1KOzIkoS0WUe8TYsS902GjMEJLPlwoZ9S9oQ4pxvn/bkkyciZX9pw2t6A8qHNZ/sZ51YduKDUZakAgaErCLQlvL7wQXM3SO7MCvi/mdSOMPxcc3k29OlWXbZ/yx+EjuhTDWOAHkxjMiwTPngslpxsilb67aTHIJyHqtXis6DRJlHn0ayBGyxC/rxn1rBbWCb/qVrtl/BEk72rd8jKlIKxLuCv2uCG6ttdHnK1Gl4VSDPBKiN5J0DMNa4opjaOca0HPMN18A== X-Forefront-PRVS: 0204F0BDE2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(42186005)(66066001)(50466002)(6486002)(47776003)(38730400001)(105586002)(54906002)(25786008)(106356001)(2351001)(36756003)(68736007)(4001430100002)(53416004)(50986999)(107886002)(7736002)(2906002)(305945005)(4326007)(110136003)(23676002)(575784001)(2870700001)(189998001)(5660300001)(92566002)(86362001)(1076002)(6116002)(3846002)(33646002)(6916009)(97736004)(2950100002)(5820100001)(6666003)(76176999)(101416001)(53936002)(81166006)(81156014)(8676002)(50226002)(69596002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR06MB2777; H:skyninja.cnexlabs.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cnexlabs.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtETTVQUjA2TUIyNzc3OzIzOlBURm9mVDNoUm9TS3BrbG1KS3N2V0xpa1dC?= =?utf-8?B?dDVGeG10U0RYaEZwZGpiQmkrbXk0VHc1WjNncC9tVjQ4NUpRK0hlUzJySHlx?= =?utf-8?B?Qm80Zlp2RkNmUFlQTTU0cXM2TTlaZzhvSHJCU1RWUWZFYjJ2U1RocWxVZXZl?= =?utf-8?B?YTRtQ3dSNVJaRFJJaXM2eUlkOGxyUEgwYnNZTXJxVjl2ajFJVGRLT1czay9u?= =?utf-8?B?NFhpdkhZT0VJMkMwMDdZQWNkLzhzQ0xDcnBKTWlkeEdNVTJmZmN1d0lybXhY?= =?utf-8?B?Y0NocFZzY2Qzanlab1Qvc0N5QUNQdkFMamZPanM0UVZNMytzZ3QyVUd0ZXFl?= =?utf-8?B?SUo5Y0pvRzA4SGdVTEtxU2NyQXppMXQ0QktFY3FmMk0xV3VKb2FhTkFuR1Jr?= =?utf-8?B?YjI0OVVCRmxrVWRiRDNZaStnWmgxSzhEbjRRTHhCNXdHZkljckRxcm9yMjU4?= =?utf-8?B?NCs4ZmxSSEJmd2xJTys4VGZPdWpEaHBGMGtXR1hCSnlGeUp5SHZUZVV6M0Rp?= =?utf-8?B?VTc1a1VvNVh1K2Y0WW9VdUI0NUEyMTJFK2loZmtIaDNlR3ozNGJsUElmcnJ1?= =?utf-8?B?ODJmR242L1ZZd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w6qcF+Br6i4hYt/v8a69kfpr2iDx0Qd3X3l+ap+KT0YuHnxRx2elOOgXVEl9tuvUIBEG/xF20nms0t6Q2TQy7sCpuRkYv/jNRJ1sj15HqIYZ5A53qSX4ZNNGlXLg1+WC3O08HAkWWkEdR3BkFz6+1Ii+RFQORDZgI/Yem8rJBZJQeryQEA09sXN+nJNY6et2vmZuv1P7Kh9aewK2WM5E2FgcQZL4+HJI6PMRND+fsjEeld4MCm5rrlSYLJoFH7qYTunWwQySGXaZYj2OHDXGr53Vg3J/nLZmF+SVOFW2UBGHMtdwoK82y3rpPPGMPWqBOi+UNgVYvT3IUFnFRcKZ5bIiDfL5Vt5gTEa57JxzoRLeGufuw5Ou6KBZx5xwULDbkmklu4a2Npkl0GDg0Nq0+2udp1KruerxeVBcNou7pE4AIOQnmIutsRxD2OlPHN8OBaOfHccRtob8kvH88xHR8t0XkKM/lQrMnxB/BcgiRcZHSSio5nld4wFEFRDVmkIc5HTBho0ARBUo44v3B X-OriginatorOrg: cnexlabs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2017 12:17:54.1466 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR06MB2777 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 Going from target specific ppa addresses to device was accomplished by first converting target to generic ppa addresses and generic to device addresses. The conversion was either open-coded or used the built-in nvm_trans_* and nvm_map_* functions for conversion. Simplify the interface and cleanup the calls to provide clean functions that now either take a list of ppas or a nvm_rq, and is exposed through: void nvm_ppa_* - target to/from device with a list of PPAs, void nvm_rq_* - target to/from device with a nvm_rq. Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 115 ++++++++++++++--------------------------------- include/linux/lightnvm.h | 14 +++--- 2 files changed, 40 insertions(+), 89 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index a1a7a5a..0842c85 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -50,11 +50,6 @@ struct nvm_area { sector_t end; /* end is excluded */ }; -enum { - TRANS_TGT_TO_DEV = 0x0, - TRANS_DEV_TO_TGT = 0x1, -}; - static struct nvm_target *nvm_find_target(struct nvm_dev *dev, const char *name) { struct nvm_target *tgt; @@ -428,38 +423,46 @@ static void nvm_map_to_tgt(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *p) p->g.lun -= lun_roff; } -static void nvm_trans_rq(struct nvm_tgt_dev *tgt_dev, struct nvm_rq *rqd, - int flag) +static void nvm_ppa_tgt_to_dev(struct nvm_tgt_dev *tgt_dev, + struct ppa_addr *ppa_list, int nr_ppas) { int i; - if (rqd->nr_ppas == 1) { - if (flag == TRANS_TGT_TO_DEV) - nvm_map_to_dev(tgt_dev, &rqd->ppa_addr); - else - nvm_map_to_tgt(tgt_dev, &rqd->ppa_addr); - return; + for (i = 0; i < nr_ppas; i++) { + nvm_map_to_dev(tgt_dev, &ppa_list[i]); + ppa_list[i] = generic_to_dev_addr(tgt_dev, ppa_list[i]); } +} + +static void nvm_ppa_dev_to_tgt(struct nvm_tgt_dev *tgt_dev, + struct ppa_addr *ppa_list, int nr_ppas) +{ + int i; - for (i = 0; i < rqd->nr_ppas; i++) { - if (flag == TRANS_TGT_TO_DEV) - nvm_map_to_dev(tgt_dev, &rqd->ppa_list[i]); - else - nvm_map_to_tgt(tgt_dev, &rqd->ppa_list[i]); + for (i = 0; i < nr_ppas; i++) { + ppa_list[i] = dev_to_generic_addr(tgt_dev, ppa_list[i]); + nvm_map_to_tgt(tgt_dev, &ppa_list[i]); } } -static struct ppa_addr nvm_trans_ppa(struct nvm_tgt_dev *tgt_dev, - struct ppa_addr p, int dir) +static void nvm_rq_tgt_to_dev(struct nvm_tgt_dev *tgt_dev, struct nvm_rq *rqd) { - struct ppa_addr ppa = p; + if (rqd->nr_ppas == 1) { + nvm_ppa_tgt_to_dev(tgt_dev, &rqd->ppa_addr, 1); + return; + } + + nvm_ppa_tgt_to_dev(tgt_dev, rqd->ppa_list, rqd->nr_ppas); +} - if (dir == TRANS_TGT_TO_DEV) - nvm_map_to_dev(tgt_dev, &ppa); - else - nvm_map_to_tgt(tgt_dev, &ppa); +static void nvm_rq_dev_to_tgt(struct nvm_tgt_dev *tgt_dev, struct nvm_rq *rqd) +{ + if (rqd->nr_ppas == 1) { + nvm_ppa_dev_to_tgt(tgt_dev, &rqd->ppa_addr, 1); + return; + } - return ppa; + nvm_ppa_dev_to_tgt(tgt_dev, rqd->ppa_list, rqd->nr_ppas); } void nvm_part_to_tgt(struct nvm_dev *dev, sector_t *entries, @@ -564,26 +567,6 @@ static struct nvm_dev *nvm_find_nvm_dev(const char *name) return NULL; } -static void nvm_tgt_generic_to_addr_mode(struct nvm_tgt_dev *tgt_dev, - struct nvm_rq *rqd) -{ - struct nvm_dev *dev = tgt_dev->parent; - int i; - - if (rqd->nr_ppas > 1) { - for (i = 0; i < rqd->nr_ppas; i++) { - rqd->ppa_list[i] = nvm_trans_ppa(tgt_dev, - rqd->ppa_list[i], TRANS_TGT_TO_DEV); - rqd->ppa_list[i] = generic_to_dev_addr(dev, - rqd->ppa_list[i]); - } - } else { - rqd->ppa_addr = nvm_trans_ppa(tgt_dev, rqd->ppa_addr, - TRANS_TGT_TO_DEV); - rqd->ppa_addr = generic_to_dev_addr(dev, rqd->ppa_addr); - } -} - int nvm_set_tgt_bb_tbl(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *ppas, int nr_ppas, int type) { @@ -599,7 +582,7 @@ int nvm_set_tgt_bb_tbl(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *ppas, memset(&rqd, 0, sizeof(struct nvm_rq)); nvm_set_rqd_ppalist(dev, &rqd, ppas, nr_ppas, 1); - nvm_tgt_generic_to_addr_mode(tgt_dev, &rqd); + nvm_rq_tgt_to_dev(tgt_dev, &rqd); ret = dev->ops->set_bb_tbl(dev, &rqd.ppa_addr, rqd.nr_ppas, type); nvm_free_rqd_ppalist(dev, &rqd); @@ -627,8 +610,7 @@ int nvm_submit_io(struct nvm_tgt_dev *tgt_dev, struct nvm_rq *rqd) if (!dev->ops->submit_io) return -ENODEV; - /* Convert address space */ - nvm_generic_to_addr_mode(dev, rqd); + nvm_rq_tgt_to_dev(tgt_dev, rqd); rqd->dev = tgt_dev; return dev->ops->submit_io(dev, rqd); @@ -652,7 +634,7 @@ int nvm_erase_blk(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *ppas, int flags) if (ret) return ret; - nvm_generic_to_addr_mode(dev, &rqd); + nvm_rq_tgt_to_dev(tgt_dev, &rqd); rqd.flags = flags; @@ -741,34 +723,6 @@ void nvm_put_area(struct nvm_tgt_dev *tgt_dev, sector_t begin) } EXPORT_SYMBOL(nvm_put_area); -void nvm_addr_to_generic_mode(struct nvm_dev *dev, struct nvm_rq *rqd) -{ - int i; - - if (rqd->nr_ppas > 1) { - for (i = 0; i < rqd->nr_ppas; i++) - rqd->ppa_list[i] = dev_to_generic_addr(dev, - rqd->ppa_list[i]); - } else { - rqd->ppa_addr = dev_to_generic_addr(dev, rqd->ppa_addr); - } -} -EXPORT_SYMBOL(nvm_addr_to_generic_mode); - -void nvm_generic_to_addr_mode(struct nvm_dev *dev, struct nvm_rq *rqd) -{ - int i; - - if (rqd->nr_ppas > 1) { - for (i = 0; i < rqd->nr_ppas; i++) - rqd->ppa_list[i] = generic_to_dev_addr(dev, - rqd->ppa_list[i]); - } else { - rqd->ppa_addr = generic_to_dev_addr(dev, rqd->ppa_addr); - } -} -EXPORT_SYMBOL(nvm_generic_to_addr_mode); - int nvm_set_rqd_ppalist(struct nvm_dev *dev, struct nvm_rq *rqd, const struct ppa_addr *ppas, int nr_ppas, int vblk) { @@ -826,7 +780,7 @@ void nvm_end_io(struct nvm_rq *rqd, int error) /* Convert address space */ if (tgt_dev) - nvm_trans_rq(tgt_dev, rqd, TRANS_DEV_TO_TGT); + nvm_rq_dev_to_tgt(tgt_dev, rqd); rqd->error = error; ins->tt->end_io(rqd); @@ -874,8 +828,7 @@ int nvm_get_tgt_bb_tbl(struct nvm_tgt_dev *tgt_dev, struct ppa_addr ppa, { struct nvm_dev *dev = tgt_dev->parent; - ppa = nvm_trans_ppa(tgt_dev, ppa, TRANS_TGT_TO_DEV); - ppa = generic_to_dev_addr(dev, ppa); + nvm_ppa_tgt_to_dev(tgt_dev, &ppa, 1); return dev->ops->get_bb_tbl(dev, ppa, blks); } diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index cad1e1c..faa0fbf 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -378,10 +378,10 @@ static inline struct ppa_addr linear_to_generic_addr(struct nvm_geo *geo, return l; } -static inline struct ppa_addr generic_to_dev_addr(struct nvm_dev *dev, - struct ppa_addr r) +static inline struct ppa_addr generic_to_dev_addr(struct nvm_tgt_dev *tgt_dev, + struct ppa_addr r) { - struct nvm_geo *geo = &dev->geo; + struct nvm_geo *geo = &tgt_dev->geo; struct ppa_addr l; l.ppa = ((u64)r.g.blk) << geo->ppaf.blk_offset; @@ -394,10 +394,10 @@ static inline struct ppa_addr generic_to_dev_addr(struct nvm_dev *dev, return l; } -static inline struct ppa_addr dev_to_generic_addr(struct nvm_dev *dev, - struct ppa_addr r) +static inline struct ppa_addr dev_to_generic_addr(struct nvm_tgt_dev *tgt_dev, + struct ppa_addr r) { - struct nvm_geo *geo = &dev->geo; + struct nvm_geo *geo = &tgt_dev->geo; struct ppa_addr l; l.ppa = 0; @@ -477,8 +477,6 @@ extern int nvm_set_tgt_bb_tbl(struct nvm_tgt_dev *, struct ppa_addr *, int, int); extern int nvm_max_phys_sects(struct nvm_tgt_dev *); extern int nvm_submit_io(struct nvm_tgt_dev *, struct nvm_rq *); -extern void nvm_generic_to_addr_mode(struct nvm_dev *, struct nvm_rq *); -extern void nvm_addr_to_generic_mode(struct nvm_dev *, struct nvm_rq *); extern int nvm_set_rqd_ppalist(struct nvm_dev *, struct nvm_rq *, const struct ppa_addr *, int, int); extern void nvm_free_rqd_ppalist(struct nvm_dev *, struct nvm_rq *);