From patchwork Fri Sep 1 13:22:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?R290b3UsIFlhc3Vub3JpL+S6lOWztiDlurfmloc=?= X-Patchwork-Id: 9934157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0D9686016C for ; Fri, 1 Sep 2017 13:22:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F05A72852B for ; Fri, 1 Sep 2017 13:22:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3DFE28644; Fri, 1 Sep 2017 13:22:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 52CC72852B for ; Fri, 1 Sep 2017 13:22:20 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 71A1C21EB88FF; Fri, 1 Sep 2017 06:19:35 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mgwkm01.jp.fujitsu.com (mgwkm01.jp.fujitsu.com [202.219.69.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4BE8321EB88F5 for ; Fri, 1 Sep 2017 06:19:33 -0700 (PDT) Received: from kw-mxoi2.gw.nic.fujitsu.com (unknown [192.168.231.133]) by mgwkm01.jp.fujitsu.com with smtp id 3909_99cb_11dec278_c10f_41ff_8b59_5faa769d5eeb; Fri, 01 Sep 2017 22:22:14 +0900 Received: from m3050.s.css.fujitsu.com (msm.b.css.fujitsu.com [10.134.21.208]) by kw-mxoi2.gw.nic.fujitsu.com (Postfix) with ESMTP id 2C3F7AC0187 for ; Fri, 1 Sep 2017 22:22:14 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.5.2 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20170217-enc X-SHieldMailCheckerMailID: ffe7cf96cd7340c7bb08b1d6a21f2a87 Date: Fri, 01 Sep 2017 22:22:03 +0900 From: Yasunori Goto To: NVDIMM-ML Subject: [ndctl PATCH 5/5] ndctl: show bad dimm's name by ndctl list command. In-Reply-To: <20170901221335.C27F.E1E9C6FF@jp.fujitsu.com> References: <20170901221335.C27F.E1E9C6FF@jp.fujitsu.com> Message-Id: <20170901222200.C28E.E1E9C6FF@jp.fujitsu.com> MIME-Version: 1.0 X-Mailer: Becky! ver. 2.73 [ja] X-TM-AS-MML: disable X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Show dimm's name which has badblock by ndctl list command. This patch uses translate SPA interface to get bad dimm info. Signed-off-by: Yasunori Goto --- util/json.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/util/json.c b/util/json.c index 98165b7..a9b6259 100644 --- a/util/json.c +++ b/util/json.c @@ -366,6 +366,15 @@ struct json_object *util_daxctl_region_to_json(struct daxctl_region *region, return NULL; } +static struct ndctl_dimm *badblock_to_dimm(struct ndctl_region *region, + unsigned long long spa) +{ + struct ndctl_bus *bus; + + bus = ndctl_region_get_bus(region); + return ndctl_dimm_get_by_physical_address(bus, spa); +} + struct json_object *util_region_badblocks_to_json(struct ndctl_region *region, unsigned int *bb_count, unsigned long flags) { @@ -381,6 +390,18 @@ 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_dimm *dimm = NULL; + unsigned long long spa; + + /* get start address of region */ + spa = ndctl_region_get_resource(region); + if (spa == ULONG_MAX) + goto err_array; + + /* get address of bad block */ + spa += bb->offset << 9; + dimm = badblock_to_dimm(region, spa); + jbb = json_object_new_object(); if (!jbb) goto err_array; @@ -395,6 +416,12 @@ struct json_object *util_region_badblocks_to_json(struct ndctl_region *region, goto err; json_object_object_add(jbb, "length", jobj); + if (dimm) { + jobj = json_object_new_string(ndctl_dimm_get_devname(dimm)); + if (!jobj) + goto err; + json_object_object_add(jbb, "dimm", jobj); + } json_object_array_add(jbbs, jbb); } @@ -436,6 +463,7 @@ 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_dimm *dimm = NULL; bb_begin = region_begin + (bb->offset << 9); bb_end = bb_begin + (bb->len << 9) - 1; @@ -456,6 +484,8 @@ static struct json_object *dev_badblocks_to_json(struct ndctl_region *region, offset = (begin - dev_begin) >> 9; len = (end - begin + 1) >> 9; + dimm = badblock_to_dimm(region, begin); + if (flags & UTIL_JSON_MEDIA_ERRORS) { /* add to json */ jbb = json_object_new_object(); @@ -472,6 +502,13 @@ static struct json_object *dev_badblocks_to_json(struct ndctl_region *region, goto err; json_object_object_add(jbb, "length", jobj); + if (dimm) { + jobj = json_object_new_string(ndctl_dimm_get_devname(dimm)); + if (!jobj) + goto err; + json_object_object_add(jbb, "dimm", jobj); + } + json_object_array_add(jbbs, jbb); } bbs += len;