From patchwork Sat Apr 15 18:55:37 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: 9682347 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 9B96860138 for ; Sat, 15 Apr 2017 18:56:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BDBA25E13 for ; Sat, 15 Apr 2017 18:56:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DBE025223; Sat, 15 Apr 2017 18:56:30 +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 A915825223 for ; Sat, 15 Apr 2017 18:56:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754870AbdDOS40 (ORCPT ); Sat, 15 Apr 2017 14:56:26 -0400 Received: from mail-dm3nam03on0041.outbound.protection.outlook.com ([104.47.41.41]:38016 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753773AbdDOS4U (ORCPT ); Sat, 15 Apr 2017 14:56:20 -0400 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=TLLHfyg4gyhjyrZ0ZhoWZEJuL+4SMqq7DU/42eWlv2I=; b=feLglgRGCFcExTbO2r9YqyqwXBe55HN0HLbSyuo5SXMP7VHQaD4RG0nZBw3EIzDe3Nomxuimh5LF7A8I8/9tFr7TtNP4h7507PyszLSCrqkEBYYV5RcWExbeDUqg+HtnOrHUYHRL9qKv1kjVjxSnGGFDB5hrpSsxG7Wf1mRz6lc= Authentication-Results: fb.com; dkim=none (message not signed) header.d=none; fb.com; dmarc=none action=none header.from=cnexlabs.com; Received: from skyninja.cnexlabs.com (193.106.164.211) by CY4PR06MB2774.namprd06.prod.outlook.com (10.175.117.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Sat, 15 Apr 2017 18:56:15 +0000 From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: CC: , , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 03/19] lightnvm: submit erases using the I/O path Date: Sat, 15 Apr 2017 20:55:37 +0200 Message-ID: <20170415185553.16098-4-matias@cnexlabs.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170415185553.16098-1-matias@cnexlabs.com> References: <20170415185553.16098-1-matias@cnexlabs.com> MIME-Version: 1.0 X-Originating-IP: [193.106.164.211] X-ClientProxiedBy: AM5PR0701CA0069.eurprd07.prod.outlook.com (10.169.145.159) To CY4PR06MB2774.namprd06.prod.outlook.com (10.175.117.142) X-MS-Office365-Filtering-Correlation-Id: 0368a65f-7fc3-4d3d-c2be-08d48431189c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:CY4PR06MB2774; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2774; 3:0QHpp/5hVPRdRL0S2mgO05vVHf9pZkLo7T/AoqgF5YfdivztHteGENTtbhysjUuK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WWojCOgroWwOHv9YWBYYZC1UpAKeEA3FHDVdi7Ni60751/0V51eq1QLZvdMPdx4a94wMcGor31gbfbIvp2LPCAb47isrWiJquFU2twnJxUMmQOFY5+oYG3rPF8MICI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(6041248)(20161123564025)(20161123562025)(20161123560025)(201703131423075)(201703061421075)(20161123555025)(6072148); SRVR:CY4PR06MB2774; BCL:0; PCL:0; RULEID:; SRVR:CY4PR06MB2774; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2774; 4:o4Jbw1IaXg55apLtCMgM14uwkZUEEjdanxhZP74iLlKorR5/Y48sZMZtTYV1OpdJ38+yPKQYAwg7m4FKTb8CWc9iul2ZhCB2ZWO3lw1zfJC4EJAkuEjYjd9rDSsBPq/VBZjlHwcZ+rP2E8NCZ8VNBZ74dThUxdXtm+2WhMf6F/zAqin6P60dybMPraSLezbyUtx1wXRf9O7EVglW0/1VYTw1msO68Yn/jEm8EVZIORJd0dnI7ae9fpoJ83BUo6z4y0i2T/89xFEExwhiAvVhtmYXPLKWUNdUnMpgltha5+E9sI20/rR7eqP4+bvWCigSpW5KkAf1y0bGUXsg6JPaWFI5MeD82Jn01ZzHrP3q/tGN0724qEmCvvD+7D8/UtzDpy/dbuMjIrgxNt//RXIMxuzosGfjLDgq+ZfGw/W7jGrbc2qRnhGUCKatEg7ND2WSQz/6Y/ymo0ALLNgnmsOUE1CJJxH4CqGRTPGqihVUsv0LGzbZy7heCJy5CeehIXbXLAbxOZ6C1UTGeVN3zhSwrPWOy9BsMMFWLm4gU7dBZbTr6NyiMdTrpj7QEaZTfBDxalxtK7Cj7PYEUkGbSlLStKRH6Rh0S+08QRnmQfkTkeK1eCa6SakkPDRvpW/Eduu3PvLbrV2j6fZ2TmllG7ARlOwPIG0jp0sLhI4bl18FRwpQCKKdlo3KLjUkQfrsQPjb X-Forefront-PRVS: 02788FF38E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39400400002)(39450400003)(86362001)(305945005)(1076002)(6916009)(6666003)(25786009)(2950100002)(6486002)(2906002)(3846002)(6116002)(2870700001)(54906002)(189998001)(53936002)(53416004)(107886003)(110136004)(5660300001)(38730400002)(50986999)(76176999)(2351001)(4326008)(66066001)(5820100001)(23676002)(81166006)(47776003)(42186005)(36756003)(33646002)(50226002)(8676002)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR06MB2774; H:skyninja.cnexlabs.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjA2TUIyNzc0OzIzOmYxbEpldCtjbmRRSkNJdThhQ0pOVmZyYVFv?= =?utf-8?B?ZFJxbHdmS1dCTEE5bUZ5ajFGQWdGWkJ0cFNPYWZpMkcwVnFENG1WYkIzbThw?= =?utf-8?B?MFB2eDdBc2JFZVB1NDJxV0daNWhiNWw4YjRhbWZRK3BnQ0hiRlZaNVA1eEFV?= =?utf-8?B?YVJIdlVQVEptclF2TXg5aHMzNm1nZUJiVndteTBnSTdXOWFNRW8vVFZtT29n?= =?utf-8?B?V05veVM0amc4Y25aRm94cVJXR0FuLzhzQ0hpODRrdFdlUnlTZGZhdU1jUlVQ?= =?utf-8?B?dllsbUJLS3BFT3JjcEtLSlR4NFFIcllLUHpnWG1Md1VuQ2ZubmZuMDdjQlZv?= =?utf-8?B?VHNMY290MGpOMEp4TGZlcTFsRnpnMEUrUy9ha1A4RUFXZDFqclRaVG1iNm1s?= =?utf-8?B?V2pLMTd6Y00vd29jeHBsb1N6ZVA1eWRNbVFrdmYzY3FQM0tBUkt3NkJnei9M?= =?utf-8?B?MjhwVUhIR2E1WVlDUC9qdVAvOUo2VDUrVXJsUUxQL2FsZUNHK3lLdmZ4MDhI?= =?utf-8?B?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q14Q8OjXeBCws9ECKOQ== X-OriginatorOrg: cnexlabs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2017 18:56:15.5513 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR06MB2774 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 Until now erases have been submitted as synchronous commands through a dedicated erase function. In order to enable targets implementing asynchronous erases, refactor the erase path so that it uses the normal async I/O submission functions. If a target requires sync I/O, it can implement it internally. Also, adapt rrpc to use the new erase path. Signed-off-by: Javier González Fixed spelling error. Signed-off-by: Matias Bjørling Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 54 +++++++++++++++++++++++++++----------------- drivers/lightnvm/rrpc.c | 3 +-- drivers/nvme/host/lightnvm.c | 32 ++++++++------------------ include/linux/lightnvm.h | 8 +++---- 4 files changed, 47 insertions(+), 50 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 5262ba6..95105c4 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -590,11 +590,11 @@ 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_set_rqd_ppalist(tgt_dev, &rqd, ppas, nr_ppas, 1); 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); + nvm_free_rqd_ppalist(tgt_dev, &rqd); if (ret) { pr_err("nvm: failed bb mark\n"); return -EINVAL; @@ -626,34 +626,45 @@ int nvm_submit_io(struct nvm_tgt_dev *tgt_dev, struct nvm_rq *rqd) } EXPORT_SYMBOL(nvm_submit_io); -int nvm_erase_blk(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *ppas, int flags) +static void nvm_end_io_sync(struct nvm_rq *rqd) { - struct nvm_dev *dev = tgt_dev->parent; + struct completion *waiting = rqd->private; + + complete(waiting); +} + +int nvm_erase_sync(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *ppas, + int nr_ppas) +{ + struct nvm_geo *geo = &tgt_dev->geo; struct nvm_rq rqd; int ret; - - if (!dev->ops->erase_block) - return 0; - - nvm_map_to_dev(tgt_dev, ppas); + DECLARE_COMPLETION_ONSTACK(wait); memset(&rqd, 0, sizeof(struct nvm_rq)); - ret = nvm_set_rqd_ppalist(dev, &rqd, ppas, 1, 1); + rqd.opcode = NVM_OP_ERASE; + rqd.end_io = nvm_end_io_sync; + rqd.private = &wait; + rqd.flags = geo->plane_mode >> 1; + + ret = nvm_set_rqd_ppalist(tgt_dev, &rqd, ppas, nr_ppas, 1); if (ret) return ret; - nvm_rq_tgt_to_dev(tgt_dev, &rqd); + ret = nvm_submit_io(tgt_dev, &rqd); + if (ret) { + pr_err("rrpr: erase I/O submission failed: %d\n", ret); + goto free_ppa_list; + } + wait_for_completion_io(&wait); - rqd.flags = flags; - - ret = dev->ops->erase_block(dev, &rqd); - - nvm_free_rqd_ppalist(dev, &rqd); +free_ppa_list: + nvm_free_rqd_ppalist(tgt_dev, &rqd); return ret; } -EXPORT_SYMBOL(nvm_erase_blk); +EXPORT_SYMBOL(nvm_erase_sync); int nvm_get_l2p_tbl(struct nvm_tgt_dev *tgt_dev, u64 slba, u32 nlb, nvm_l2p_update_fn *update_l2p, void *priv) @@ -732,10 +743,11 @@ void nvm_put_area(struct nvm_tgt_dev *tgt_dev, sector_t begin) } EXPORT_SYMBOL(nvm_put_area); -int nvm_set_rqd_ppalist(struct nvm_dev *dev, struct nvm_rq *rqd, +int nvm_set_rqd_ppalist(struct nvm_tgt_dev *tgt_dev, struct nvm_rq *rqd, const struct ppa_addr *ppas, int nr_ppas, int vblk) { - struct nvm_geo *geo = &dev->geo; + struct nvm_dev *dev = tgt_dev->parent; + struct nvm_geo *geo = &tgt_dev->geo; int i, plane_cnt, pl_idx; struct ppa_addr ppa; @@ -773,12 +785,12 @@ int nvm_set_rqd_ppalist(struct nvm_dev *dev, struct nvm_rq *rqd, } EXPORT_SYMBOL(nvm_set_rqd_ppalist); -void nvm_free_rqd_ppalist(struct nvm_dev *dev, struct nvm_rq *rqd) +void nvm_free_rqd_ppalist(struct nvm_tgt_dev *tgt_dev, struct nvm_rq *rqd) { if (!rqd->ppa_list) return; - nvm_dev_dma_free(dev, rqd->ppa_list, rqd->dma_ppa_list); + nvm_dev_dma_free(tgt_dev->parent, rqd->ppa_list, rqd->dma_ppa_list); } EXPORT_SYMBOL(nvm_free_rqd_ppalist); diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index e68efbc..4e4c299 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -414,7 +414,6 @@ static void rrpc_block_gc(struct work_struct *work) struct rrpc *rrpc = gcb->rrpc; struct rrpc_block *rblk = gcb->rblk; struct rrpc_lun *rlun = rblk->rlun; - struct nvm_tgt_dev *dev = rrpc->dev; struct ppa_addr ppa; mempool_free(gcb, rrpc->gcb_pool); @@ -430,7 +429,7 @@ static void rrpc_block_gc(struct work_struct *work) ppa.g.lun = rlun->bppa.g.lun; ppa.g.blk = rblk->id; - if (nvm_erase_blk(dev, &ppa, 0)) + if (nvm_erase_sync(rrpc->dev, &ppa, 1)) goto put_back; rrpc_put_blk(rrpc, rblk); diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index fd98954..4ea9c93 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -510,12 +510,16 @@ static int nvme_nvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd) } rq->cmd_flags &= ~REQ_FAILFAST_DRIVER; - rq->ioprio = bio_prio(bio); - if (bio_has_data(bio)) - rq->nr_phys_segments = bio_phys_segments(q, bio); - - rq->__data_len = bio->bi_iter.bi_size; - rq->bio = rq->biotail = bio; + if (bio) { + rq->ioprio = bio_prio(bio); + rq->__data_len = bio->bi_iter.bi_size; + rq->bio = rq->biotail = bio; + if (bio_has_data(bio)) + rq->nr_phys_segments = bio_phys_segments(q, bio); + } else { + rq->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM); + rq->__data_len = 0; + } nvme_nvm_rqtocmd(rq, rqd, ns, cmd); @@ -526,21 +530,6 @@ static int nvme_nvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd) return 0; } -static int nvme_nvm_erase_block(struct nvm_dev *dev, struct nvm_rq *rqd) -{ - struct request_queue *q = dev->q; - struct nvme_ns *ns = q->queuedata; - struct nvme_nvm_command c = {}; - - c.erase.opcode = NVM_OP_ERASE; - c.erase.nsid = cpu_to_le32(ns->ns_id); - c.erase.spba = cpu_to_le64(rqd->ppa_addr.ppa); - c.erase.length = cpu_to_le16(rqd->nr_ppas - 1); - c.erase.control = cpu_to_le16(rqd->flags); - - return nvme_submit_sync_cmd(q, (struct nvme_command *)&c, NULL, 0); -} - static void *nvme_nvm_create_dma_pool(struct nvm_dev *nvmdev, char *name) { struct nvme_ns *ns = nvmdev->q->queuedata; @@ -576,7 +565,6 @@ static struct nvm_dev_ops nvme_nvm_dev_ops = { .set_bb_tbl = nvme_nvm_set_bb_tbl, .submit_io = nvme_nvm_submit_io, - .erase_block = nvme_nvm_erase_block, .create_dma_pool = nvme_nvm_create_dma_pool, .destroy_dma_pool = nvme_nvm_destroy_dma_pool, diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index ca45e4a..e11163f 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -56,7 +56,6 @@ typedef int (nvm_get_l2p_tbl_fn)(struct nvm_dev *, u64, u32, typedef int (nvm_op_bb_tbl_fn)(struct nvm_dev *, struct ppa_addr, u8 *); typedef int (nvm_op_set_bb_fn)(struct nvm_dev *, struct ppa_addr *, int, int); typedef int (nvm_submit_io_fn)(struct nvm_dev *, struct nvm_rq *); -typedef int (nvm_erase_blk_fn)(struct nvm_dev *, struct nvm_rq *); typedef void *(nvm_create_dma_pool_fn)(struct nvm_dev *, char *); typedef void (nvm_destroy_dma_pool_fn)(void *); typedef void *(nvm_dev_dma_alloc_fn)(struct nvm_dev *, void *, gfp_t, @@ -70,7 +69,6 @@ struct nvm_dev_ops { nvm_op_set_bb_fn *set_bb_tbl; nvm_submit_io_fn *submit_io; - nvm_erase_blk_fn *erase_block; nvm_create_dma_pool_fn *create_dma_pool; nvm_destroy_dma_pool_fn *destroy_dma_pool; @@ -479,10 +477,10 @@ 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 int nvm_set_rqd_ppalist(struct nvm_dev *, struct nvm_rq *, +extern int nvm_erase_sync(struct nvm_tgt_dev *, struct ppa_addr *, int); +extern int nvm_set_rqd_ppalist(struct nvm_tgt_dev *, struct nvm_rq *, const struct ppa_addr *, int, int); -extern void nvm_free_rqd_ppalist(struct nvm_dev *, struct nvm_rq *); -extern int nvm_erase_blk(struct nvm_tgt_dev *, struct ppa_addr *, int); +extern void nvm_free_rqd_ppalist(struct nvm_tgt_dev *, struct nvm_rq *); extern int nvm_get_l2p_tbl(struct nvm_tgt_dev *, u64, u32, nvm_l2p_update_fn *, void *); extern int nvm_get_area(struct nvm_tgt_dev *, sector_t *, sector_t);