From patchwork Wed Jul 19 18:33:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9852985 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 2DEEF602C8 for ; Wed, 19 Jul 2017 18:39:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13E2F2863B for ; Wed, 19 Jul 2017 18:39:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08CD228672; Wed, 19 Jul 2017 18:39:45 +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 679402863B for ; Wed, 19 Jul 2017 18:39:44 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2236521D147A4; Wed, 19 Jul 2017 11:37:49 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 B8CFE21D147CD for ; Wed, 19 Jul 2017 11:37:47 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jul 2017 11:39:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.40,381,1496127600"; d="scan'208"; a="1153163808" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.125]) by orsmga001.jf.intel.com with ESMTP; 19 Jul 2017 11:39:42 -0700 Subject: [ndctl PATCH 4/6] ndctl, list: emit device-dax 'chardev' by default From: Dan Williams To: linux-nvdimm@lists.01.org Date: Wed, 19 Jul 2017 11:33:17 -0700 Message-ID: <150048919740.12895.4759356543014868451.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <150048917662.12895.15953645444185664230.stgit@dwillia2-desk3.amr.corp.intel.com> References: <150048917662.12895.15953645444185664230.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 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 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 Signed-off-by: Dan Williams --- 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;