All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yasunori Goto <y-goto@jp.fujitsu.com>
To: NVDIMM-ML <linux-nvdimm@lists.01.org>
Subject: [RFC/Patch 5/5] ndctl: show dimm's name which has badblock by ndctl list command.
Date: Fri, 04 Aug 2017 18:13:54 +0900	[thread overview]
Message-ID: <20170804181353.27CF.E1E9C6FF@jp.fujitsu.com> (raw)
In-Reply-To: <20170804180231.27BC.E1E9C6FF@jp.fujitsu.com>

ndctl: show dimm's name which has badblock by ndctl list command.

This patch uses translate SPA interface to get bad dimm info.

Since this patch is likely Proof of Concept,
because libnvdimm functions of this feature will change yet.
So, I don't think this patch can be merged.

However, I hope this patch is good start for discussion....



Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
---
 util/json.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/util/json.c b/util/json.c
index 2b2b5af..b791054 100644
--- a/util/json.c
+++ b/util/json.c
@@ -381,6 +381,22 @@ struct json_object *util_region_badblocks_to_json(struct ndctl_region *region,
 
 	ndctl_region_badblock_foreach(region, bb) {
 		if (flags & UTIL_JSON_MEDIA_ERRORS) {
+			struct ndctl_bus *bus;
+			struct ndctl_dimm *dimms[ND_MIRROR_MAX_WAY];
+			memset(dimms, 0, sizeof(dimms));
+			bus = ndctl_region_get_bus(region);
+			if (ndctl_bus_has_trans_spa(bus)) {
+				int rc;
+				unsigned long long spa;
+				spa = ndctl_region_get_resource(region);
+				if (spa == ULONG_MAX)
+					goto err_array;
+				spa += bb->offset << 9;
+				rc = ndctl_dimms_get_by_spa(bus, spa, dimms);
+				if (rc)
+					goto err_array;
+			}
+
 			jbb = json_object_new_object();
 			if (!jbb)
 				goto err_array;
@@ -395,6 +411,14 @@ struct json_object *util_region_badblocks_to_json(struct ndctl_region *region,
 				goto err;
 			json_object_object_add(jbb, "length", jobj);
 
+			for (int i = 0; i < ND_MIRROR_MAX_WAY; i++) {
+				if (dimms[i]) {
+					jobj = json_object_new_string(ndctl_dimm_get_devname(dimms[i]));
+					if (!jobj)
+						goto err;
+					json_object_object_add(jbb, "dimm", jobj);
+				}
+			}
 			json_object_array_add(jbbs, jbb);
 		}
 
@@ -436,6 +460,8 @@ static struct json_object *dev_badblocks_to_json(struct ndctl_region *region,
 
 	ndctl_region_badblock_foreach(region, bb) {
 		unsigned long long bb_begin, bb_end, begin, end;
+		struct ndctl_bus *bus;
+		struct ndctl_dimm *dimms[ND_MIRROR_MAX_WAY];
 
 		bb_begin = region_begin + (bb->offset << 9);
 		bb_end = bb_begin + (bb->len << 9) - 1;
@@ -453,6 +479,20 @@ static struct json_object *dev_badblocks_to_json(struct ndctl_region *region,
 		else
 			end = bb_end;
 
+		memset(dimms, 0, sizeof(dimms));
+		bus = ndctl_region_get_bus(region);
+		if (ndctl_bus_has_trans_spa(bus)) {
+			int rc;
+			unsigned long long spa;
+			spa = ndctl_region_get_resource(region);
+			if (spa == ULLONG_MAX)
+				goto err_array;
+			spa += bb->offset << 9;
+			rc = ndctl_dimms_get_by_spa(bus, spa, dimms);
+			if (rc)
+				goto err_array;
+		}
+
 		offset = (begin - dev_begin) >> 9;
 		len = (end - begin + 1) >> 9;
 
@@ -472,6 +512,15 @@ static struct json_object *dev_badblocks_to_json(struct ndctl_region *region,
 				goto err;
 			json_object_object_add(jbb, "length", jobj);
 
+			for (int i = 1; i < ND_MIRROR_MAX_WAY; i++) {
+				if (dimms[i]) {
+					jobj = json_object_new_string(ndctl_dimm_get_devname(dimms[i]));
+					if (!jobj)
+						goto err;
+					json_object_object_add(jbb, "dimm", jobj);
+				}
+			}
+
 			json_object_array_add(jbbs, jbb);
 		}
 		bbs += len;



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

      parent reply	other threads:[~2017-08-04  9:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-04  9:02 [RFC/Patch 0/5] ndctl list show broken nvdimm info Yasunori Goto
2017-08-04  9:06 ` [RFC/Patch 1/5] Remove old enum definition of "Translate Spa" Yasunori Goto
2017-08-04 23:09   ` Dan Williams
2017-08-07  0:03     ` Yasunori Goto
2017-08-04  9:08 ` [RFC/Patch 2/5] Support Translate SPA for NVDIMM Root Device Yasunori Goto
2017-08-04 23:30   ` Dan Williams
2017-08-04  9:10 ` [RFC/Patch 3/5] nfit_test supports Translate SPA Yasunori Goto
2017-08-04  9:12 ` [RFC/Patch 4/5] libndctl Make interfaces to use " Yasunori Goto
2017-08-05  0:03   ` Dan Williams
2017-08-07  0:08     ` Yasunori Goto
2017-08-04  9:13 ` Yasunori Goto [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=20170804181353.27CF.E1E9C6FF@jp.fujitsu.com \
    --to=y-goto@jp.fujitsu.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.