All of lore.kernel.org
 help / color / mirror / Atom feed
* [ndctl PATCH 0/6] ndctl: 'write-labels' and other misc updates
@ 2017-03-28 23:13 Dan Williams
  2017-03-28 23:13 ` [ndctl PATCH 1/6] ndctl: drop "builtin" prefix from source file names Dan Williams
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Dan Williams @ 2017-03-28 23:13 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Nicholas Moulin

The primary change is the creation of a new 'write-labels' utility that
can replay the output from 'read-labels' back onto a given device
(nmem). This capability is then used to regression test label
compatibility.

Unrelated to write-labels support this series also takes the opportunity
to:

* clean up the source file names for the ndctl utility commands
* add some missing documentation
* fixup the summary output of dimm-related commands

---

Dan Williams (6):
      ndctl: drop "builtin" prefix from source file names
      Documentation, list: add --device-dax, -X description to man page
      Documentation, list: add --mode, -m description to man page
      ndctl, dimm: add 'write-labels' command
      ndctl, dimm: fix count display in the presence of errors
      test: add interleave set compatibility test


 Documentation/ndctl-list.txt      |   28 ++++++++
 builtin.h                         |    1 
 ndctl/Makefile.am                 |   16 ++--
 ndctl/bat.c                       |    0 
 ndctl/check.c                     |    0 
 ndctl/create-nfit.c               |    0 
 ndctl/dimm.c                      |  138 +++++++++++++++++++++++++++++++++----
 ndctl/list.c                      |    0 
 ndctl/namespace.c                 |    0 
 ndctl/ndctl.c                     |    1 
 ndctl/region.c                    |    0 
 ndctl/test.c                      |    0 
 test/Makefile.am                  |   11 ++-
 test/label-compat.sh              |   61 ++++++++++++++++
 test/nmem1.bin                    |  Bin
 test/nmem2.bin                    |  Bin
 test/nmem3.bin                    |  Bin
 test/nmem4.bin                    |  Bin
 18 files changed, 228 insertions(+), 28 deletions(-)
 rename ndctl/{builtin-bat.c => bat.c} (100%)
 rename ndctl/{builtin-check.c => check.c} (100%)
 rename ndctl/{builtin-create-nfit.c => create-nfit.c} (100%)
 rename ndctl/{builtin-dimm.c => dimm.c} (88%)
 rename ndctl/{builtin-list.c => list.c} (100%)
 rename ndctl/{builtin-xaction-namespace.c => namespace.c} (100%)
 rename ndctl/{builtin-xable-region.c => region.c} (100%)
 rename ndctl/{builtin-test.c => test.c} (100%)
 create mode 100755 test/label-compat.sh
 create mode 100644 test/nmem1.bin
 create mode 100644 test/nmem2.bin
 create mode 100644 test/nmem3.bin
 create mode 100644 test/nmem4.bin
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ndctl PATCH 1/6] ndctl: drop "builtin" prefix from source file names
  2017-03-28 23:13 [ndctl PATCH 0/6] ndctl: 'write-labels' and other misc updates Dan Williams
@ 2017-03-28 23:13 ` Dan Williams
  2017-03-28 23:14 ` [ndctl PATCH 2/6] Documentation, list: add --device-dax, -X description to man page Dan Williams
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Dan Williams @ 2017-03-28 23:13 UTC (permalink / raw)
  To: linux-nvdimm

The "builtin" designation is a hold over from the initial duplication of
git infrastructure where builtin commands are differentiated from shell
helper commands. Since ndctl only has the former the prefix is not
useful.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/Makefile.am                 |   16 ++++++++--------
 ndctl/bat.c                       |    0 
 ndctl/check.c                     |    0 
 ndctl/create-nfit.c               |    0 
 ndctl/dimm.c                      |    0 
 ndctl/list.c                      |    0 
 ndctl/namespace.c                 |    0 
 ndctl/region.c                    |    0 
 ndctl/test.c                      |    0 
 test/Makefile.am                  |    8 ++++----
 10 files changed, 12 insertions(+), 12 deletions(-)
 rename ndctl/{builtin-bat.c => bat.c} (100%)
 rename ndctl/{builtin-check.c => check.c} (100%)
 rename ndctl/{builtin-create-nfit.c => create-nfit.c} (100%)
 rename ndctl/{builtin-dimm.c => dimm.c} (100%)
 rename ndctl/{builtin-list.c => list.c} (100%)
 rename ndctl/{builtin-xaction-namespace.c => namespace.c} (100%)
 rename ndctl/{builtin-xable-region.c => region.c} (100%)
 rename ndctl/{builtin-test.c => test.c} (100%)

diff --git a/ndctl/Makefile.am b/ndctl/Makefile.am
index f9158d9cce63..d346c041d74b 100644
--- a/ndctl/Makefile.am
+++ b/ndctl/Makefile.am
@@ -3,14 +3,14 @@ include $(top_srcdir)/Makefile.am.in
 bin_PROGRAMS = ndctl
 
 ndctl_SOURCES = ndctl.c \
-		builtin-create-nfit.c \
-		builtin-xaction-namespace.c \
-		builtin-check.c \
-		builtin-xable-region.c \
-		builtin-dimm.c \
+		create-nfit.c \
+		namespace.c \
+		check.c \
+		region.c \
+		dimm.c \
 		 ../util/log.c \
-		builtin-list.c \
-		builtin-test.c \
+		list.c \
+		test.c \
 		../util/json.c
 
 if ENABLE_SMART
@@ -20,7 +20,7 @@ endif
 if ENABLE_DESTRUCTIVE
 ndctl_SOURCES += ../test/blk_namespaces.c \
 		 ../test/pmem_namespaces.c
-ndctl_SOURCES += builtin-bat.c
+ndctl_SOURCES += bat.c
 endif
 
 ndctl_LDADD =\
diff --git a/ndctl/builtin-bat.c b/ndctl/bat.c
similarity index 100%
rename from ndctl/builtin-bat.c
rename to ndctl/bat.c
diff --git a/ndctl/builtin-check.c b/ndctl/check.c
similarity index 100%
rename from ndctl/builtin-check.c
rename to ndctl/check.c
diff --git a/ndctl/builtin-create-nfit.c b/ndctl/create-nfit.c
similarity index 100%
rename from ndctl/builtin-create-nfit.c
rename to ndctl/create-nfit.c
diff --git a/ndctl/builtin-dimm.c b/ndctl/dimm.c
similarity index 100%
rename from ndctl/builtin-dimm.c
rename to ndctl/dimm.c
diff --git a/ndctl/builtin-list.c b/ndctl/list.c
similarity index 100%
rename from ndctl/builtin-list.c
rename to ndctl/list.c
diff --git a/ndctl/builtin-xaction-namespace.c b/ndctl/namespace.c
similarity index 100%
rename from ndctl/builtin-xaction-namespace.c
rename to ndctl/namespace.c
diff --git a/ndctl/builtin-xable-region.c b/ndctl/region.c
similarity index 100%
rename from ndctl/builtin-xable-region.c
rename to ndctl/region.c
diff --git a/ndctl/builtin-test.c b/ndctl/test.c
similarity index 100%
rename from ndctl/builtin-test.c
rename to ndctl/test.c
diff --git a/test/Makefile.am b/test/Makefile.am
index 3fdd2272b4eb..969fe055b35e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -79,8 +79,8 @@ device_dax_SOURCES = \
 		dax-dev.c \
 		dax-pmd.c \
 		$(testcore) \
-		../ndctl/builtin-xaction-namespace.c \
-		../ndctl/builtin-check.c \
+		../ndctl/namespace.c \
+		../ndctl/check.c \
 		../util/json.c
 device_dax_LDADD = \
 		$(LIBNDCTL_LIB) \
@@ -91,8 +91,8 @@ device_dax_LDADD = \
 multi_pmem_SOURCES = \
 		multi-pmem.c \
 		$(testcore) \
-		../ndctl/builtin-xaction-namespace.c \
-		../ndctl/builtin-check.c \
+		../ndctl/namespace.c \
+		../ndctl/check.c \
 		../util/json.c
 multi_pmem_LDADD = \
 		$(LIBNDCTL_LIB) \

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [ndctl PATCH 2/6] Documentation, list: add --device-dax, -X description to man page
  2017-03-28 23:13 [ndctl PATCH 0/6] ndctl: 'write-labels' and other misc updates Dan Williams
  2017-03-28 23:13 ` [ndctl PATCH 1/6] ndctl: drop "builtin" prefix from source file names Dan Williams
