From patchwork Sat Jan 30 19:10:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 8172281 Return-Path: X-Original-To: patchwork-linux-nvdimm@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 98948BEEE5 for ; Sat, 30 Jan 2016 19:11:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C6FB320265 for ; Sat, 30 Jan 2016 19:11:17 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08A952024F for ; Sat, 30 Jan 2016 19:11:17 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id F126A1A2513; Sat, 30 Jan 2016 11:11:16 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ml01.01.org (Postfix) with ESMTP id 5C3261A2513 for ; Sat, 30 Jan 2016 11:11:15 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 30 Jan 2016 11:11:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,371,1449561600"; d="scan'208";a="892760627" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.136]) by fmsmga001.fm.intel.com with ESMTP; 30 Jan 2016 11:11:15 -0800 Subject: [ndctl PATCH] ndctl: create-namespace fix pfn setup From: Dan Williams To: linux-nvdimm@lists.01.org Date: Sat, 30 Jan 2016 11:10:50 -0800 Message-ID: <20160130191050.17974.70738.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, 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 e820-defined persistent memory is in memory mode by default. For the 'memmap in pmem' case we need to instantiate a pfn instance. Reported-by: Jeff Moyer Signed-off-by: Dan Williams --- builtin-xaction-namespace.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c index 3c4c3e8da255..eb16aaaf5ee7 100644 --- a/builtin-xaction-namespace.c +++ b/builtin-xaction-namespace.c @@ -239,6 +239,21 @@ do { \ } \ } while (0) +static bool do_setup_pfn(struct ndctl_namespace *ndns, + struct parsed_parameters *p) +{ + if (p->mode != NDCTL_NS_MODE_MEMORY) + return false; + + if (ndctl_namespace_get_mode(ndns) != NDCTL_NS_MODE_MEMORY) + return true; + + if (p->loc == NDCTL_PFN_LOC_PMEM) + return true; + + return false; +} + static int setup_namespace(struct ndctl_region *region, struct ndctl_namespace *ndns, struct parsed_parameters *p) { @@ -255,8 +270,7 @@ static int setup_namespace(struct ndctl_region *region, try(ndctl_namespace, set_sector_size, ndns, p->sector_size); uuid_generate(uuid); - if (ndctl_namespace_get_mode(ndns) != NDCTL_NS_MODE_MEMORY - && p->mode == NDCTL_NS_MODE_MEMORY) { + if (do_setup_pfn(ndns, p)) { struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region); try(ndctl_pfn, set_uuid, pfn, uuid);