Linux-NVDIMM Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [ndctl PATCH 0/6] multi-device-dax support and other fixes
@ 2017-07-19 18:32 Dan Williams
  2017-07-19 18:33 ` [ndctl PATCH 1/6] ndctl, daxctl: propagate loglevel to internal libdaxctl instance Dan Williams
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Dan Williams @ 2017-07-19 18:32 UTC (permalink / raw)
  To: linux-nvdimm

A test report highlighted the fact that the unit tests never verified
that multiple-namespaces in a region could be in device-dax mode. This
was fixed in the kernel [1], but there is some fallout to handle in
ndctl and daxctl:

1/ teach libdaxctl that there may be multiple dax-region instances that
   share the same region-id

2/ update 'ndctl list' to assume that there will only ever be one
   device-dax instance per-namespace and emit the "chardev" by default
   (Linda).

3/ fix 'daxctl list' to differentiate regions by path, since 'id' may be
   duplicated.

4/ add a regression test for multi-dax configurations

---

Dan Williams (6):
      ndctl, daxctl: propagate loglevel to internal libdaxctl instance
      daxctl: stop carrying 'dax_region' in the daxctl_region region_path
      daxctl: fix support for multiple instances per-region id
      ndctl, list: emit device-dax 'chardev' by default
      daxctl, list: clarify output when multiple regions share an id
      test: add multi-dax test


 daxctl/lib/libdaxctl.c   |   78 ++++++++++++++++++++++++++++++++++------------
 daxctl/lib/libdaxctl.sym |    5 +++
 daxctl/libdaxctl.h       |    2 +
 daxctl/list.c            |    2 +
 ndctl/lib/libndctl.c     |    2 +
 ndctl/list.c             |    2 +
 ndctl/namespace.c        |    2 +
 test/Makefile.am         |    1 +
 test/multi-dax.sh        |   61 ++++++++++++++++++++++++++++++++++++
 util/json.c              |   34 ++++++++++++++++++--
 util/json.h              |    3 +-
 11 files changed, 165 insertions(+), 27 deletions(-)
 create mode 100755 test/multi-dax.sh
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

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

* [ndctl PATCH 1/6] ndctl, daxctl: propagate loglevel to internal libdaxctl instance
  2017-07-19 18:32 [ndctl PATCH 0/6] multi-device-dax support and other fixes Dan Williams
@ 2017-07-19 18:33 ` Dan Williams
  2017-07-19 18:33 ` [ndctl PATCH 2/6] daxctl: stop carrying 'dax_region' in the daxctl_region region_path Dan Williams
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Dan Williams @ 2017-07-19 18:33 UTC (permalink / raw)
  To: linux-nvdimm

If someone turns on libndctl debug they automatically get libdaxctl
debug output from the internal library instance.

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

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 6607b68d4dd2..68d806444589 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -704,6 +704,8 @@ NDCTL_EXPORT int ndctl_get_log_priority(struct ndctl_ctx *ctx)
 NDCTL_EXPORT void ndctl_set_log_priority(struct ndctl_ctx *ctx, int priority)
 {
 	ctx->ctx.log_priority = priority;
+	/* forward the debug level to our internal libdaxctl instance */
+	daxctl_set_log_priority(ctx->daxctl_ctx, priority);
 }
 
 static char *__dev_path(char *type, int major, int minor, int parent)

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

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

* [ndctl PATCH 2/6] daxctl: stop carrying 'dax_region' in the daxctl_region region_path
  2017-07-19 18:32 [ndctl PATCH 0/6] multi-device-dax support and other fixes Dan Williams
  2017-07-19 18:33 ` [ndctl PATCH 1/6] ndctl, daxctl: propagate loglevel to internal libdaxctl instance Dan Williams
@ 2017-07-19 18:33 ` Dan Williams
  2017-07-19 18:33 ` [ndctl PATCH 3/6] daxctl: fix support for multiple instances per-region id Dan Williams
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Dan Williams @ 2017-07-19 18:33 UTC (permalink / raw)
  To: linux-nvdimm

Clean up region_path to carry the region device path directly. This
aligns libdaxctl with libndctl internal path names, and is a preparation
for carrying absolute path names that are needed for multi-device-dax
per region support.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 daxctl/lib/libdaxctl.c |   21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index 019f31b5067c..41af6ee92300 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -27,6 +27,8 @@
 #include <daxctl/libdaxctl.h>
 #include "libdaxctl-private.h"
 