@ 2017-03-28 23:14 ` Dan Williams
  2017-03-28 23:14 ` [ndctl PATCH 3/6] Documentation, list: add --mode, -m " Dan Williams
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Dan Williams @ 2017-03-28 23:14 UTC (permalink / raw)
  To: linux-nvdimm

Document the new option added in commit 10663a60d723 "ndctl, list: add
'--device-dax' option".

Reported-by: Linda Knippers <linda.knippers@hpe.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 Documentation/ndctl-list.txt |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/Documentation/ndctl-list.txt b/Documentation/ndctl-list.txt
index 2e362e818bbc..bb7db47e7af8 100644
--- a/Documentation/ndctl-list.txt
+++ b/Documentation/ndctl-list.txt
@@ -105,6 +105,29 @@ include::xable-region-options.txt[]
   }
 }
 
+-X::
+--device-dax::
+	Include device-dax ("daxregion") details when a namespace is in
+	"dax" mode.
+[verse]
+{
+  "dev":"namespace0.0",
+  "mode":"dax",
+  "size":4225761280,
+  "uuid":"18ae1bbb-bb62-4efc-86df-4a5caacb5dcc",
+  "daxregion":{
+    "id":0,
+    "size":4225761280,
+    "align":2097152,
+    "devices":[
+      {
+        "chardev":"dax0.0",
+        "size":4225761280
+      }
+    ]
+  }
+}
+
 -R::
 --regions::
 	Include region info in the listing

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [ndctl PATCH 3/6] Documentation, list: add --mode, -m description to man page
  2017-03-28 23:13 [ndctl PATCH 0/6] ndctl: 'write-labels' and other misc updates Dan Williams
  2017-03-28 23:13 ` [ndctl PATCH 1/6] ndctl: drop "builtin" prefix from source file names Dan Williams
  2017-03-28 23:14 ` [ndctl PATCH 2/6] Documentation, list: add --device-dax, -X description to man page Dan Williams
