From patchwork Fri Nov 18 14:43:40 2016 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: 9436647 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 2262760237 for ; Fri, 18 Nov 2016 14:45:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E0C629906 for ; Fri, 18 Nov 2016 14:45:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 131E629907; Fri, 18 Nov 2016 14:45:09 +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=unavailable 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 9FB4C29908 for ; Fri, 18 Nov 2016 14:45:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753988AbcKROpD (ORCPT ); Fri, 18 Nov 2016 09:45:03 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:36126 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932185AbcKROoN (ORCPT ); Fri, 18 Nov 2016 09:44:13 -0500 Received: by mail-wm0-f50.google.com with SMTP id g23so42658233wme.1 for ; Fri, 18 Nov 2016 06:44:12 -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=g2bM5hjV0+CNJo4NQft7TGLx4o+Xgjg9gD0XKxaFc1c=; b=HkpYqnGtDh50WALLywYiT7TXcNXgyyzO2ocGoK99mJO8pmNq6Np8R1dTdB9Sci62tQ zBAg2PIK/eHxYt051Nojko9Lt5J8p/qaZkuss5i9//l9/2rEtz9szd5zhVfZ5WVaE5rd jHwS7DLInxQO33AKUgOxUxycYKnlaGI0xbKiLiHj7Rp36F1PXhYNGdXvJTAVMwthKl3i r3DJpxDRljAe4x1JG2F5p7xfi2UMazNbX39W9dt439poHTPp0D0ruimKqaaBKCA6xft+ EX9jkI+yBUYqOzU7VQbM+ejncHeHZBCp9FxsWnLyTbapyuBEytnrsbNf1K0V5JKOFTOi +wqw== 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=g2bM5hjV0+CNJo4NQft7TGLx4o+Xgjg9gD0XKxaFc1c=; b=jc5EyUn5lTTGZM6xsyBrwQYgYBu/CXor55+eaE3/Zg3u+WLfYHkpjkT51Rv7uIGLjA 8whbAGttAgeAN/0wg/Ki4kZFBq6qyISOhsAdtQ9ssUh/7Mm8p+g3G6snDd/rQFuckKdL TKWi2wJtcDB2VphQI4iWytcS3RlJe4C+QQX5IQRSrJFFZlMDUqw5hywy/bp3Xtuhi82u ayRC1mMMu5opDdomXWH6KZO5gGs1qrUP5AYIH/Q6XMaAIWVQZzqqZ/mRFGNIoQpjy5Sm 9AIgyW/4C+GEIAjZHYyXjUPxqS7U9TJR79X9Jb32/UCrM+prj2Nnrtdsoejjqj4Ebzx3 i6Zw== X-Gm-Message-State: AKaTC00h1oKKXyB9CgBzfJhJ84EfWD9pqHPGOaJmhv+O2jhE3IBSRZezLgo1j6N7xYGp1w== X-Received: by 10.28.90.65 with SMTP id o62mr503297wmb.80.1479480251493; Fri, 18 Nov 2016 06:44:11 -0800 (PST) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id 138sm3703576wms.20.2016.11.18.06.44.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Nov 2016 06:44:11 -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, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= Subject: [PATCH 18/20] lightnvm: introduce helpers for generic ops in rrpc Date: Fri, 18 Nov 2016 15:43:40 +0100 Message-Id: <1479480222-18790-19-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479480222-18790-1-git-send-email-javier@cnexlabs.com> References: <1479480222-18790-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 Avoid calling media manager and device-specific operations directly from rrpc. Create helper functions on lightnvm's core instead. Signed-off-by: Javier González --- drivers/lightnvm/core.c | 22 ++++++++++++++++++++++ drivers/lightnvm/gennvm.c | 2 -- drivers/lightnvm/rrpc.c | 11 +++-------- include/linux/lightnvm.h | 3 --- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 23d582f..69f261e 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -219,6 +219,28 @@ int nvm_erase_blk(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *p, int flags) } EXPORT_SYMBOL(nvm_erase_blk); +int nvm_get_l2p_tbl(struct nvm_dev *dev, u64 slba, u32 nlb, + nvm_l2p_update_fn *update_l2p, void *priv) +{ + if (!dev->ops->get_l2p_tbl) + return 0; + + return dev->ops->get_l2p_tbl(dev, slba, nlb, update_l2p, priv); +} +EXPORT_SYMBOL(nvm_get_l2p_tbl); + +int nvm_get_area(struct nvm_dev *dev, sector_t *lba, sector_t len) +{ + return dev->mt->get_area(dev, lba, len); +} +EXPORT_SYMBOL(nvm_get_area); + +void nvm_put_area(struct nvm_dev *dev, sector_t lba) +{ + dev->mt->put_area(dev, lba); +} +EXPORT_SYMBOL(nvm_put_area); + void nvm_addr_to_generic_mode(struct nvm_dev *dev, struct nvm_rq *rqd) { int i; diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c index 5d7c8c4..befa828 100644 --- a/drivers/lightnvm/gennvm.c +++ b/drivers/lightnvm/gennvm.c @@ -175,8 +175,6 @@ static struct nvm_tgt_dev *gen_create_tgt_dev(struct nvm_dev *dev, tgt_dev->geo.luns_per_chnl = (lun_balanced) ? prev_nr_luns : -1; tgt_dev->total_secs = nr_luns * tgt_dev->geo.sec_per_lun; tgt_dev->q = dev->q; - tgt_dev->ops = dev->ops; - tgt_dev->mt = dev->mt; tgt_dev->map = dev_map; tgt_dev->luns = luns; memcpy(&tgt_dev->identity, &dev->identity, sizeof(struct nvm_id)); diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index 08a633c..150b5f30 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -1167,11 +1167,8 @@ static int rrpc_map_init(struct rrpc *rrpc) r->addr = ADDR_EMPTY; } - if (!dev->ops->get_l2p_tbl) - return 0; - /* Bring up the mapping table from device */ - ret = dev->ops->get_l2p_tbl(dev->parent, rrpc->soffset, rrpc->nr_sects, + ret = nvm_get_l2p_tbl(dev->parent, rrpc->soffset, rrpc->nr_sects, rrpc_l2p_update, rrpc); if (ret) { pr_err("nvm: rrpc: could not read L2P table.\n"); @@ -1372,13 +1369,12 @@ static int rrpc_luns_init(struct rrpc *rrpc, struct ppa_addr *luns) static int rrpc_area_init(struct rrpc *rrpc, sector_t *begin) { struct nvm_tgt_dev *dev = rrpc->dev; - struct nvmm_type *mt = dev->mt; sector_t size = rrpc->nr_sects * dev->geo.sec_size; int ret; size >>= 9; - ret = mt->get_area(dev->parent, begin, size); + ret = nvm_get_area(dev->parent, begin, size); if (!ret) *begin >>= (ilog2(dev->geo.sec_size) - 9); @@ -1388,10 +1384,9 @@ static int rrpc_area_init(struct rrpc *rrpc, sector_t *begin) static void rrpc_area_free(struct rrpc *rrpc) { struct nvm_tgt_dev *dev = rrpc->dev; - struct nvmm_type *mt = dev->mt; sector_t begin = rrpc->soffset << (ilog2(dev->geo.sec_size) - 9); - mt->put_area(dev->parent, begin); + nvm_put_area(dev->parent, begin); } static void rrpc_free(struct rrpc *rrpc) diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 2222853..b3ca603 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -320,9 +320,6 @@ struct nvm_tgt_dev { struct nvm_id identity; struct request_queue *q; - struct nvmm_type *mt; - struct nvm_dev_ops *ops; - void *parent; void *map; };