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 3/9] ndctl, list: list device-dax instances beneath a namespace
Date: Sun, 26 Jun 2016 16:24:44 -0700	[thread overview]
Message-ID: <146698348413.40541.8831911859137598217.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <146698346627.40541.14661847967712551305.stgit@dwillia2-desk3.amr.corp.intel.com>

For example:

    {
      "dev":"namespace0.0",
      "mode":"dax",
      "size":8453619712,
      "uuid":"277919a1-ba36-4f41-89b5-c9eebb9b7e33",
      "daxdevs":[
        {
          "chardev":"dax0.0",
          "size":8589934592
        }
      ]
    }

Note that "daxdevs" is an array because there may be more than one
per-namespace in the future.

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

diff --git a/ndctl/util/json.c b/ndctl/util/json.c
index d144039bb559..dedfb45ed100 100644
--- a/ndctl/util/json.c
+++ b/ndctl/util/json.c
@@ -3,6 +3,7 @@
 #include <uuid/uuid.h>
 #include <json-c/json.h>
 #include <ndctl/libndctl.h>
+#include <daxctl/libdaxctl.h>
 #include <ccan/array_size/array_size.h>
 
 #ifdef HAVE_NDCTL_H
@@ -99,6 +100,39 @@ bool util_namespace_active(struct ndctl_namespace *ndns)
 	return false;
 }
 
+static json_object *util_daxctl_region_to_json(struct daxctl_region *region)
+{
+	struct json_object *jdaxdevs = json_object_new_array();
+	struct json_object *jobj;
+	struct daxctl_dev *dev;
+
+	if (!jdaxdevs)
+		return NULL;
+
+	daxctl_dev_foreach(region, dev) {
+		const char *devname = daxctl_dev_get_devname(dev);
+		struct json_object *jdev = json_object_new_object();
+
+		if (!devname || !jdev)
+			continue;
+		jobj = json_object_new_string(devname);
+		if (jobj)
+			json_object_object_add(jdev, "chardev", jobj);
+
+		jobj = json_object_new_int64(daxctl_dev_get_size(dev));
+		if (jobj)
+			json_object_object_add(jdev, "size", jobj);
+
+		json_object_array_add(jdaxdevs, jdev);
+	}
+
+	if (json_object_array_length(jdaxdevs) < 1) {
+		json_object_put(jdaxdevs);
+		return NULL;
+	}
+	return jdaxdevs;
+}
+
 struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns)
 {
 	struct json_object *jndns = json_object_new_object();
@@ -178,12 +212,18 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns)
 		json_object_object_add(jndns, "uuid", jobj);
 		bdev = ndctl_pfn_get_block_device(pfn);
 	} else if (dax) {
+		struct daxctl_region *dax_region;
+
 		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);
+		dax_region = ndctl_dax_get_daxctl_region(dax);
+		jobj = util_daxctl_region_to_json(dax_region);
+		if (jobj)
+			json_object_object_add(jndns, "daxdevs", 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

  parent reply	other threads:[~2016-06-26 23:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-26 23:24 [ndctl PATCH 0/9] updates for vmalloc-based nfit_test and device-dax Dan Williams
2016-06-26 23:24 ` [ndctl PATCH 1/9] ndctl: deprecate pcommit Dan Williams
2016-06-26 23:24 ` [ndctl PATCH 2/9] test, libndctl: invalidate dax info blocks before reuse Dan Williams
2016-06-26 23:24 ` Dan Williams [this message]
2016-06-26 23:24 ` [ndctl PATCH 4/9] ndctl, list: allow limiting namespace listing Dan Williams
2016-06-27 19:28   ` Vishal Verma
2016-06-27 19:38     ` Dan Williams
2016-06-26 23:24 ` [ndctl PATCH 5/9] ndctl: add libs dependency to spec file Dan Williams
2016-06-26 23:24 ` [ndctl PATCH 6/9] ndctl, create-namespace: fix blk-namepsaces vs device-dax Dan Williams
2016-06-26 23:25 ` [ndctl PATCH 7/9] ndctl, create-namespace: fix device-dax vs --map= Dan Williams
2016-06-26 23:25 ` [ndctl PATCH 8/9] test, libndctl: move pfn + dax configurations to a destructive test Dan Williams
2016-06-26 23:25 ` [ndctl PATCH 9/9] test, libndctl: kill some dead code Dan Williams
2016-06-27 11:37 ` [ndctl PATCH 0/9] updates for vmalloc-based nfit_test and device-dax Yigal Korman
2016-06-27 23:04 ` Vishal Verma

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=146698348413.40541.8831911859137598217.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.