@ 2017-03-28 23:14 ` Dan Williams
  2017-03-28 23:14 ` [ndctl PATCH 4/6] ndctl, dimm: add 'write-labels' command Dan Williams
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Dan Williams @ 2017-03-28 23:14 UTC (permalink / raw)
  To: linux-nvdimm

Document the new option added in commit b17f21f7fae7 "ndctl, list: add
option to filter namespace by mode".

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 Documentation/ndctl-list.txt |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/ndctl-list.txt b/Documentation/ndctl-list.txt
index bb7db47e7af8..444a6f998f19 100644
--- a/Documentation/ndctl-list.txt
+++ b/Documentation/ndctl-list.txt
@@ -78,6 +78,11 @@ include::xable-region-options.txt[]
 --type=::
 	Filter listing by region type ('pmem' or 'blk')
 
+-m::
+--mode=::
+	Filter listing by the mode ('raw', 'memory', 'sector' or 'dax')
+	of the namespace(s).
+
 -B::
 --buses::
 	Include bus info in the listing

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [ndctl PATCH 4/6] ndctl, dimm: add 'write-labels' command
  2017-03-28 23:13 [ndctl PATCH 0/6] ndctl: 'write-labels' and other misc updates Dan Williams
                   ` (2 preceding siblings ...)
  2017-03-28 23:14 ` [ndctl PATCH 3/6] Documentation, list: add --mode, -m " Dan Williams
