From patchwork Mon Nov 28 21:39:13 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: 9450569 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 2B9696071C for ; Mon, 28 Nov 2016 21:44:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D1EF27BFF for ; Mon, 28 Nov 2016 21:44:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1019427F60; Mon, 28 Nov 2016 21:44:00 +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 7523127BFF for ; Mon, 28 Nov 2016 21:43:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933480AbcK1Vnz (ORCPT ); Mon, 28 Nov 2016 16:43:55 -0500 Received: from mail-wj0-f193.google.com ([209.85.210.193]:35934 "EHLO mail-wj0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755650AbcK1Vj6 (ORCPT ); Mon, 28 Nov 2016 16:39:58 -0500 Received: by mail-wj0-f193.google.com with SMTP id jb2so15789868wjb.3 for ; Mon, 28 Nov 2016 13:39:57 -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=ZQY2VwTMcb5h5e1DTyxMeNOTlDofqyXAsentqr/Ui8A=; b=oiSTKtGXiC3NtKfhsl1hclDZtRxdTMHF0bDUfgx2par8aVmME0crF5Fh8yeH9SZvKE 8OOYr1F3554qrshEiuI6VOJ6wgHsVGRRi2D2zOrtOuN7NPsAxAp+S90UrilDlkqX1jIw ErjnhDvY6bkZ6hZSyt3IZgmkpAqb4to0fWc54= 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=ZQY2VwTMcb5h5e1DTyxMeNOTlDofqyXAsentqr/Ui8A=; b=iv814lMc63D2pwTjVBed3qQp7h2TbcvAvx6GxxUytW9JhXmInQpTN/wmH1Z9e2b8/2 wNgty0NgRmDSPdqWKW7IRSA0o5CPahYIKB8pDbQdmkMY6FHhjZojPOfAWrGYr/66tM5G A/T7wffxPKPB4bef+Brplr1nhoTY+m2uV9E9CXTRj3pPMhPbeFq55jCJKQIbsjL7KoDw yuzwLnOE0NMjZx+JNYKwl1hkPm+ujebhuGNLDV4s8HJnyBabA2KV0o3ILeL8TQS3Wzcq jmVbLMXcLMVEVFujlNvkb1ATn/+RyxEKb3ZUrkbVYQVF7RBwxHKeQ+YJdGaO1MQqjjKx ZoEQ== X-Gm-Message-State: AKaTC02mh1VSVf9X4ueuhUEqr1pIW8mppsj9QG3stcInhYb70vQhWX1AELzZTKqUzabuHA== X-Received: by 10.194.127.40 with SMTP id nd8mr23648334wjb.43.1480369196733; Mon, 28 Nov 2016 13:39:56 -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.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 13:39:56 -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 22/23] lightnvm: use target nvm on target-specific ops. Date: Mon, 28 Nov 2016 22:39:13 +0100 Message-Id: <20161128213914.12516-23-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 On target-specific operations pass on nvm_tgt_dev instead of the generic nvm device. Signed-off-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 15 ++++++++++----- drivers/lightnvm/rrpc.c | 14 +++++++------- drivers/lightnvm/rrpc.h | 2 +- include/linux/lightnvm.h | 6 +++--- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 3d8eaac..07bf989 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -86,8 +86,7 @@ void *nvm_dev_dma_alloc(struct nvm_dev *dev, gfp_t mem_flags, } EXPORT_SYMBOL(nvm_dev_dma_alloc); -void nvm_dev_dma_free(struct nvm_dev *dev, void *addr, - dma_addr_t dma_handler) +void nvm_dev_dma_free(struct nvm_dev *dev, void *addr, dma_addr_t dma_handler) { dev->ops->dev_dma_free(dev->dma_pool, addr, dma_handler); } @@ -227,9 +226,11 @@ 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, +int nvm_get_l2p_tbl(struct nvm_tgt_dev *tgt_dev, u64 slba, u32 nlb, nvm_l2p_update_fn *update_l2p, void *priv) { + struct nvm_dev *dev = tgt_dev->parent; + if (!dev->ops->get_l2p_tbl) return 0; @@ -237,14 +238,18 @@ int nvm_get_l2p_tbl(struct nvm_dev *dev, u64 slba, u32 nlb, } EXPORT_SYMBOL(nvm_get_l2p_tbl); -int nvm_get_area(struct nvm_dev *dev, sector_t *lba, sector_t len) +int nvm_get_area(struct nvm_tgt_dev *tgt_dev, sector_t *lba, sector_t len) { + struct nvm_dev *dev = tgt_dev->parent; + return dev->mt->get_area(dev, lba, len); } EXPORT_SYMBOL(nvm_get_area); -void nvm_put_area(struct nvm_dev *dev, sector_t lba) +void nvm_put_area(struct nvm_tgt_dev *tgt_dev, sector_t lba) { + struct nvm_dev *dev = tgt_dev->parent; + dev->mt->put_area(dev, lba); } EXPORT_SYMBOL(nvm_put_area); diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index e4678b7..8a27bcc 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -983,8 +983,8 @@ static int rrpc_submit_io(struct rrpc *rrpc, struct bio *bio, if (!(flags & NVM_IOTYPE_GC)) { rrpc_unlock_rq(rrpc, rqd); if (rqd->nr_ppas > 1) - nvm_dev_dma_free(dev->parent, - rqd->ppa_list, rqd->dma_ppa_list); + nvm_dev_dma_free(dev->parent, rqd->ppa_list, + rqd->dma_ppa_list); } return NVM_IO_ERR; } @@ -1116,7 +1116,7 @@ static int rrpc_l2p_update(u64 slba, u32 nlb, __le64 *entries, void *private) div_u64_rem(pba, rrpc->nr_sects, &mod); - gaddr = rrpc_recov_addr(dev->parent, pba); + gaddr = rrpc_recov_addr(dev, pba); rlun = rrpc_ppa_to_lun(rrpc, gaddr); if (!rlun) { pr_err("rrpc: l2p corruption on lba %llu\n", @@ -1167,8 +1167,8 @@ static int rrpc_map_init(struct rrpc *rrpc) } /* Bring up the mapping table from device */ - ret = nvm_get_l2p_tbl(dev->parent, rrpc->soffset, rrpc->nr_sects, - rrpc_l2p_update, rrpc); + ret = nvm_get_l2p_tbl(dev, rrpc->soffset, rrpc->nr_sects, + rrpc_l2p_update, rrpc); if (ret) { pr_err("nvm: rrpc: could not read L2P table.\n"); return -EINVAL; @@ -1376,7 +1376,7 @@ static int rrpc_area_init(struct rrpc *rrpc, sector_t *begin) size >>= 9; - ret = nvm_get_area(dev->parent, begin, size); + ret = nvm_get_area(dev, begin, size); if (!ret) *begin >>= (ilog2(dev->geo.sec_size) - 9); @@ -1388,7 +1388,7 @@ static void rrpc_area_free(struct rrpc *rrpc) struct nvm_tgt_dev *dev = rrpc->dev; sector_t begin = rrpc->soffset << (ilog2(dev->geo.sec_size) - 9); - nvm_put_area(dev->parent, begin); + nvm_put_area(dev, begin); } static void rrpc_free(struct rrpc *rrpc) diff --git a/drivers/lightnvm/rrpc.h b/drivers/lightnvm/rrpc.h index bc8adba..94e4d73 100644 --- a/drivers/lightnvm/rrpc.h +++ b/drivers/lightnvm/rrpc.h @@ -184,7 +184,7 @@ static inline struct ppa_addr rrpc_linear_to_generic_addr(struct nvm_geo *geo, return l; } -static inline struct ppa_addr rrpc_recov_addr(struct nvm_dev *dev, u64 pba) +static inline struct ppa_addr rrpc_recov_addr(struct nvm_tgt_dev *dev, u64 pba) { return linear_to_generic_addr(&dev->geo, pba); } diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 9637531..e76f9c4 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -538,10 +538,10 @@ extern int nvm_set_rqd_ppalist(struct nvm_dev *, struct nvm_rq *, extern void nvm_free_rqd_ppalist(struct nvm_dev *, struct nvm_rq *); extern int nvm_erase_ppa(struct nvm_dev *, struct ppa_addr *, int, int); extern int nvm_erase_blk(struct nvm_tgt_dev *, struct ppa_addr *, int); -extern int nvm_get_l2p_tbl(struct nvm_dev *, u64, u32, nvm_l2p_update_fn *, +extern int nvm_get_l2p_tbl(struct nvm_tgt_dev *, u64, u32, nvm_l2p_update_fn *, void *); -extern int nvm_get_area(struct nvm_dev *, sector_t *, sector_t); -extern void nvm_put_area(struct nvm_dev *, sector_t); +extern int nvm_get_area(struct nvm_tgt_dev *, sector_t *, sector_t); +extern void nvm_put_area(struct nvm_tgt_dev *, sector_t); extern void nvm_end_io(struct nvm_rq *, int); extern int nvm_submit_ppa(struct nvm_dev *, struct ppa_addr *, int, int, int, void *, int);