+static const char *attrs = "dax_region";
+
 /**
  * struct daxctl_ctx - library user context to find "nd" instances
  *
@@ -219,14 +221,16 @@ DAXCTL_EXPORT void daxctl_region_ref(struct daxctl_region *region)
 		region->refcount++;
 }
 
-static void *add_dax_region(void *parent, int id, const char *base)
+static struct daxctl_region *add_dax_region(void *parent, int id,
+		const char *base)
 {
 	struct daxctl_region *region, *region_dup;
-	const char *attrs = "dax_region";
 	struct daxctl_ctx *ctx = parent;
 	char buf[SYSFS_ATTR_SIZE];
 	char *path;
 
+	dbg(ctx, "%s: \'%s\'\n", __func__, base);
+
 	daxctl_region_foreach(ctx, region_dup)
 		if (region_dup->id == id)
 			return region_dup;
@@ -255,12 +259,12 @@ static void *add_dax_region(void *parent, int id, const char *base)
 	if (sysfs_read_attr(ctx, path, buf) == 0)
 		region->align = strtoul(buf, NULL, 0);
 
-	sprintf(path, "%s/%s", base, attrs);
-	region->region_path = strdup(path);
+	region->region_path = strdup(base);
 	if (!region->region_path)
 		goto err_read;
 
-	region->region_buf = calloc(1, strlen(path) + REGION_BUF_SIZE);
+	region->region_buf = calloc(1, strlen(path) + strlen(attrs)
+			+ REGION_BUF_SIZE);
 	if (!region->region_buf)
 		goto err_read;
 	region->buf_len = strlen(path) + REGION_BUF_SIZE;
@@ -306,6 +310,7 @@ static void *add_dax_dev(void *parent, int id, const char *daxdev_base)
 
 	if (!path)
 		return NULL;
+	dbg(ctx, "%s: base: \'%s\'\n", __func__, daxdev_base);
 
 	dev = calloc(1, sizeof(*dev));
 	if (!dev)
@@ -382,8 +387,8 @@ DAXCTL_EXPORT unsigned long long daxctl_region_get_available_size(
 	int len = region->buf_len;
 	unsigned long long avail;
 
-	if (snprintf(path, len, "%s/available_size",
-				region->region_path) >= len) {
+	if (snprintf(path, len, "%s/%s/available_size",
+				region->region_path, attrs) >= len) {
 		err(ctx, "%s: buffer too small!\n",
 				daxctl_region_get_devname(region));
 		return 0;
@@ -407,7 +412,7 @@ DAXCTL_EXPORT struct daxctl_dev *daxctl_region_get_dev_seed(
 	char buf[SYSFS_ATTR_SIZE];
 	struct daxctl_dev *dev;
 
-	if (snprintf(path, len, "%s/seed", region->region_path) >= len) {
+	if (snprintf(path, len, "%s/%s/seed", region->region_path, attrs) >= len) {
 		err(ctx, "%s: buffer too small!\n",
 				daxctl_region_get_devname(region));
 		return NULL;

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

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

* [ndctl PATCH 3/6] daxctl: fix support for multiple instances per-region id
  2017-07-19 18:32 [ndctl PATCH 0/6] multi-device-dax support and other fixes Dan Williams
  2017-07-19 18:33 ` [ndctl PATCH 1/6] ndctl, daxctl: propagate loglevel to internal libdaxctl instance Dan Williams
  2017-07-19 18:33 ` [ndctl PATCH 2/6] daxctl: stop carrying 'dax_region' in the daxctl_region region_path Dan Williams
@ 2017-07-19 18:33 ` Dan Williams
  2017-07-19 18:33 ` [ndctl PATCH 4/6] ndctl, list: emit device-dax 'chardev' by default Dan Williams
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Dan Williams @ 2017-07-19 18:33 UTC (permalink / raw)
  To: linux-nvdimm

If libnvdimm registers namespace0.0 and namespace0.1 as
device-dax-regions there will be 2 entries in /sys/class/dax, dax0.0 and
dax0.1. However, libdaxctl does not account for the fact that these two
devices are hosted by 2 separate parent devices. Fix this assumption and
create separate regions for each distinct parent that can be enumerated
via /sys/class/dax.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 daxctl/lib/libdaxctl.c |   52 +++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 40 insertions(+), 12 deletions(-)

diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index 41af6ee92300..0919ea47d817 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -232,7 +232,7 @@ static struct daxctl_region *add_dax_region(void *parent, int id,
 	dbg(ctx, "%s: \'%s\'\n", __func__, base);
 
 	daxctl_region_foreach(ctx, region_dup)
-		if (region_dup->id == id)
+		if (strcmp(region_dup->region_path, base) == 0)
 			return region_dup;
 
 	path = calloc(1, strlen(base) + 100);
@@ -438,20 +438,48 @@ static void dax_devices_init(struct daxctl_region *region)
 
 	region->devices_init = 1;
 	sprintf(daxdev_fmt, "dax%d.", region->id);
-	region_path = strdup(region->region_path);
-	if (region_path) {
-		char *c = strrchr(region_path, '_');
-
-		/* convert <devpath>/dax_region to <devpath>/dax */
-		*c = '\0';
-		sysfs_device_parse(ctx, region_path, daxdev_fmt, region,
-				add_dax_dev);
+	if (asprintf(&region_path, "%s/dax", region->region_path) < 0) {
+		dbg(ctx, "region path alloc fail\n");
+		return;
 	}
