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 6/6] ndctl, create-namespace: set pmem namespace sector size
Date: Wed, 05 Jul 2017 13:49:07 -0700	[thread overview]
Message-ID: <149928774707.25150.9359431758968306936.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <149928771519.25150.13314997328838983545.stgit@dwillia2-desk3.amr.corp.intel.com>

Starting with v1.2 namespace labels, the "lbasize" field is expected to
be non-zero for all namespace types.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/namespace.c |   40 +++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index c28d00193a62..778a65d02c2a 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -244,18 +244,14 @@ static int set_defaults(enum namespace_action mode)
 			error("invalid sector size: %s\n", param.sector_size);
 			rc = -EINVAL;
 		}
-
-		if (param.type && param.mode && strcmp(param.type, "pmem") == 0
-				&& strcmp(param.mode, "safe") != 0) {
-			error("'pmem' namespaces do not support setting 'sector size'\n");
-			rc = -EINVAL;
-		}
-	} else if (!param.reconfig
-			&& ((param.type && strcmp(param.type, "blk") == 0)
+	} else if (!param.reconfig) {
+		if ((param.type && strcmp(param.type, "blk") == 0)
 				|| (param.mode
-					&& strcmp(param.mode, "safe") == 0))) {
+					&& strcmp(param.mode, "safe") == 0))
 			/* default sector size for blk-type or safe-mode */
 			param.sector_size = "4096";
+		else
+			param.sector_size = "512";
 	}
 
 	return rc;
@@ -356,7 +352,7 @@ static int setup_namespace(struct ndctl_region *region,
 		try(ndctl_namespace, set_size, ndns, p->size);
 	}
 
-	if (ndctl_namespace_get_type(ndns) == ND_DEVICE_NAMESPACE_BLK)
+	if (p->sector_size)
 		try(ndctl_namespace, set_sector_size, ndns, p->sector_size);
 
 	uuid_generate(uuid);
@@ -608,22 +604,36 @@ static int validate_namespace_options(struct ndctl_region *region,
 				if (ndctl_namespace_get_supported_sector_size(seed, i)
 						== p->sector_size)
 					break;
-			if (i >= num) {
+			if (i >= num)
 				debug("%s: does not support namespace sector_size %lu\n",
 						region_name, p->sector_size);
+
+			/*
+			 * Pre-4.13 kernels did not support sector sizes
+			 * for pmem namespaces. Revert to the zero
+			 * default in that case.
+			 */
+			if (i >= num && ndctl_region_get_type(region)
+					!= ND_DEVICE_REGION_BLK
+					&& (p->sector_size == 512
+						|| p->sector_size == 4096)) {
+				debug("%s: revert to default sector size\n",
+						region_name);
+				p->sector_size = 0;
+			} else if (i >= num)
 				return -EINVAL;
-			}
 		}
 	} else if (ndns) {
 		struct ndctl_btt *btt = ndctl_namespace_get_btt(ndns);
 
 		if (btt)
 			p->sector_size = ndctl_btt_get_sector_size(btt);
-		else if (ndctl_namespace_get_type(ndns)
-				== ND_DEVICE_NAMESPACE_BLK)
-			p->sector_size = ndctl_namespace_get_sector_size(ndns);
 		else if (p->mode == NDCTL_NS_MODE_SAFE)
 				p->sector_size = 4096;
+		else
+			p->sector_size = ndctl_namespace_get_sector_size(ndns);
+		if (p->sector_size == UINT_MAX)
+			p->sector_size = 0;
 	}
 
 	if (param.map) {

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

      parent reply	other threads:[~2017-07-05 20:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-05 20:48 [ndctl PATCH 0/6] ndctl updates for v1.2 namespace labels Dan Williams
2017-07-05 20:48 ` [ndctl PATCH 1/6] ndctl, test: push btt-check test back to 4.14 Dan Williams
2017-07-05 20:48 ` [ndctl PATCH 2/6] ndctl, test: unit test new pmem sector_size support Dan Williams
2017-07-05 20:48 ` [ndctl PATCH 3/6] ndctl: update to latest ndctl.h Dan Williams
2017-07-05 20:48 ` [ndctl PATCH 4/6] ndctl, read-labels: updates for v1.2 of the namespace specification Dan Williams
2017-07-05 20:49 ` [ndctl PATCH 5/6] ndctl, init-labels: allow opt-in to new v1.2 label format Dan Williams
2017-07-05 20:49 ` 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=149928774707.25150.9359431758968306936.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.