@ 2017-03-28 23:14 ` Dan Williams
  2017-03-28 23:14 ` [ndctl PATCH 5/6] ndctl, dimm: fix count display in the presence of errors Dan Williams
  2017-03-28 23:14 ` [ndctl PATCH 6/6] test: add interleave set compatibility test Dan Williams
  5 siblings, 0 replies; 7+ messages in thread
From: Dan Williams @ 2017-03-28 23:14 UTC (permalink / raw)
  To: linux-nvdimm

Given that read-labels can take a binary image of a dimm's labels,
provide a way for that image to be written back. The motivation for this
change is the ability to unit test compatibility with legacy namespace
formats like Linux "memcmp order isetcookie" namespaces.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 builtin.h     |    1 
 ndctl/dimm.c  |  132 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 ndctl/ndctl.c |    1 
 3 files changed, 122 insertions(+), 12 deletions(-)

diff --git a/builtin.h b/builtin.h
index 200bd8ebbdc9..a8bc848614f2 100644
--- a/builtin.h
+++ b/builtin.h
@@ -20,6 +20,7 @@ int cmd_enable_dimm(int argc, const char **argv, void *ctx);
 int cmd_disable_dimm(int argc, const char **argv, void *ctx);
 int cmd_zero_labels(int argc, const char **argv, void *ctx);
 int cmd_read_labels(int argc, const char **argv, void *ctx);
+int cmd_write_labels(int argc, const char **argv, void *ctx);
 int cmd_init_labels(int argc, const char **argv, void *ctx);
 int cmd_check_labels(int argc, const char **argv, void *ctx);
 int cmd_list(int argc, const char **argv, void *ctx);
diff --git a/ndctl/dimm.c b/ndctl/dimm.c
index 93f95308bd1e..b20a84911489 100644
--- a/ndctl/dimm.c
+++ b/ndctl/dimm.c
@@ -72,6 +72,7 @@ static const char NSINDEX_SIGNATURE[] = "NAMESPACE_INDEX\0";
 struct action_context {
 	struct json_object *jdimms;
 	FILE *f_out;
+	FILE *f_in;
 };
 
 static int action_disable(struct ndctl_dimm *dimm, struct action_context *actx)
@@ -268,23 +269,36 @@ static struct json_object *dump_json(struct ndctl_dimm *dimm,
 	return NULL;
 }
 
-static int dump_bin(FILE *f_out, struct ndctl_cmd *cmd_read, ssize_t size)
+static int rw_bin(FILE *f, struct ndctl_cmd *cmd, ssize_t size, int rw)
 {
 	char buf[4096];
-	ssize_t offset;
+	ssize_t offset, write = 0;
 
 	for (offset = 0; offset < size; offset += sizeof(buf)) {
 		ssize_t len = min_t(ssize_t, sizeof(buf), size - offset), rc;
 
-		len = ndctl_cmd_cfg_read_get_data(cmd_read, buf, len, offset);
-		if (len < 0)
-			return len;
-		rc = fwrite(buf, 1, len, f_out);
-		if (rc != len)
-			return -ENXIO;
-		fflush(f_out);
+		if (rw) {
+			len = fread(buf, 1, len, f);
+			if (len == 0)
+				break;
+			rc = ndctl_cmd_cfg_write_set_data(cmd, buf, len, offset);
+			if (rc < 0)
+				return -ENXIO;
+			write += len;
+		} else {
+			len = ndctl_cmd_cfg_read_get_data(cmd, buf, len, offset);
+			if (len < 0)
+				return len;
+			rc = fwrite(buf, 1, len, f);
+			if (rc != len)
+				return -ENXIO;
+			fflush(f);
+		}
 	}
 
+	if (write)
+		return ndctl_cmd_submit(cmd);
+
 	return 0;
 }
 
@@ -322,6 +336,49 @@ static struct ndctl_cmd *read_labels(struct ndctl_dimm *dimm)
 	return NULL;
 }
 
+static int action_write(struct ndctl_dimm *dimm, struct action_context *actx)
+{
+	struct ndctl_cmd *cmd_read, *cmd_write;
+	ssize_t size;
+	int rc = 0;
+
+	if (ndctl_dimm_is_active(dimm)) {
+		fprintf(stderr, "dimm is active, abort label write\n");
+		return -EBUSY;
+	}
+
+	cmd_read = read_labels(dimm);
+	if (!cmd_read)
+		return -ENXIO;
+
+	cmd_write = ndctl_dimm_cmd_new_cfg_write(cmd_read);
+	if (!cmd_write) {
+		ndctl_cmd_unref(cmd_read);
+		return -ENXIO;
+	}
+
+	size = ndctl_cmd_cfg_read_get_size(cmd_read);
+	rc = rw_bin(actx->f_in, cmd_write, size, 1);
+
+	/*
+	 * If the dimm is already disabled the kernel is not holding a cached
+	 * copy of the label space.
+	 */
+	if (!ndctl_dimm_is_enabled(dimm))
+		goto out;
+
+	rc = ndctl_dimm_disable(dimm);
+	if (rc)
+		goto out;
+	rc = ndctl_dimm_enable(dimm);
+
+ out:
+	ndctl_cmd_unref(cmd_read);
+	ndctl_cmd_unref(cmd_write);
+
+	return rc;
+}
+
 static int action_read(struct ndctl_dimm *dimm, struct action_context *actx)
 {
 	struct ndctl_cmd *cmd_read;
@@ -341,7 +398,7 @@ static int action_read(struct ndctl_dimm *dimm, struct action_context *actx)
 		else
 			rc = -ENOMEM;
 	} else
-		rc = dump_bin(actx->f_out, cmd_read, size);
+		rc = rw_bin(actx->f_out, cmd_read, size, 0);
 
 	ndctl_cmd_unref(cmd_read);
 
@@ -631,6 +688,7 @@ static int label_write_index(struct nvdimm_data *ndd, int index, u32 seq)
 static struct parameters {
 	const char *bus;
 	const char *outfile;
+	const char *infile;
 	bool force;
 	bool json;
 	bool verbose;
@@ -736,6 +794,10 @@ OPT_STRING('o', NULL, &param.outfile, "output-file", \
 	"filename to write label area contents"), \
 OPT_BOOLEAN('j', "json", &param.json, "parse label data into json")
 
+#define WRITE_OPTIONS() \
+OPT_STRING('i', NULL, &param.infile, "input-file", \
+	"filename to read label area data")
+
 #define INIT_OPTIONS() \
 OPT_BOOLEAN('f', "force", &param.force, \
 		"force initialization even if existing index-block present")
@@ -746,6 +808,12 @@ static const struct option read_options[] = {
 	OPT_END(),
 };
 
+static const struct option write_options[] = {
+	BASE_OPTIONS(),
+	WRITE_OPTIONS(),
+	OPT_END(),
+};
+
 static const struct option base_options[] = {
 	BASE_OPTIONS(),
 	OPT_END(),
@@ -761,8 +829,9 @@ static int dimm_action(int argc, const char **argv, void *ctx,
 		int (*action)(struct ndctl_dimm *dimm, struct action_context *actx),
 		const struct option *options, const char *usage)
 {
-	struct action_context actx = { NULL, NULL };
+	struct action_context actx = { 0 };
 	int i, rc = 0, count = 0, err = 0;
+	struct ndctl_dimm *single = NULL;
 	const char * const u[] = {
 		usage,
 		NULL
@@ -810,6 +879,18 @@ static int dimm_action(int argc, const char **argv, void *ctx,
 		}
 	}
 
+	if (!param.infile)
+		actx.f_in = stdin;
+	else {
+		actx.f_in = fopen(param.infile, "r");
+		if (!actx.f_in) {
+			fprintf(stderr, "failed to open: %s: (%s)\n",
+					param.infile, strerror(errno));
+			rc = -errno;
+			goto out;
+		}
+	}
+
 	if (param.verbose)
 		ndctl_set_log_priority(ctx, LOG_DEBUG);
 
@@ -830,7 +911,12 @@ static int dimm_action(int argc, const char **argv, void *ctx,
 			ndctl_dimm_foreach(bus, dimm) {
 				if (!util_dimm_filter(dimm, argv[i]))
 					continue;
-				rc = action(dimm, &actx);
+				if (action == action_write) {
+					single = dimm;
+					rc = 0;
+				} else
+					rc = action(dimm, &actx);
+
 				if (rc == 0)
 					count++;
 				else if (rc && !err)
@@ -840,6 +926,15 @@ static int dimm_action(int argc, const char **argv, void *ctx,
 	}
 	rc = err;
 
+	if (action == action_write) {
+		if (count > 1) {
+			error("write-labels only supports writing a single dimm\n");
+			usage_with_options(u, options);
+			return -EINVAL;
+		} else if (single)
+			rc = action(single, &actx);
+	}
+
 	if (actx.jdimms) {
 		util_display_json_array(actx.f_out, actx.jdimms,
 				JSON_C_TO_STRING_PRETTY);
@@ -849,6 +944,9 @@ static int dimm_action(int argc, const char **argv, void *ctx,
 	if (actx.f_out != stdout)
 		fclose(actx.f_out);
 
+	if (actx.f_in != stdin)
+		fclose(actx.f_in);
+
  out:
 	/*
 	 * count if some actions succeeded, 0 if none were attempted,
@@ -859,6 +957,16 @@ static int dimm_action(int argc, const char **argv, void *ctx,
 	return count;
 }
 
+int cmd_write_labels(int argc, const char **argv, void *ctx)
+{
+	int count = dimm_action(argc, argv, ctx, action_write, write_options,
+			"ndctl write-labels <nmem> [-i <filename>]");
+
+	fprintf(stderr, "wrote %d nmem%s\n", count >= 0 ? count : 0,
+			count > 1 ? "s" : "");
+	return count >= 0 ? 0 : EXIT_FAILURE;
+}
+
 int cmd_read_labels(int argc, const char **argv, void *ctx)
 {
 	int count = dimm_action(argc, argv, ctx, action_read, read_options,
diff --git a/ndctl/ndctl.c b/ndctl/ndctl.c
index 0678a9a29bfb..4b08c9b2a8ff 100644
--- a/ndctl/ndctl.c
+++ b/ndctl/ndctl.c
@@ -64,6 +64,7 @@ static struct cmd_struct commands[] = {
 	{ "disable-dimm", cmd_disable_dimm },
 	{ "zero-labels", cmd_zero_labels },
 	{ "read-labels", cmd_read_labels },
+	{ "write-labels", cmd_write_labels },
 	{ "init-labels", cmd_init_labels },
 	{ "check-labels", cmd_check_labels },
 	{ "list", cmd_list },

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [ndctl PATCH 5/6] ndctl, dimm: fix count display in the presence of errors
  2017-03-28 23:13 [ndctl PATCH 0/6] ndctl: 'write-labels' and other misc updates Dan Williams
                   ` (3 preceding siblings ...)
  2017-03-28 23:14 ` [ndctl PATCH 4/6] ndctl, dimm: add 'write-labels' command Dan Williams
@ 2017-03-28 23:14 ` Dan Williams
  2017-03-28 23:14 ` [ndctl PATCH 6/6] test: add interleave set compatibility test Dan Williams
  5 siblings, 0 replies; 7+ messages in thread
From: Dan Williams @ 2017-03-28 23:14 UTC (permalink / raw)
  To: linux-nvdimm

The dimm commands return zero when some operations succeed, return the
count separately from the error code.

    Before:
    # ndctl zero-labels all
    zeroed 0 nmem

    After:
    # ndctl zero-labels all
    zeroed 6 nmems

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

diff --git a/ndctl/dimm.c b/ndctl/dimm.c
index b20a84911489..4d25417fb2ae 100644
--- a/ndctl/dimm.c
+++ b/ndctl/dimm.c
@@ -952,9 +952,9 @@ static int dimm_action(int argc, const char **argv, void *ctx,
 	 * count if some actions succeeded, 0 if none were attempted,
 	 * negative error code otherwise.
 	 */
-	if (rc < 0)
-		return rc;
-	return count;
+	if (count > 0)
+		return count;
+	return rc;
 }
 
 int cmd_write_labels(int argc, const char **argv, void *ctx)

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [ndctl PATCH 6/6] test: add interleave set compatibility test
  2017-03-28 23:13 [ndctl PATCH 0/6] ndctl: 'write-labels' and other misc updates Dan Williams
                   ` (4 preceding siblings ...)
  2017-03-28 23:14 ` [ndctl PATCH 5/6] ndctl, dimm: fix count display in the presence of errors Dan Williams
@ 2017-03-28 23:14 ` Dan Williams
  5 siblings, 0 replies; 7+ messages in thread
