All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Subject: [ndctl PATCH 8/8] ndctl, create-namespace: check for ZONE_DEVICE=n kernels
Date: Fri, 22 Apr 2016 12:47:43 -0700	[thread overview]
Message-ID: <146135446379.4228.7996799346697687015.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <146135442234.4228.904225076597683142.stgit@dwillia2-desk3.amr.corp.intel.com>

When a kernel does not support ZONE_DEVICE it is unable to support
pfn-device configurations.  Use the absence of a pfn-seed as the
indicator of this configuration to fail the operation with an error
rather than crashing.

Reported-by: Linda Knippers <linda.knippers@hpe.com>
Reported-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 builtin-xaction-namespace.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c
index 6ae8d7aee849..6ff969cd696e 100644
--- a/builtin-xaction-namespace.c
+++ b/builtin-xaction-namespace.c
@@ -38,6 +38,7 @@ static bool verbose;
 static bool force;
 static struct parameters {
 	bool do_scan;
+	bool mode_default;
 	const char *bus;
 	const char *map;
 	const char *type;
@@ -153,6 +154,7 @@ static int set_defaults(enum namespace_action mode)
 			param.mode = "memory";
 		else
 			param.mode = "safe";
+		param.mode_default = true;
 	}
 
 	if (param.map) {
@@ -428,6 +430,22 @@ static int validate_namespace_options(struct ndctl_namespace *ndns,
 	} else if (p->mode == NDCTL_NS_MODE_MEMORY)
 		p->loc = NDCTL_PFN_LOC_PMEM;
 
+	/* check if we need, and whether the kernel supports, pfn devices */
+	if (do_setup_pfn(ndns, p)) {
+		struct ndctl_region *region;
+		struct ndctl_pfn *pfn;
+
+		region = ndctl_namespace_get_region(ndns);
+		pfn = ndctl_region_get_pfn_seed(region);
+		if (!pfn && param.mode_default) {
+			debug("memory mode not available\n");
+			p->mode = NDCTL_NS_MODE_RAW;
+		} else if (!pfn) {
+			error("operation failed, memory mode not available\n");
+			return -EINVAL;
+		}
+	}
+
 	return 0;
 }
 

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

      parent reply	other threads:[~2016-04-22 19:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-22 19:47 [ndctl PATCH 0/8] create-namespace fixes, and a misc build fix Dan Williams
2016-04-22 19:47 ` [ndctl PATCH 1/8] ndctl, create-namespace: make zero_info_block() more robust Dan Williams
2016-04-22 19:47 ` [ndctl PATCH 2/8] ndctl: new 'destroy-namespace' utility Dan Williams
2016-04-22 19:47 ` [ndctl PATCH 3/8] ndctl: fix build on systems where /bin/sh is not a link to bash Dan Williams
2016-04-22 19:47 ` [ndctl PATCH 4/8] ndctl, create-namespace: report failures due to namespace being mounted Dan Williams
2016-04-22 23:00   ` Linda Knippers
2016-04-22 23:10     ` Dan Williams
2016-04-22 19:47 ` [ndctl PATCH 5/8] ndctl, xaction-namespace: make 'verbose' option available in all sub-commands Dan Williams
2016-04-22 19:47 ` [ndctl PATCH 6/8] ndctl, create-namespace: fix memmap location reconfiguration Dan Williams
2016-04-22 19:47 ` [ndctl PATCH 7/8] ndctl, create-namespace: fix sector mode default for pmem namespaces Dan Williams
2016-04-22 23:07   ` Linda Knippers
2016-04-22 19:47 ` Dan Williams [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=146135446379.4228.7996799346697687015.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.