From patchwork Tue Jun 27 08:13:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 9811037 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 EF04C60351 for ; Tue, 27 Jun 2017 08:13:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E498923794 for ; Tue, 27 Jun 2017 08:13:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D934B2851E; Tue, 27 Jun 2017 08:13:15 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no 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 9FBB623794 for ; Tue, 27 Jun 2017 08:13:15 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7F76621BBC430; Tue, 27 Jun 2017 01:11:44 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E7A9821BBC401 for ; Tue, 27 Jun 2017 01:11:43 -0700 (PDT) Received: by mail-pg0-x242.google.com with SMTP id f127so3398263pgc.2 for ; Tue, 27 Jun 2017 01:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Y9ohffHg6a/5an4woAaoObkTKChNi1KsetUKi59vSbU=; b=eMrt8meo7e8TopWgBWGhHVBv3qRK7MjZ42rM4ZhDAIwGZaqUaiKVeMmy85cyIpDwBG 71Z3Y1whmLfaCQDc0l69rOADCRRfbFMYOIhfTBfqNS8Qt7xx20bt3ONDxZZ3vXNxZ9ni /PvQPUpE2UHwIJkhTfX3HG0FLgjBbbGl0VUz/mp5JlT/7QJD8e7veuXlj2s2vbk52+tl k5XKPRCggJjm5dApNLDwTFn3jfsdbWtbUxW5oaREQDtQv61Kk+XJG9/d7ig14I1/AQrW F9MJ2ryv8SNL8SJ3qAh//IlYLjqDmgIUipW7Vo09lu651kWI6m3UyETE5Y3EdLPKvULU JG1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Y9ohffHg6a/5an4woAaoObkTKChNi1KsetUKi59vSbU=; b=rMWEUw8Ff7rxSmjncze+o1hst80roqfHfERFMZo9dGYjPewWzh9pVPxP8W3AMPkG1S nUPqHsBx+AK/I5za8WQhk/I21R2PXHFKVWkim3KIPT34L1SOoPs314ivoD5CSdA74cj1 /5IgRsgfaQK/lu9+j7Ysv9BKA/PhCMHbpVp5auhJbdyc8ozH/J2OJ8qZweLrzq/SESBc iHpsY+glDJLbpMizCzPpxEUMeZ17qkUcCIrYn30KkRaER87eNl1b9xD01ozqFYZYeQll TxMSqiJP3Mt7bQa4CKirmrt7xvzrCUwuu+hGJZxJTTlqHL2ZoCPkFHG4ae5NHZtXLAGX 3VKA== X-Gm-Message-State: AKS2vOzPvtqKz0ASu/fHu3EomKbra4aVl62vumfE9oiiSHQiP9uYSAEu pEcMtz20MCQ6gFH5 X-Received: by 10.84.202.163 with SMTP id x32mr1941923pld.99.1498551193775; Tue, 27 Jun 2017 01:13:13 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id x64sm4710903pfk.20.2017.06.27.01.13.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jun 2017 01:13:13 -0700 (PDT) From: Oliver O'Halloran To: linux-nvdimm@lists.01.org Subject: [PATCH] ndctl: Add alignment to the namespace JSON output Date: Tue, 27 Jun 2017 18:13:04 +1000 Message-Id: <20170627081304.6534-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.4 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: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Automated tooling probably wants to know this and it's helpful output for command line users for ndctl. Signed-off-by: Oliver O'Halloran --- util/json.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/util/json.c b/util/json.c index b718d747c285..9e4aa2655514 100644 --- a/util/json.c +++ b/util/json.c @@ -443,6 +443,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns, struct ndctl_btt *btt; struct ndctl_pfn *pfn; struct ndctl_dax *dax; + unsigned long align = 0; char buf[40]; uuid_t uuid; @@ -509,6 +510,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns, bdev = ndctl_btt_get_block_device(btt); } else if (pfn) { + align = ndctl_pfn_get_align(pfn); ndctl_pfn_get_uuid(pfn, uuid); uuid_unparse(uuid, buf); jobj = json_object_new_string(buf); @@ -519,6 +521,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns, } else if (dax) { struct daxctl_region *dax_region; + align = ndctl_dax_get_align(dax); ndctl_dax_get_uuid(dax, uuid); uuid_unparse(uuid, buf); jobj = json_object_new_string(buf); @@ -553,6 +556,13 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns, } else bdev = ndctl_namespace_get_block_device(ndns); + if (align) { + jobj = json_object_new_int64(align); + if (!jobj) + goto err; + json_object_object_add(jndns, "align", jobj); + } + if (bdev && bdev[0]) { jobj = json_object_new_string(bdev); if (!jobj)