From patchwork Thu Feb 4 14:13:27 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: 8222311 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C4C86BEEE5 for ; Thu, 4 Feb 2016 14:14:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E23E720397 for ; Thu, 4 Feb 2016 14:14:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA75020395 for ; Thu, 4 Feb 2016 14:14:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965703AbcBDON7 (ORCPT ); Thu, 4 Feb 2016 09:13:59 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:37867 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965015AbcBDONm (ORCPT ); Thu, 4 Feb 2016 09:13:42 -0500 Received: by mail-wm0-f54.google.com with SMTP id g62so6362413wme.0 for ; Thu, 04 Feb 2016 06:13:41 -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=HXqJNa66ZazfyURYJNrbQwTdTb8CPxkRhr6oc6d5xsw=; b=xKct+ldAUUizrCZh3+bWGLyR0PJuQRk6EA/GGEo9DOrC0bB+NMKIiLwAnvVxipJYtr EvPTFoq2I+B0zPYRF6Qm8xJ/G3TsL8nTRAJ5C6Nl9YbzwQMeE5neOmULBACOgVgR2PR1 mafzsFM0QP1NVxZKmszWgUnDhxodFmEfjRQwk= 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=HXqJNa66ZazfyURYJNrbQwTdTb8CPxkRhr6oc6d5xsw=; b=DwyVfcbc6L0xhWDEWfdqrwUX/l711iBwKgmTRvAt9P2n7Jamzj/74ZEuw5DaLyxaEm PAZCwZiJs5pIXAxO0OdF4CvjzbkCRLcJuRytrpIUkM3vuyfQIN3MqmNqBI3w6l0Q64UJ nnc7NQ7+hDmJRLP5b/58QLHIDy8sSPB/k4vF8SVe2iURpe/0HD/gOwzlUFW5fO5aavY1 ybPU42DcmvEGyPrmNutrGe55gwTwktqQh3ja7PMDCxDnHWgUqfGaeNRBki4fstvd1eQp AkBnpdrm91uEx+nq625D8lOZV0p2e7pqdmLc+WG+/fxkA6AVWbXlEsLdyZc9byIv4PDY jZSg== X-Gm-Message-State: AG10YOSR9vJngBW0T6iH41hg6jSRK8prGm0NO3q17CdnYz/QwdNpi/Zr/FKWcAiQ6JHR7g== X-Received: by 10.28.65.193 with SMTP id o184mr29785920wma.15.1454595221431; Thu, 04 Feb 2016 06:13:41 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id u130sm26390332wmg.15.2016.02.04.06.13.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Feb 2016 06:13:40 -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 5/5] lightnvm: allow to force mm initialization Date: Thu, 4 Feb 2016 15:13:27 +0100 Message-Id: <1454595207-22432-6-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1454595207-22432-1-git-send-email-m@bjorling.me> References: <1454595207-22432-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=-7.2 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 System block allows the device to initialize with its configured media manager. The system blocks is written to disk, and read again when media manager is determined. For this to work, the backend must store the data. Device drivers, such as null_blk, does not have any backend storage. This patch allows the media manager to be initialized without a storage backend. It also fix incorrect configuration of capabilities in null_blk, as it does not support get/set bad block interface. Signed-off-by: Matias Bjørling --- drivers/block/null_blk.c | 2 +- drivers/lightnvm/core.c | 25 ++++++++++++++++--------- include/linux/lightnvm.h | 4 ++++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 8ba1e97..ae05d31 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -478,7 +478,7 @@ static int null_lnvm_id(struct nvm_dev *dev, struct nvm_id *id) id->ver_id = 0x1; id->vmnt = 0; id->cgrps = 1; - id->cap = 0x3; + id->cap = 0x2; id->dom = 0x1; id->ppaf.blk_offset = 0; diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 5471cc5..c3d4b54 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -568,11 +568,13 @@ int nvm_register(struct request_queue *q, char *disk_name, } } - ret = nvm_get_sysblock(dev, &dev->sb); - if (!ret) - pr_err("nvm: device not initialized.\n"); - else if (ret < 0) - pr_err("nvm: err (%d) on device initialization\n", ret); + if (dev->identity.cap & NVM_ID_DCAP_BBLKMGMT) { + ret = nvm_get_sysblock(dev, &dev->sb); + if (!ret) + pr_err("nvm: device not initialized.\n"); + else if (ret < 0) + pr_err("nvm: err (%d) on device initialization\n", ret); + } /* register device with a supported media manager */ down_write(&nvm_lock); @@ -1051,9 +1053,11 @@ static long __nvm_ioctl_dev_init(struct nvm_ioctl_dev_init *init) strncpy(info.mmtype, init->mmtype, NVM_MMTYPE_LEN); info.fs_ppa.ppa = -1; - ret = nvm_init_sysblock(dev, &info); - if (ret) - return ret; + if (dev->identity.cap & NVM_ID_DCAP_BBLKMGMT) { + ret = nvm_init_sysblock(dev, &info); + if (ret) + return ret; + } memcpy(&dev->sb, &info, sizeof(struct nvm_sb_info)); @@ -1113,7 +1117,10 @@ static long nvm_ioctl_dev_factory(struct file *file, void __user *arg) dev->mt = NULL; } - return nvm_dev_factory(dev, fact.flags); + if (dev->identity.cap & NVM_ID_DCAP_BBLKMGMT) + return nvm_dev_factory(dev, fact.flags); + + return 0; } static long nvm_ctl_ioctl(struct file *file, uint cmd, unsigned long arg) diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index b94f2d5..08c1e14 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -135,6 +135,10 @@ enum { /* Memory types */ NVM_ID_FMTYPE_SLC = 0, NVM_ID_FMTYPE_MLC = 1, + + /* Device capabilities */ + NVM_ID_DCAP_BBLKMGMT = 0x1, + NVM_UD_DCAP_ECC = 0x2, }; struct nvm_id_lp_mlc {