diff mbox

[ndctl] ndctl: create-namespace fix pfn setup

Message ID 20160130191050.17974.70738.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit 01e204d9893d
Headers show

Commit Message

Dan Williams Jan. 30, 2016, 7:10 p.m. UTC
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 <jmoyer@redhat.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 builtin-xaction-namespace.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
diff mbox

Patch

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);