From: Dan Williams @ 2017-03-28 23:14 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Nicholas Moulin

Per the realization that Linux was incompatible with other
implementations of the interleave-set-cookie algorithm [1], add a
regression test to check for compatibility with the original Linux
implementation.

This also serves as a unit test for the new 'write-labels' command.

[1]: commit 86ef58a4e35e ("nfit, libnvdimm: fix interleave set cookie calculation")

Reported-by: Nicholas Moulin <nicholas.w.moulin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/Makefile.am     |    3 ++
 test/label-compat.sh |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++
 test/nmem1.bin       |  Bin
 test/nmem2.bin       |  Bin
 test/nmem3.bin       |  Bin
 test/nmem4.bin       |  Bin
 6 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100755 test/label-compat.sh
 create mode 100644 test/nmem1.bin
 create mode 100644 test/nmem2.bin
 create mode 100644 test/nmem3.bin
 create mode 100644 test/nmem4.bin

diff --git a/test/Makefile.am b/test/Makefile.am
index 969fe055b35e..d2a0cf9fe2ba 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -9,7 +9,8 @@ TESTS =\
 	create.sh \
 	clear.sh \
 	dax-errors.sh \
-	btt-check.sh
+	btt-check.sh \
+	label-compat.sh
 
 check_PROGRAMS =\
 	libndctl \
