From patchwork Tue Jan 12 06:49:30 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: 8014141 X-Patchwork-Delegate: axboe@kernel.dk Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4DC189F6FA for ; Tue, 12 Jan 2016 06:56:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 74BDF20379 for ; Tue, 12 Jan 2016 06:56:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 91044201F4 for ; Tue, 12 Jan 2016 06:56:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761547AbcALGvX (ORCPT ); Tue, 12 Jan 2016 01:51:23 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:38658 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761167AbcALGuP (ORCPT ); Tue, 12 Jan 2016 01:50:15 -0500 Received: by mail-wm0-f51.google.com with SMTP id b14so303597404wmb.1 for ; Mon, 11 Jan 2016 22:50:14 -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-type:content-transfer-encoding; bh=2DHCOzkQFHzb5NY/xetO0XEcPYBF5/aAbBzkbopsCIs=; b=VTcHHIISBnl0V0RMvpWa0kaulH3LUOYwydMMTlt2iHXey4na1VnXkp7vLbtE6YzPrF eAbGPacr5E8fWj/mfU0hc26klHbU7Pc48iG+caAlXC42Qw5sUIGU9DSAMC2M5f9ppFEu d0U7JHY2Ru6wS6+07G0nFKtqtcM1yMDO2eCGI= 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-type:content-transfer-encoding; bh=2DHCOzkQFHzb5NY/xetO0XEcPYBF5/aAbBzkbopsCIs=; b=JnIz8VIh+XLFtNsSV921lAORSftkdKtZeRkZMewhs994Wu1VaHpPJe5VlfLdnPBqAU DlR04XPkQNxqAd4w63gYcPObAnpZ/NPYr9aaw2hULuEK0piP+4LVbAtYV5kQolD7F13u eyOjluVb/xoV1KMg3EJ/BBXrv1YwhXVdFUFsXXKsbWtRtSZMpukoVHmt1bf4jFQhcQkV p/TzJv+6MYwaid3gs0mQWkBzwGp0MMHMYm29CYjvdPIDN5608oiwc4qHpRTpEwQfKpdY aXDoA/I1rZan3Fe1PLE02uBI4nw1TQQXZbQf4K5Y5qu23KPZaFyOuIVWw1PnRQASthUa Ctgw== X-Gm-Message-State: ALoCoQmx4fjMIQa0Rzchc1FDV3SEDvvSEyatoGJoC3l6e/L+GJyIQZfCp4GzbulXqjjdb1rHMLCeV65+bll0CKJQHD/bvmXAbA== X-Received: by 10.28.126.84 with SMTP id z81mr18248494wmc.29.1452581413926; Mon, 11 Jan 2016 22:50:13 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id yz5sm70776886wjc.36.2016.01.11.22.50.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Jan 2016 22:50:12 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 16/25] lightnvm: introduce nvm_submit_ppa Date: Tue, 12 Jan 2016 07:49:30 +0100 Message-Id: <1452581379-18162-17-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452581379-18162-1-git-send-email-m@bjorling.me> References: <1452581379-18162-1-git-send-email-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-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 | 45 ++++++++++++++++++++++++++++++++++++++++++++- include/linux/lightnvm.h | 2 ++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index dad84dd..dc83e01 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -296,7 +296,7 @@ void nvm_end_io(struct nvm_rq *rqd, int error) } EXPORT_SYMBOL(nvm_end_io); -static void nvm_end_io_sync(struct nvm_rq *rqd, int errors) +static void nvm_end_io_sync(struct nvm_rq *rqd) { struct completion *waiting = rqd->wait; @@ -305,6 +305,49 @@ static void nvm_end_io_sync(struct nvm_rq *rqd, int errors) complete(waiting); } +int nvm_submit_ppa(struct nvm_dev *dev, struct ppa_addr *ppa, int nr_ppas, + int opcode, int flags, void *buf, int len) +{ + DECLARE_COMPLETION_ONSTACK(wait); + struct nvm_rq rqd; + struct bio *bio; + int ret; + unsigned long hang_check; + + 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, nr_ppas); + if (ret) { + bio_put(bio); + return ret; + } + + rqd.opcode = opcode; + rqd.bio = bio; + rqd.wait = &wait; + rqd.dev = dev; + rqd.end_io = nvm_end_io_sync; + rqd.flags = flags; + nvm_generic_to_addr_mode(dev, &rqd); + + ret = dev->ops->submit_io(dev, &rqd); + + /* Prevent hang_check timer from firing at us during very long I/O */ + hang_check = sysctl_hung_task_timeout_secs; + if (hang_check) + while (!wait_for_completion_io_timeout(&wait, hang_check * (HZ/2))); + else + wait_for_completion_io(&wait); + + nvm_free_rqd_ppalist(dev, &rqd); + + return rqd.error; +} +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 9acc71a..b700148 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -440,6 +440,8 @@ extern void nvm_free_rqd_ppalist(struct nvm_dev *, struct nvm_rq *); extern int nvm_erase_ppa(struct nvm_dev *, struct ppa_addr *, int); extern int nvm_erase_blk(struct nvm_dev *, struct nvm_block *); 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); #else /* CONFIG_NVM */ struct nvm_dev_ops;