From patchwork Tue May 29 23:15:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 10437391 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 AAB84601C7 for ; Tue, 29 May 2018 23:15:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EFD420499 for ; Tue, 29 May 2018 23:15:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91E64287B8; Tue, 29 May 2018 23:15:38 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 1297920499 for ; Tue, 29 May 2018 23:15:37 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 82F1F2063D760; Tue, 29 May 2018 16:15:37 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=vishal.l.verma@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 5EC0B2007E80E for ; Tue, 29 May 2018 16:15:35 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 May 2018 16:15:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,458,1520924400"; d="scan'208";a="51639403" Received: from vverma7-mobl4.lm.intel.com ([10.254.189.82]) by fmsmga002.fm.intel.com with ESMTP; 29 May 2018 16:15:34 -0700 From: Vishal Verma To: Subject: [ndctl PATCH v2] ndctl, list: display the 'map' location in listings Date: Tue, 29 May 2018 17:15:03 -0600 Message-Id: <20180529231503.31710-1-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.14.3 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yigal Korman MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP For 'fsdax' and 'devdax' namespaces, a 'map' location may be specified for page structures storage. This can be 'mem', for system RAM, or 'dev' for using pmem as the backing storage. Once set, there was no way of telling using ndctl, which of the two locations a namespace was configured for. Add this in util_namespace_to_json so that all namespace listings contain the map location. Reported-by: "Yigal Korman" Cc: Dan Williams Signed-off-by: Vishal Verma --- util/json.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) v2: Also account for memmap=ss!nn or legacy-e820 namespaces. (Dan) diff --git a/util/json.c b/util/json.c index c606e1c..b020300 100644 --- a/util/json.c +++ b/util/json.c @@ -667,11 +667,17 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns, { struct json_object *jndns = json_object_new_object(); struct json_object *jobj, *jbbs = NULL; + const char *locations[] = { + [NDCTL_PFN_LOC_NONE] = "none", + [NDCTL_PFN_LOC_RAM] = "mem", + [NDCTL_PFN_LOC_PMEM] = "dev", + }; unsigned long long size = ULLONG_MAX; unsigned int sector_size = UINT_MAX; enum ndctl_namespace_mode mode; const char *bdev = NULL, *name; unsigned int bb_count = 0; + enum ndctl_pfn_loc loc; struct ndctl_btt *btt; struct ndctl_pfn *pfn; struct ndctl_dax *dax; @@ -693,33 +699,49 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns, mode = ndctl_namespace_get_mode(ndns); switch (mode) { case NDCTL_NS_MODE_MEMORY: - if (pfn) /* dynamic memory mode */ + jobj = json_object_new_string("fsdax"); + if (jobj) + json_object_object_add(jndns, "mode", jobj); + loc = ndctl_pfn_get_location(pfn); + if (pfn) { /* dynamic memory mode */ size = ndctl_pfn_get_size(pfn); - else /* native/static memory mode */ + jobj = json_object_new_string(locations[loc]); + } else { /* native/static memory mode */ size = ndctl_namespace_get_size(ndns); - jobj = json_object_new_string("fsdax"); + jobj = json_object_new_string("mem"); + } + if (jobj) + json_object_object_add(jndns, "map", jobj); break; case NDCTL_NS_MODE_DAX: if (!dax) goto err; size = ndctl_dax_get_size(dax); jobj = json_object_new_string("devdax"); + if (jobj) + json_object_object_add(jndns, "mode", jobj); + loc = ndctl_dax_get_location(dax); + jobj = json_object_new_string(locations[loc]); + if (jobj) + json_object_object_add(jndns, "map", jobj); break; case NDCTL_NS_MODE_SAFE: if (!btt) goto err; jobj = json_object_new_string("sector"); + if (jobj) + json_object_object_add(jndns, "mode", jobj); size = ndctl_btt_get_size(btt); break; case NDCTL_NS_MODE_RAW: size = ndctl_namespace_get_size(ndns); jobj = json_object_new_string("raw"); + if (jobj) + json_object_object_add(jndns, "mode", jobj); break; default: jobj = NULL; } - if (jobj) - json_object_object_add(jndns, "mode", jobj); if (size < ULLONG_MAX) { jobj = util_json_object_size(size, flags);