All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Cc: Maciej Ramotowski <maciej.ramotowski@intel.com>
Subject: [ndctl PATCH] ndctl, create-namespace: fix minimum alignment detection
Date: Sat, 03 Mar 2018 13:49:07 -0800	[thread overview]
Message-ID: <152011374766.14937.7017387737157056826.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)

Commit 0c31ce0a2875 "ndctl, create-namespace: fix --align= default..."
tried to make casual testing with nfit_test easier by auto-detecting the
alignment. However, this auto-detection always falls back to 4K
alignment on kernels that do not export the region 'resource' attribute.
Those kernels, like v4.9.4, may also be missing this fix: commit
cd755677d944 "libnvdimm, pfn: fix memmap reservation size versus 4K
alignment".

Given the chance to fail to initialize a namespace in the 4K case on
older kernels, be more conservative about falling back to 4K alignment.

Link: https://github.com/pmem/ndctl/issues/34
Reported-by: Maciej Ramotowski <maciej.ramotowski@intel.com>
Fixes: 0c31ce0a2875 ("ndctl, create-namespace: fix --align= default...")
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/namespace.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index ceb9e7a9b8af..aef356abbee1 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -462,7 +462,7 @@ static int validate_namespace_options(struct ndctl_region *region,
 		struct ndctl_namespace *ndns, struct parsed_parameters *p)
 {
 	const char *region_name = ndctl_region_get_devname(region);
-	unsigned long long size_align = SZ_4K, units = 1;
+	unsigned long long size_align = SZ_4K, units = 1, resource;
 	unsigned int ways;
 	int rc = 0;
 
@@ -563,8 +563,9 @@ static int validate_namespace_options(struct ndctl_region *region,
 		 * the nfit_test use case where it is backed by vmalloc
 		 * memory.
 		 */
-		if (param.align_default && (ndctl_region_get_resource(region)
-					& (SZ_2M - 1))) {
+		resource = ndctl_region_get_resource(region);
+		if (param.align_default && resource < ULLONG_MAX
+				&& (resource & (SZ_2M - 1))) {
 			debug("%s: falling back to a 4K alignment\n",
 					region_name);
 			p->align = SZ_4K;

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

             reply	other threads:[~2018-03-03 21:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-03 21:49 Dan Williams [this message]
2018-03-06  0:38 ` [ndctl PATCH] ndctl, create-namespace: fix minimum alignment detection Verma, Vishal L

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=152011374766.14937.7017387737157056826.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=maciej.ramotowski@intel.com \
    /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.