diff mbox

[ndctl,07/13] ndctl: alias "sector" and "safe" namespace modes

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

Commit Message

Dan Williams Jan. 28, 2016, 10:52 p.m. UTC
Linda notes that the "safe" label gives the impression that the other
modes are not safe, i.e. dangerous.  While that is not the intent it
remains true that "safe" is an accurate description especially if the
use case of persistent memory is for applications that are not prepared
for torn writes.  However, lets de-emphasize "safe" and use "sector"
mode in the example and accept it is an alias for "safe" mode.

Reported-by: Linda Knippers <linda.knippers@hpe.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 Documentation/ndctl-create-namespace.txt |   39 +++++++++++++++---------------
 builtin-xaction-namespace.c              |    4 ++-
 2 files changed, 23 insertions(+), 20 deletions(-)
diff mbox

Patch

diff --git a/Documentation/ndctl-create-namespace.txt b/Documentation/ndctl-create-namespace.txt
index 3a9f911c231c..8d919255e04f 100644
--- a/Documentation/ndctl-create-namespace.txt
+++ b/Documentation/ndctl-create-namespace.txt
@@ -19,9 +19,9 @@  Create a maximally sized pmem namespace in 'memory' mode
 [verse]
 ndctl create-namespace
 
-Convert namespace0.0 to 'safe' mode
+Convert namespace0.0 to 'sector' mode
 [verse]
-ndctl create-namespace -f -e namespace0.0 --mode=safe
+ndctl create-namespace -f -e namespace0.0 --mode=sector
 
 OPTIONS
 -------
@@ -38,16 +38,24 @@  OPTIONS
 
 -m::
 --mode=::
-	- "safe": persistent memory, given that it is byte addressable,
-	  does not support sector atomicity.  The problematic aspect of
-	  sector tearing is that most applications do not know they have
-	  a atomic sector update dependency.  At least a disk rarely
-	  ever tears sectors and if it does it almost certainly returns
-	  a checksum error on access.  Persistent memory devices will
-	  always tear and always silently.  Until an application is
-	  audited to be robust in the presence of sector-tearing "safe"
-	  mode is recommended.  This imposes some performance overhead
-	  and disables the DAX capability.
+	- "raw": expose the namespace capacity directly with some
+	  limitations.  Neither a raw pmem namepace nor raw blk namespace
+	  support sector atomicity by default (see "sector" mode below).  A
+	  raw pmem namespace may have limited support for passing a DAX
+	  mapping to other syscalls.  I.e. direct-I/O to/from a DAX buffer
+	  may fail for a pmem namespace in raw mode.
+
+	- "sector" or "safe": persistent memory, given that it is byte
+	  addressable, does not support sector atomicity.  The
+	  problematic aspect of sector tearing is that most applications
+	  do not know they have a atomic sector update dependency.  At
+	  least a disk rarely ever tears sectors and if it does it
+	  almost certainly returns a checksum error on access.
+	  Persistent memory devices will always tear and always
+	  silently.  Until an application is audited to be robust in the
+	  presence of sector-tearing "safe" mode is recommended.  This
+	  imposes some performance overhead and disables the DAX
+	  capability.
 
 	- "memory": A pmem namespace in this mode supports direct I/O
 	  to/from DAX mappings.  Depending on the kernel this mode may
@@ -56,13 +64,6 @@  OPTIONS
 	  "System RAM" or from a reserved portion of pmem (see the --map=
 	  option).
 
-	- "raw": expose the namespace capacity directly with some
-	  limitations.  Neither a raw pmem namepace nor raw blk namespace
-	  support sector atomicity by default (see "safe" mode below).  A
-	  raw pmem namespace may have limited support for passing a DAX
-	  mapping to other syscalls.  I.e. direct-I/O to/from a DAX buffer
-	  may fail for a pmem namespace in raw mode.
-
 -s::
 --size=::
 	For NVDIMM devices that support namespace labels, set the
diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c
index fdf20dfc01af..1d7e460e0950 100644
--- a/builtin-xaction-namespace.c
+++ b/builtin-xaction-namespace.c
@@ -79,7 +79,7 @@  OPT_STRING('n', "name", &param.name, "name", \
 OPT_STRING('s', "size", &param.size, "size", \
 	"specify the namespace size in bytes (default: available capacity)"), \
 OPT_STRING('m', "mode", &param.mode, "operation-mode", \
-	"specify a mode for the namespace, 'safe', 'memory', or 'raw'"), \
+	"specify a mode for the namespace, 'sector', 'memory', or 'raw'"), \
 OPT_STRING('M', "map", &param.map, "memmap-location", \
 	"specify 'mem' or 'dev' for the location of the memmap"), \
 OPT_STRING('l', "sector-size", &param.sector_size, "lba-size", \
@@ -332,6 +332,8 @@  static int validate_namespace_options(struct ndctl_namespace *ndns,
 	if (param.mode) {
 		if (strcmp(param.mode, "memory") == 0)
 			p->mode = NDCTL_NS_MODE_MEMORY;
+		else if (strcmp(param.mode, "sector") == 0)
+			p->mode = NDCTL_NS_MODE_SAFE;
 		else if (strcmp(param.mode, "safe") == 0)
 			p->mode = NDCTL_NS_MODE_SAFE;
 		else