Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932533AbbLNNSa (ORCPT ); Mon, 14 Dec 2015 08:18:30 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:34637 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932394AbbLNNRf (ORCPT ); Mon, 14 Dec 2015 08:17:35 -0500 From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH RFC 4/5] lightnvm: introduce nvm_submit_ppa Date: Mon, 14 Dec 2015 14:17:06 +0100 Message-Id: <1450099027-24745-5-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1450099027-24745-1-git-send-email-m@bjorling.me> References: <1450099027-24745-1-git-send-email-m@bjorling.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2399 Lines: 76 Internal logic for both core and media managers, does not have a backing bio for issuing I/Os. Introduce nvm_submit_ppa to allow raw I/Os to be submitted to the underlying device driver. The function request the device, ppa, data buffer and its length and will submit the I/O synchronously to the device. The return value may therefore be used to detect any errors regarding the issued I/O. Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 31 +++++++++++++++++++++++++++++++ include/linux/lightnvm.h | 1 + 2 files changed, 32 insertions(+) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 081b0f5..77a9907 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -288,6 +288,37 @@ int nvm_erase_ppa(struct nvm_dev *dev, struct ppa_addr ppa) } EXPORT_SYMBOL(nvm_erase_ppa); +int nvm_submit_ppa(struct nvm_dev *dev, struct ppa_addr ppa, int opcode, + void *buf, int len) +{ + struct nvm_rq rqd; + struct bio *bio; + int ret; + + bio = bio_map_kern(dev->q, buf, len, GFP_KERNEL); + if (IS_ERR_OR_NULL(bio)) + return -ENOMEM; + + memset(&rqd, 0, sizeof(struct nvm_rq)); + ret = nvm_set_rqd_ppalist(dev, &rqd, &ppa, 1); + if (ret) { + bio_put(bio); + return ret; + } + + rqd.opcode = opcode; + rqd.flags = NVM_IO_F_SYNC; + rqd.bio = bio; + nvm_generic_to_addr_mode(dev, &rqd); + + ret = dev->ops->submit_io(dev, &rqd); + + nvm_free_rqd_ppalist(dev, &rqd); + + return ret; +} +EXPORT_SYMBOL(nvm_submit_ppa); + static int nvm_core_init(struct nvm_dev *dev) { struct nvm_id *id = &dev->identity; diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 770278a..0017d55 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -437,6 +437,7 @@ 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); extern int nvm_erase_blk(struct nvm_dev *, struct nvm_block *); +extern int nvm_submit_ppa(struct nvm_dev *, struct ppa_addr, int, void *, int); #else /* CONFIG_NVM */ struct nvm_dev_ops; -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/