diff --git a/test/label-compat.sh b/test/label-compat.sh
new file mode 100755
index 000000000000..f103f64ae7ff
--- /dev/null
+++ b/test/label-compat.sh
@@ -0,0 +1,61 @@
+#!/bin/bash -x
+NDCTL="../ndctl/ndctl"
+BUS="-b nfit_test.0"
+BUS1="-b nfit_test.1"
+rc=77
+
+set -e
+
+err() {
+	echo "test/label-compat.sh: failed at line $1"
+	exit $rc
+}
+
+check_min_kver()
+{
+	local ver="$1"
+	: "${KVER:=$(uname -r)}"
+
+	[ -n "$ver" ] || return 1
+	[[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)" ]]
+}
+
+check_min_kver "4.11" || { echo "kernel $KVER may not provide reliable isetcookie values"; exit $rc; }
+
+set -e
+trap 'err $LINENO' ERR
+
+# setup (reset nfit_test dimms)
+modprobe nfit_test
+$NDCTL disable-region $BUS all
+$NDCTL zero-labels $BUS all
+
+# grab the largest pmem region on $BUS
+query=". | sort_by(.available_size) | reverse | .[0].dev"
+region=$($NDCTL list $BUS -t pmem -Ri | jq -r "$query")
+
+# we assume that $region is comprised of 4 dimms
+query=". | .regions[0].mappings | sort_by(.dimm) | .[].dimm"
+dimms=$($NDCTL list -DRi -r $region | jq -r "$query" | xargs)
+i=1
+for d in $dimms
+do
+	$NDCTL write-labels $d -i nmem${i}.bin
+	i=$((i+1))
+done
+
+$NDCTL enable-region $BUS all
+
+len=$($NDCTL list -r 7 -N | jq -r "length")
+
+if [ -z $len ]; then
+	rc=1
+	echo "failed to find legacy isetcookie namespace"
+	exit 1
+fi
+
+$NDCTL disable-region $BUS all
+$NDCTL disable-region $BUS1 all
+modprobe -r nfit_test
+
+exit 0
diff --git a/test/nmem1.bin b/test/nmem1.bin
new file mode 100644
index 0000000000000000000000000000000000000000..1ef8dfd802e6735073230f7e6a8ec3365c555f39
GIT binary patch
literal 131072
zcmeIuF=_%)6a~;f8HFss71*ZH(nc^kg++!y8aoS{Y{4D51|i#+WC@m5B1%lY=x?Hh
z*l6IqVYs{p19MN=dnw*td;MZOEC<CXoJ@ASq<lE+>pX-kK6$tOH5*JeKewHe-@f!v
zp6MT}?aLh|<#7#v`qyLsr{QF?`=|ZiTg%S0@!XwP&5zmlqDnQd&Byp*Exy}b$Uay3
zeod1kQ>MElK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U
zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7
z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N
z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+
z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly
zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF
z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk
z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs
z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ
zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U
zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7
J2oSg<fnS9n8x8;f

literal 0
HcmV?d00001

diff --git a/test/nmem2.bin b/test/nmem2.bin
new file mode 100644
index 0000000000000000000000000000000000000000..adf45b5c586667e77f83f74b0574adc7369f0df4
GIT binary patch
literal 131072
zcmeIuF=_%)6a~;f8HFss71*ZH(nc^kg++!y8aoS{Y{4D51|i#+WC@m5B1%lY=x?Hh
z*l6IqUtHdUfw`yby%cY+y?!wsmV;sxP9{5EQa&8^bsj<%U*2th%?6Xr&u!=Aw=X@E
zXZpu#`*Md#d0fMv{`J`ZX*k*J{%QaB*0M8gJa^|+^JDhCs8Y>q^D%x{i+I~z$Uay3
zeod1kQ>MElK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U
zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7
z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N
z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+
z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly
zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF
z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk
z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs
z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ
zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U
zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7
J2oSg<fnS2?8xH^g

literal 0
HcmV?d00001

diff --git a/test/nmem3.bin b/test/nmem3.bin
new file mode 100644
index 0000000000000000000000000000000000000000..bf7334e28cbc26accbcfbb79bcedf8a8f7a9000b
GIT binary patch
literal 131072
zcmeIuF=_%)6a~;f8HFss71*ZH(nc^kg++!y8aoS{Y{4D51|i#+WC@m5B1%lY=x?Hh
z*l6IqUtHdUfw`yby%cY+y?!wsmV;sxP9{5EQa&8^bsj<%U*2th%?6Xr&u!=Aw=X@E
zXZpu#`*Md#d0fMv{`J`ZX*k*J{%QaB*0M8gJa^|+^JDhCs8Y>q^D%x{i%8pD$Uay3
zeod1kQ>MElK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U
zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7
z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N
z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+
z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly
zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF
z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk
z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs
z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ
zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U
zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7
J2oSg<fnR{I8xQ~h

literal 0
HcmV?d00001

diff --git a/test/nmem4.bin b/test/nmem4.bin
new file mode 100644
index 0000000000000000000000000000000000000000..24485122e9d8ecfc25ab6b27449c76a2b4f527bf
GIT binary patch
literal 131072
zcmeIuF=_%)6a~;fnFv`xR$yxrOB=z&DW-4`Z0u6lxCM9Q8iZ_PbP1MLAt;WH=x;Pd
zNRtTX{o?W-49q=6Z;*|Ky|?T=FZ$Uy+)Q%0#C$mKUug(Q{nBoGHSbThhrgYh-~Q>L
z_@;kd?NshOF)wSl>ffmQxAMuhy3_vCmrZB({MucV&5!whUB;Tf&8Paq$B>3y6_Vv=
zdRpT|$(Zpj2@oJafB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk
z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs
z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ
zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U
zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7
z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N
z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+
z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly
zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF
z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk
z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs
K0Rja6k-!mtcpDJ_

literal 0
HcmV?d00001


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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-03-28 23:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-28 23:13 [ndctl PATCH 0/6] ndctl: 'write-labels' and other misc updates Dan Williams
2017-03-28 23:13 ` [ndctl PATCH 1/6] ndctl: drop "builtin" prefix from source file names Dan Williams
2017-03-28 23:14 ` [ndctl PATCH 2/6] Documentation, list: add --device-dax, -X description to man page Dan Williams
2017-03-28 23:14 ` [ndctl PATCH 3/6] Documentation, list: add --mode, -m " Dan Williams
2017-03-28 23:14 ` [ndctl PATCH 4/6] ndctl, dimm: add 'write-labels' command Dan Williams
2017-03-28 23:14 ` [ndctl PATCH 5/6] ndctl, dimm: fix count display in the presence of errors Dan Williams
2017-03-28 23:14 ` [ndctl PATCH 6/6] test: add interleave set compatibility test Dan Williams

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.