+	sysfs_device_parse(ctx, region_path, daxdev_fmt, region, add_dax_dev);
 	free(region_path);
 }
 
+static char *dax_region_path(const char *base, const char *device)
+{
+	char *path, *region_path, *c;
+
+	if (asprintf(&path, "%s/%s", base, device) < 0)
+		return NULL;
+
+	/* dax_region must be the instance's direct parent */
+	region_path = canonicalize_file_name(path);
+	free(path);
+	if (!region_path)
+		return NULL;
+
+	/* 'region_path' is now regionX/dax/daxX.Y', trim back to regionX */
+	c = strrchr(region_path, '/');
+	if (!c) {
+		free(region_path);
+		return NULL;
+	}
+	*c = '\0';
+
+	c = strrchr(region_path, '/');
+	if (!c) {
+		free(region_path);
+		return NULL;
+	}
+	*c = '\0';
+
+	return region_path;
+}
+
 static void dax_regions_init(struct daxctl_ctx *ctx)
 {
+	const char *base = "/sys/class/dax";
 	struct dirent *de;
 	DIR *dir;
 
@@ -460,7 +488,7 @@ static void dax_regions_init(struct daxctl_ctx *ctx)
 
 	ctx->regions_init = 1;
 
-	dir = opendir("/sys/class/dax");
+	dir = opendir(base);
 	if (!dir) {
 		dbg(ctx, "no dax regions found\n");
 		return;
@@ -475,11 +503,11 @@ static void dax_regions_init(struct daxctl_ctx *ctx)
 			continue;
 		if (sscanf(de->d_name, "dax%d.%d", &region_id, &id) != 2)
 			continue;
-		if (asprintf(&dev_path, "/sys/class/dax/%s/device", de->d_name) < 0) {
+		dev_path = dax_region_path(base, de->d_name);
+		if (!dev_path) {
 			err(ctx, "dax region path allocation failure\n");
 			continue;
 		}
-
 		region = add_dax_region(ctx, region_id, dev_path);
 		free(dev_path);
 		if (!region)

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

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

* [ndctl PATCH 4/6] ndctl, list: emit device-dax 'chardev' by default
  2017-07-19 18:32 [ndctl PATCH 0/6] multi-device-dax support and other fixes Dan Williams
                   ` (2 preceding siblings ...)
  2017-07-19 18:33 ` [ndctl PATCH 3/6] daxctl: fix support for multiple instances per-region id Dan Williams
@ 2017-07-19 18:33 ` Dan Williams
  2017-07-19 20:13   ` Linda Knippers
  2017-07-19 18:33 ` [ndctl PATCH 5/6] daxctl, list: clarify output when multiple regions share an id Dan Williams
  2017-07-19 18:33 ` [ndctl PATCH 6/6] test: add multi-dax test Dan Williams
  5 siblings, 1 reply; 8+ messages in thread
From: Dan Williams @ 2017-07-19 18:33 UTC (permalink / raw)
  To: linux-nvdimm

Commit 10663a60d723 "ndctl, list: add '--device-dax' option" tried to
cleanup the default namespace output by putting the device-dax details
behind an extra option. This was done in anticipation of device-dax
sub-division support, but the kernel has since added support for
multiple-pmem namespaces per region and limiting device-dax instances to
one per parent namespace. With the limitation in place we can directly
associate a device-dax instance with a namespace and omit the dax-region
details in ndctl.

Reported-by: Linda Knippers <linda.knippers@hpe.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 util/json.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/util/json.c b/util/json.c
index 80512bdabeae..25188a61064f 100644
--- a/util/json.c
+++ b/util/json.c
@@ -622,18 +622,28 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
 	} else if (dax) {
 		struct daxctl_region *dax_region;
 
+		dax_region = ndctl_dax_get_daxctl_region(dax);
 		ndctl_dax_get_uuid(dax, uuid);
 		uuid_unparse(uuid, buf);
 		jobj = json_object_new_string(buf);
 		if (!jobj)
 			goto err;
 		json_object_object_add(jndns, "uuid", jobj);
-		if (flags & UTIL_JSON_DAX) {
-			dax_region = ndctl_dax_get_daxctl_region(dax);
+		if ((flags & UTIL_JSON_DAX) && dax_region) {
 			jobj = util_daxctl_region_to_json(dax_region, NULL,
 					flags);
 			if (jobj)
 				json_object_object_add(jndns, "daxregion", jobj);
+		} else if (dax_region) {
+			struct daxctl_dev *dev;
+			const char *name;
+
+			dev = daxctl_dev_get_first(dax_region);
+			name = daxctl_dev_get_devname(dev);
+			jobj = json_object_new_string(name);
+			if (!jobj)
+				goto err;
+			json_object_object_add(jndns, "chardev", jobj);
 		}
 	} else if (ndctl_namespace_get_type(ndns) != ND_DEVICE_NAMESPACE_IO) {
 		const char *name;

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

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

* [ndctl PATCH 5/6] daxctl, list: clarify output when multiple regions share an id
  2017-07-19 18:32 [ndctl PATCH 0/6] multi-device-dax support and other fixes Dan Williams
                   ` (3 preceding siblings ...)
  2017-07-19 18:33 ` [ndctl PATCH 4/6] ndctl, list: emit device-dax 'chardev' by default Dan Williams
@ 2017-07-19 18:33 ` Dan Williams
  2017-07-19 18:33 ` [ndctl PATCH 6/6] test: add multi-dax test Dan Williams
  5 siblings, 0 replies; 8+ messages in thread
From: Dan Williams @ 2017-07-19 18:33 UTC (permalink / raw)
  To: linux-nvdimm

The region id is meant to uniquely identify a host memory range, but in
the case of the libnvdimm namespace the host memory range may be
sub-divided into multiple namespaces leading to ambiguous output like
the following

    # daxctl list -R
    [
      {
        "id":1,
        "size":1054867456,
        "align":2097152
      },
      {
        "id":1,
        "size":1054867456,
        "align":2097152
      },
      {
        "id":1,
        "size":1054867456,
        "align":2097152
      },
      {
        "id":1,
        "size":1054867456,
        "align":2097152
      }
    ]

Teach util_dax_region_to_json() to emit the host device path, but be
careful to only do this when it is not being called through ndctl. In
the 'ndctl list -X' case including the host path information is
redundant. Note, we use the path rather than the device-name since the
name is not descriptive enough to disambiguate dax-regions.

    # daxctl list -R
    [
      {
        "path":"\/LNXSYSTM:00\/LNXSYBUS:00\/ACPI0012:00\/ndbus1\/region1\/dax1.3",
        "id":1,
        "size":1054867456,
        "align":2097152
      },
      {
        "path":"\/LNXSYSTM:00\/LNXSYBUS:00\/ACPI0012:00\/ndbus1\/region1\/dax1.1",
        "id":1,
        "size":1054867456,
        "align":2097152
      },
      {
        "path":"\/LNXSYSTM:00\/LNXSYBUS:00\/ACPI0012:00\/ndbus1\/region1\/dax1.2",
        "id":1,
        "size":1054867456,
        "align":2097152
      },
      {
        "path":"\/LNXSYSTM:00\/LNXSYBUS:00\/ACPI0012:00\/ndbus1\/region1\/dax1.4",
        "id":1,
        "size":1054867456,
        "align":2097152
      }
    ]

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 daxctl/lib/libdaxctl.c   |    5 +++++
 daxctl/lib/libdaxctl.sym |    5 +++++
 daxctl/libdaxctl.h       |    2 ++
 daxctl/list.c            |    2 +-
 ndctl/list.c             |    2 +-
 ndctl/namespace.c        |    2 +-
 util/json.c              |   20 +++++++++++++++++++-
 util/json.h              |    3 ++-
 8 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index 0919ea47d817..89f8cc8e69ff 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -378,6 +378,11 @@ DAXCTL_EXPORT const char *daxctl_region_get_devname(struct daxctl_region *region
 	return region->devname;
 }
 
+DAXCTL_EXPORT const char *daxctl_region_get_path(struct daxctl_region *region)
+{
+	return region->region_path;
+}
+
 DAXCTL_EXPORT unsigned long long daxctl_region_get_available_size(
 		struct daxctl_region *region)
 {
diff --git a/daxctl/lib/libdaxctl.sym b/daxctl/lib/libdaxctl.sym
index 1b1104dbe74c..84d3a6909165 100644
--- a/daxctl/lib/libdaxctl.sym
+++ b/daxctl/lib/libdaxctl.sym
@@ -45,3 +45,8 @@ global:
 	daxctl_region_get_first;
 	daxctl_region_get_next;
 } LIBDAXCTL_3;
+
+LIBDAXCTL_5 {
+global:
+	daxctl_region_get_path;
+} LIBDAXCTL_4;
diff --git a/daxctl/libdaxctl.h b/daxctl/libdaxctl.h
index b65dc3083048..77f6a25d2e30 100644
--- a/daxctl/libdaxctl.h
+++ b/daxctl/libdaxctl.h
@@ -49,6 +49,8 @@ unsigned long long daxctl_region_get_available_size(
 unsigned long long daxctl_region_get_size(struct daxctl_region *region);
 unsigned long daxctl_region_get_align(struct daxctl_region *region);
 const char *daxctl_region_get_devname(struct daxctl_region *region);
+const char *daxctl_region_get_path(struct daxctl_region *region);
+
 struct daxctl_dev *daxctl_region_get_dev_seed(struct daxctl_region *region);
 
 struct daxctl_dev;
diff --git a/daxctl/list.c b/daxctl/list.c
index 678ef6ce4c13..254f0ac9be79 100644
--- a/daxctl/list.c
+++ b/daxctl/list.c
@@ -34,7 +34,7 @@ static unsigned long listopts_to_flags(void)
 	unsigned long flags = 0;
 
 	if (list.devs)
-		flags |= UTIL_JSON_DAX;
+		flags |= UTIL_JSON_DAX_DEVS;
 	if (list.idle)
 		flags |= UTIL_JSON_IDLE;
 	if (list.human)
diff --git a/ndctl/list.c b/ndctl/list.c
index 7f8db6630b51..c910c776c61d 100644
--- a/ndctl/list.c
+++ b/ndctl/list.c
@@ -49,7 +49,7 @@ static unsigned long listopts_to_flags(void)
 	if (list.media_errors)
 		flags |= UTIL_JSON_MEDIA_ERRORS;
 	if (list.dax)
-		flags |= UTIL_JSON_DAX;
+		flags |= UTIL_JSON_DAX | UTIL_JSON_DAX_DEVS;
 	if (list.human)
 		flags |= UTIL_JSON_HUMAN;
 	return flags;
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index a9576cefa2ce..4734ebdb22b0 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -401,7 +401,7 @@ static int setup_namespace(struct ndctl_region *region,
 		error("%s: failed to enable\n",
 				ndctl_namespace_get_devname(ndns));
 	} else {
-		unsigned long flags = UTIL_JSON_DAX;
+		unsigned long flags = UTIL_JSON_DAX | UTIL_JSON_DAX_DEVS;
 		struct json_object *jndns;
 
 		if (isatty(1))
diff --git a/util/json.c b/util/json.c
index 25188a61064f..559a022ae405 100644
--- a/util/json.c
+++ b/util/json.c
@@ -306,6 +306,24 @@ struct json_object *util_daxctl_region_to_json(struct daxctl_region *region,
 	if (!jregion)
 		return NULL;
 
+	/*
+	 * The flag indicates when we are being called by an agent that
+	 * already knows about the parent device information.
+	 */
+	if (!(flags & UTIL_JSON_DAX)) {
+		/* trim off the redundant /sys/devices prefix */
+		const char *path = daxctl_region_get_path(region);
+		int len = strlen("/sys/devices");
+		const char *trim = &path[len];
+
+		if (strncmp(path, "/sys/devices", len) != 0)
+			goto err;
+		jobj = json_object_new_string(trim);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jregion, "path", jobj);
+	}
+
 	jobj = json_object_new_int(daxctl_region_get_id(region));
 	if (!jobj)
 		goto err;
@@ -335,7 +353,7 @@ struct json_object *util_daxctl_region_to_json(struct daxctl_region *region,
 		json_object_object_add(jregion, "align", jobj);
 	}
 
-	if (!(flags & UTIL_JSON_DAX))
+	if (!(flags & UTIL_JSON_DAX_DEVS))
 		return jregion;
 
 	jobj = util_daxctl_devs_to_list(region, NULL, ident, flags);
diff --git a/util/json.h b/util/json.h
index d885ead2b916..d934b2e660d4 100644
--- a/util/json.h
+++ b/util/json.h
@@ -20,7 +20,8 @@ enum util_json_flags {
 	UTIL_JSON_IDLE = (1 << 0),
 	UTIL_JSON_MEDIA_ERRORS = (1 << 1),
 	UTIL_JSON_DAX = (1 << 2),
-	UTIL_JSON_HUMAN = (1 << 3),
+	UTIL_JSON_DAX_DEVS = (1 << 3),
+	UTIL_JSON_HUMAN = (1 << 4),
 };
 
 struct json_object;

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

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

* [ndctl PATCH 6/6] test: add multi-dax test
  2017-07-19 18:32 [ndctl PATCH 0/6] multi-device-dax support and other fixes Dan Williams
                   ` (4 preceding siblings ...)
  2017-07-19 18:33 ` [ndctl PATCH 5/6] daxctl, list: clarify output when multiple regions share an id Dan Williams
@ 2017-07-19 18:33 ` Dan Williams
  5 siblings, 0 replies; 8+ messages in thread
From: Dan Williams @ 2017-07-19 18:33 UTC (permalink / raw)
  To: linux-nvdimm

Add a simple sanity check for multiple dax instances per
libnvdimm-region support. This is known to fail with a sysfs duplicate
filename warning on kernels prior to 4.13-final.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/Makefile.am  |    1 +
 test/multi-dax.sh |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)
 create mode 100755 test/multi-dax.sh

diff --git a/test/Makefile.am b/test/Makefile.am
index 9353a34326c1..ac3547e22ccb 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -10,6 +10,7 @@ TESTS =\
 	clear.sh \
 	dax-errors.sh \
 	daxdev-errors.sh \
+	multi-dax.sh \
 	btt-check.sh \
 	label-compat.sh \
 	blk-exhaust.sh
diff --git a/test/multi-dax.sh b/test/multi-dax.sh
new file mode 100755
index 000000000000..751f16f5b07b
--- /dev/null
+++ b/test/multi-dax.sh
@@ -0,0 +1,61 @@
+#!/bin/bash -x
+
+# Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+
+DEV=""
+NDCTL="../ndctl/ndctl"
+DAXCTL="../daxctl/daxctl"
+BUS="-b nfit_test.0"
+BUS1="-b nfit_test.1"
+json2var="s/[{}\",]//g; s/:/=/g"
+rc=77
+
+err() {
+	rc=1
+	echo "test/multi-dax: 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.13" || { echo "kernel $KVER may lack multi-dax support"; 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
+$NDCTL enable-region $BUS all
+
+query=". | sort_by(.available_size) | reverse | .[0].dev"
+region=$($NDCTL list $BUS -t pmem -Ri | jq -r "$query")
+
+json=$($NDCTL create-namespace $BUS -r $region -t pmem -m dax -a 4096 -s 16M)
+chardev1=$(echo $json | jq ". | select(.mode == \"dax\") | .daxregion.devices[0].chardev")
+json=$($NDCTL create-namespace $BUS -r $region -t pmem -m dax -a 4096 -s 16M)
+chardev2=$(echo $json | jq ". | select(.mode == \"dax\") | .daxregion.devices[0].chardev")
+
+# cleanup
+$NDCTL disable-region $BUS all
+$NDCTL disable-region $BUS1 all
+modprobe -r nfit_test
+
+exit 0

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

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

* Re: [ndctl PATCH 4/6] ndctl, list: emit device-dax 'chardev' by default
  2017-07-19 18:33 ` [ndctl PATCH 4/6] ndctl, list: emit device-dax 'chardev' by default Dan Williams
@ 2017-07-19 20:13   ` Linda Knippers
  0 siblings, 0 replies; 8+ messages in thread
From: Linda Knippers @ 2017-07-19 20:13 UTC (permalink / raw)
  To: Dan Williams, linux-nvdimm

On 07/19/2017 02:33 PM, Dan Williams wrote:
> Commit 10663a60d723 "ndctl, list: add '--device-dax' option" tried to
> cleanup the default namespace output by putting the device-dax details
> behind an extra option. This was done in anticipation of device-dax
> sub-division support, but the kernel has since added support for
> multiple-pmem namespaces per region and limiting device-dax instances to
> one per parent namespace. With the limitation in place we can directly
> associate a device-dax instance with a namespace and omit the dax-region
> details in ndctl.

$ ndctl list
...
  {
    "dev":"namespace7.0",
    "mode":"dax",
    "size":8453619712,
    "uuid":"c57b18aa-0c6a-4775-aa3e-e25f2a7c0c2f",
    "chardev":"dax7.0",
    "numa_node":1
  },
...


Thanks!

-- ljk
> 
> Reported-by: Linda Knippers <linda.knippers@hpe.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  util/json.c |   14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/util/json.c b/util/json.c
> index 80512bdabeae..25188a61064f 100644
> --- a/util/json.c
> +++ b/util/json.c
> @@ -622,18 +622,28 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
>  	} else if (dax) {
>  		struct daxctl_region *dax_region;
>  
> +		dax_region = ndctl_dax_get_daxctl_region(dax);
>  		ndctl_dax_get_uuid(dax, uuid);
>  		uuid_unparse(uuid, buf);
>  		jobj = json_object_new_string(buf);
>  		if (!jobj)
>  			goto err;
>  		json_object_object_add(jndns, "uuid", jobj);
> -		if (flags & UTIL_JSON_DAX) {
> -			dax_region = ndctl_dax_get_daxctl_region(dax);
> +		if ((flags & UTIL_JSON_DAX) && dax_region) {
>  			jobj = util_daxctl_region_to_json(dax_region, NULL,
>  					flags);
>  			if (jobj)
>  				json_object_object_add(jndns, "daxregion", jobj);
> +		} else if (dax_region) {
> +			struct daxctl_dev *dev;
> +			const char *name;
> +
> +			dev = daxctl_dev_get_first(dax_region);
> +			name = daxctl_dev_get_devname(dev);
> +			jobj = json_object_new_string(name);
> +			if (!jobj)
> +				goto err;
> +			json_object_object_add(jndns, "chardev", jobj);
>  		}
>  	} else if (ndctl_namespace_get_type(ndns) != ND_DEVICE_NAMESPACE_IO) {
>  		const char *name;
> 

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

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

end of thread, other threads:[~2017-07-19 20:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-19 18:32 [ndctl PATCH 0/6] multi-device-dax support and other fixes Dan Williams
2017-07-19 18:33 ` [ndctl PATCH 1/6] ndctl, daxctl: propagate loglevel to internal libdaxctl instance Dan Williams
2017-07-19 18:33 ` [ndctl PATCH 2/6] daxctl: stop carrying 'dax_region' in the daxctl_region region_path Dan Williams
2017-07-19 18:33 ` [ndctl PATCH 3/6] daxctl: fix support for multiple instances per-region id Dan Williams
2017-07-19 18:33 ` [ndctl PATCH 4/6] ndctl, list: emit device-dax 'chardev' by default Dan Williams
2017-07-19 20:13   ` Linda Knippers
2017-07-19 18:33 ` [ndctl PATCH 5/6] daxctl, list: clarify output when multiple regions share an id Dan Williams
2017-07-19 18:33 ` [ndctl PATCH 6/6] test: add multi-dax test Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox