From patchwork Tue Jan 29 14:48:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 10786425 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2783A139A for ; Tue, 29 Jan 2019 14:49:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FF072C29A for ; Tue, 29 Jan 2019 14:49:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01B652C29C; Tue, 29 Jan 2019 14:49: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=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,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 29DBF2C29A for ; Tue, 29 Jan 2019 14:49:15 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 01EA0211BB8D6; Tue, 29 Jan 2019 06:49:15 -0800 (PST) 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=2607:f8b0:4864:20::544; helo=mail-pg1-x544.google.com; envelope-from=oohall@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (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 28662211B5A34 for ; Tue, 29 Jan 2019 06:49:13 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id c25so8837591pgb.4 for ; Tue, 29 Jan 2019 06:49:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AwK3V4JjzI8OAj56XqChv0r1JtqL56kFM+V2uomzmQY=; b=OhcdkYyuphKHbkbcBDwJYjRo2DErFVpGFZGD9ta4IhqRHbZB1rS7qH3zZY0PsNPmgi +eYXxf26u7Ax4h7KHXG4heu8dUNlUFvhiKIYt0FcaGJyA9qdtes33RiE2E95eDqUZyv1 1u4uUaFDIqj2+rXnVqMvAC4HbPypm/zqSitFgJ4jiGce9jDa/kB1vjEcxHTzFxWRrO3c QKXEsuNLhRFqCCrwFbkizPmE2T0w2X52kaWKPEzezQiVZnQ3BetzbcvSiXxq+Oq3Gb0/ a2aFE+WR05TWuKVoKNxObFVw+QIKJ/VgcxLmdpx51yrhqG2MoGCKKB/z9wdfK7aaiB5s f5kg== 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:mime-version :content-transfer-encoding; bh=AwK3V4JjzI8OAj56XqChv0r1JtqL56kFM+V2uomzmQY=; b=W67kQm8CD+G6RpfwEb8zSLGRJez8RwClxhDjoY8I3kwiDy2xTeYFOckDxr4CKMTt4b vuymkmkkAxP3l5JIOADNU2O+IrRib0XvzCQCBTQGnXV1fnN6EXp5UELl41f1QwbFiZHx yScAOzHLsw9DpLQnsR5ynxMl4gcaX7xwtsyNApNaaI6IpY591stW1xnbIF701nr7TgWS ln0miJyx3w25OFpMIAwRH4L6HI1zKWDvFKd6gr/JdZ+WObNbE6Tb8YEmi+ApvbBmUMEW c3ktJICJ8RSlOml5C/X/Lg+nkLX824zHXfVnzgDD+c14k+vWjosypmmxcojyaCEITNIs yK5w== X-Gm-Message-State: AJcUukctshpMvXobjQTNbc4kNlTzpWDR+Zs+EkSOi1nSYoSVK5Tt8N9A 6dO1/8gjWSHXRmSZOBFxUstlzm/2 X-Google-Smtp-Source: ALg8bN6JLx9/EK0ioTplkdwwUp4z1tdYNcn0LBGRHCbil6VdYanMOD8eFQgH6rynSGt1ZPirt3DQjQ== X-Received: by 2002:a62:178f:: with SMTP id 137mr26234118pfx.226.1548773353273; Tue, 29 Jan 2019 06:49:13 -0800 (PST) Received: from 192-168-1-15.tpgi.com.au (203-219-255-210.tpgi.com.au. [203.219.255.210]) by smtp.gmail.com with ESMTPSA id g26sm44944677pfh.61.2019.01.29.06.49.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jan 2019 06:49:12 -0800 (PST) From: Oliver O'Halloran To: linux-nvdimm@lists.01.org Subject: [PATCH v4 1/5] libndctl: Use the supported_alignment attribute Date: Wed, 30 Jan 2019 01:48:53 +1100 Message-Id: <20190129144857.6741-1-oohall@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 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 Newer kernels provide the "supported_alignments" sysfs attribute that indicates what alignments can be used with a PFN or DAX namespace. This patch adds the plumbing inside of libndctl to allow users to query this information through using: ndctl_{dax|pfn}_get_supported_alignment(), and ndctl_{dax|pfn}_get_num_alignments() Signed-off-by: Oliver O'Halloran --- v4: Changed return code of ndctl_pfn_get_supported_alignment from -1 to -1 to -EINVAL. Reworded comment about why we default to 4K and 2M alignments when the sysfs attribute is missing. Shuffled around prototypes in ndctl.h. 80 char compliance fixes. rebased onto pending branch v3: Changed the return type of the *_get_supported_alignment() functions to unsigned long to match the existing *_get_alignment() functions. --- ndctl/lib/libndctl.c | 44 ++++++++++++++++++++++++++++++++++++++++++ ndctl/lib/libndctl.sym | 4 ++++ ndctl/libndctl.h | 4 ++++ 3 files changed, 52 insertions(+) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 830b791339d2..64cd2996bbd9 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -237,6 +238,7 @@ struct ndctl_pfn { int buf_len; uuid_t uuid; int id, generation; + struct ndctl_lbasize alignments; }; struct ndctl_dax { @@ -4814,6 +4816,20 @@ static void *__add_pfn(struct ndctl_pfn *pfn, const char *pfn_base) else pfn->size = strtoull(buf, NULL, 0); + /* + * The supported_alignments attribute was added before arches other + * than x86 had pmem support. If the kernel doesn't provide the + * attribute then it's safe to a attribute then it's safe to assume + * that we are on x86 which will always support 2MB and 4KB + * alignments. + */ + sprintf(path, "%s/supported_alignments", pfn_base); + if (sysfs_read_attr(ctx, path, buf) < 0) + sprintf(buf, "%d %d", SZ_4K, SZ_2M); + + if (parse_lbasize_supported(ctx, pfn_base, buf, &pfn->alignments) < 0) + goto err_read; + free(path); return pfn; @@ -5048,6 +5064,23 @@ NDCTL_EXPORT int ndctl_pfn_set_align(struct ndctl_pfn *pfn, unsigned long align) return 0; } +NDCTL_EXPORT int ndctl_pfn_get_num_alignments(struct ndctl_pfn *pfn) +{ + return pfn->alignments.num; +} + +NDCTL_EXPORT unsigned long ndctl_pfn_get_supported_alignment( + struct ndctl_pfn *pfn, int i) +{ + if (pfn->alignments.num == 0) + return 0; + + if (i < 0 || i > pfn->alignments.num) + return -EINVAL; + else + return pfn->alignments.supported[i]; +} + NDCTL_EXPORT int ndctl_pfn_set_namespace(struct ndctl_pfn *pfn, struct ndctl_namespace *ndns) { @@ -5270,6 +5303,17 @@ NDCTL_EXPORT unsigned long ndctl_dax_get_align(struct ndctl_dax *dax) return ndctl_pfn_get_align(&dax->pfn); } +NDCTL_EXPORT int ndctl_dax_get_num_alignments(struct ndctl_dax *dax) +{ + return ndctl_pfn_get_num_alignments(&dax->pfn); +} + +NDCTL_EXPORT unsigned long ndctl_dax_get_supported_alignment( + struct ndctl_dax *dax, int i) +{ + return ndctl_pfn_get_supported_alignment(&dax->pfn, i); +} + NDCTL_EXPORT int ndctl_dax_has_align(struct ndctl_dax *dax) { return ndctl_pfn_has_align(&dax->pfn); diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym index 275db92ee103..a30a93e3c012 100644 --- a/ndctl/lib/libndctl.sym +++ b/ndctl/lib/libndctl.sym @@ -390,4 +390,8 @@ LIBNDCTL_19 { global: ndctl_cmd_xlat_firmware_status; ndctl_cmd_submit_xlat; + ndctl_pfn_get_supported_alignment; + ndctl_pfn_get_num_alignments; + ndctl_dax_get_supported_alignment; + ndctl_dax_get_num_alignments; } LIBNDCTL_18; diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h index e55a5932781d..ac639b7d9142 100644 --- a/ndctl/libndctl.h +++ b/ndctl/libndctl.h @@ -597,7 +597,9 @@ int ndctl_pfn_set_uuid(struct ndctl_pfn *pfn, uuid_t uu); void ndctl_pfn_get_uuid(struct ndctl_pfn *pfn, uuid_t uu); int ndctl_pfn_has_align(struct ndctl_pfn *pfn); int ndctl_pfn_set_align(struct ndctl_pfn *pfn, unsigned long align); +int ndctl_pfn_get_num_alignments(struct ndctl_pfn *pfn); unsigned long ndctl_pfn_get_align(struct ndctl_pfn *pfn); +unsigned long ndctl_pfn_get_supported_alignment(struct ndctl_pfn *pfn, int i); unsigned long long ndctl_pfn_get_resource(struct ndctl_pfn *pfn); unsigned long long ndctl_pfn_get_size(struct ndctl_pfn *pfn); int ndctl_pfn_set_namespace(struct ndctl_pfn *pfn, struct ndctl_namespace *ndns); @@ -628,7 +630,9 @@ unsigned long long ndctl_dax_get_resource(struct ndctl_dax *dax); int ndctl_dax_set_uuid(struct ndctl_dax *dax, uuid_t uu); enum ndctl_pfn_loc ndctl_dax_get_location(struct ndctl_dax *dax); int ndctl_dax_set_location(struct ndctl_dax *dax, enum ndctl_pfn_loc loc); +int ndctl_dax_get_num_alignments(struct ndctl_dax *dax); unsigned long ndctl_dax_get_align(struct ndctl_dax *dax); +unsigned long ndctl_dax_get_supported_alignment(struct ndctl_dax *dax, int i); int ndctl_dax_has_align(struct ndctl_dax *dax); int ndctl_dax_set_align(struct ndctl_dax *dax, unsigned long align); int ndctl_dax_set_namespace(struct ndctl_dax *dax, From patchwork Tue Jan 29 14:48:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 10786427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB7F81399 for ; Tue, 29 Jan 2019 14:49:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9FB92C29A for ; Tue, 29 Jan 2019 14:49:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B7A02C29C; Tue, 29 Jan 2019 14:49:17 +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.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,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 47C4A2C29A for ; Tue, 29 Jan 2019 14:49:17 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1A148211BB8DC; Tue, 29 Jan 2019 06:49:17 -0800 (PST) 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=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=oohall@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (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 0B3352194D3AE for ; Tue, 29 Jan 2019 06:49:15 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id g9so9441144plo.3 for ; Tue, 29 Jan 2019 06:49:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9CZe6/mPyds7N/cI342d0fhejbMy5coCz60V5tgIoz0=; b=UJO6xmQUYJ4VDJFSOKzveQXsG9Czv7J6ugZErM7Dv8w0GmfPLx98u0UsG+Aojw6pP5 JxmHyx5M63zaEYBFdz4J2lqFWGnh3Who7Zx33TJIqQ7SuzTG+us2kNEYYDVuOjqMlHxn GPslyk126ZsKyLGAVb3K003YKvz5apgx2wEwwjfTuuvPmuBZ4pEzXHzRY4NevUcOzTBe 4t90NPUum4X/jJHw3cQ0jTxEbjNRDS1YdqQYywi5lcvhnr7roZm9PpqfjqjB5CL/0GcB 4U80CeRZPFEb4symDcbhbFBsdwJMFOM/CviVzQiPyraVA5hJQSOZ88KBiwcFGJwESX6c V/ew== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=9CZe6/mPyds7N/cI342d0fhejbMy5coCz60V5tgIoz0=; b=WpGkoBSezHPNXyaLTvtsxjFafAzKwdDfBCZl4l2t76ndQp9ZFXmAFeCbEOFmpmA5hO iEnCzTUGc6QFj7x0XCa1jC/GBV8YzcSRMEUbj9VzyCFxioF83RFbYasHsjHxMte2X/tC z+Z0NvAVDvpIC9rYSRxPHu0wq5836cJ7Qub/mtH0ST3Ll7Pe6SCtQRKwCs5l0T8kDYgQ GET2twhsSsERQ3pWPfKC3Jt38keKvE1hXY8yuLTuOvTvW3C2zfWYrfhtiJbThd0VJKvH +ufVpPAQNoQFNRvutWZI+CqD7Ptz14W/YGQy1b08aAvDXI2JZ2PAD5oW7fz1C0X5IAnq N2Ig== X-Gm-Message-State: AJcUukedCgQ0ZhZCRlgy+TwxNACRi83eUcioVxdOXO7Ldcc3xaxP5oU/ DvdaRdhatFoqz/36Mt15WjC/Ybcd X-Google-Smtp-Source: ALg8bN7/YkG+0ONaSBv5kk2z8y9A33l00OurCUGhWmAjp8M6Tbfdx3VHBawHsGgyZOwYnFLvfAtaag== X-Received: by 2002:a17:902:2c03:: with SMTP id m3mr25074779plb.6.1548773355341; Tue, 29 Jan 2019 06:49:15 -0800 (PST) Received: from 192-168-1-15.tpgi.com.au (203-219-255-210.tpgi.com.au. [203.219.255.210]) by smtp.gmail.com with ESMTPSA id g26sm44944677pfh.61.2019.01.29.06.49.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jan 2019 06:49:14 -0800 (PST) From: Oliver O'Halloran To: linux-nvdimm@lists.01.org Subject: [PATCH v4 2/5] ndctl/namespace: Check for seed namespaces earlier Date: Wed, 30 Jan 2019 01:48:54 +1100 Message-Id: <20190129144857.6741-2-oohall@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129144857.6741-1-oohall@gmail.com> References: <20190129144857.6741-1-oohall@gmail.com> MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 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 When creating an fsdax or devdax namespace we need to verify that the seed namespaces exist. This patch reworks the validation so that it's done earlier to simplify the subsequent patches in the series. Signed-off-by: Oliver O'Halloran --- No functional changes, I hope. v3: Don't fail early if the user specifies fsdax mode without pfn support. Instead, if we try to validate a feature that requires pfn support, fail the validation at that point. --- ndctl/namespace.c | 48 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index b35812bd17a9..12253a96e095 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -469,6 +469,8 @@ static int validate_namespace_options(struct ndctl_region *region, { const char *region_name = ndctl_region_get_devname(region); unsigned long long size_align = SZ_4K, units = 1, resource; + struct ndctl_pfn *pfn = NULL; + struct ndctl_dax *dax = NULL; unsigned int ways; int rc = 0; @@ -525,10 +527,24 @@ static int validate_namespace_options(struct ndctl_region *region, } else if (ndns) p->mode = ndctl_namespace_get_mode(ndns); - if (param.align) { - struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region); - struct ndctl_dax *dax = ndctl_region_get_dax_seed(region); + if (p->mode == NDCTL_NS_MODE_MEMORY) { + pfn = ndctl_region_get_pfn_seed(region); + if (!pfn && param.mode_default) { + debug("%s fsdax mode not available\n", region_name); + p->mode = NDCTL_NS_MODE_RAW; + } + /* + * NB: We only fail validation if a pfn-specific option is used + */ + } else if (p->mode == NDCTL_NS_MODE_DAX) { + dax = ndctl_region_get_dax_seed(region); + if (!dax) { + error("Kernel does not support devdax mode\n"); + return -ENODEV; + } + } + if (param.align) { p->align = parse_size64(param.align); if (p->mode == NDCTL_NS_MODE_MEMORY && p->align != SZ_2M @@ -709,30 +725,12 @@ static int validate_namespace_options(struct ndctl_region *region, || p->mode == NDCTL_NS_MODE_DAX) p->loc = NDCTL_PFN_LOC_PMEM; - /* check if we need, and whether the kernel supports, pfn devices */ - if (do_setup_pfn(ndns, p)) { - struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region); - - if (!pfn && param.mode_default) { - debug("%s fsdax mode not available\n", region_name); - p->mode = NDCTL_NS_MODE_RAW; - } else if (!pfn) { - error("operation failed, %s fsdax mode not available\n", - region_name); - return -EINVAL; - } + if (!pfn && do_setup_pfn(ndns, p)) { + error("operation failed, %s cannot support requested mode\n", + region_name); + return -EINVAL; } - /* check if we need, and whether the kernel supports, dax devices */ - if (p->mode == NDCTL_NS_MODE_DAX) { - struct ndctl_dax *dax = ndctl_region_get_dax_seed(region); - - if (!dax) { - error("operation failed, %s devdax mode not available\n", - region_name); - return -EINVAL; - } - } p->autolabel = param.autolabel; From patchwork Tue Jan 29 14:48:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 10786429 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D409C14E1 for ; Tue, 29 Jan 2019 14:49:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEB7E2C8A0 for ; Tue, 29 Jan 2019 14:49:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B093B2C8A4; Tue, 29 Jan 2019 14:49: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=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,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 3DF4C2C8A0 for ; Tue, 29 Jan 2019 14:49:20 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 321D0211B696B; Tue, 29 Jan 2019 06:49:20 -0800 (PST) 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=2607:f8b0:4864:20::643; helo=mail-pl1-x643.google.com; envelope-from=oohall@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (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 5010C211B5A34 for ; Tue, 29 Jan 2019 06:49:18 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id e11so9424136plt.11 for ; Tue, 29 Jan 2019 06:49:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uUaBuQNjN+mwEK3nGm85GwqwVxv+e1kYXkYn5D57eJ4=; b=PP6jt6RDOH9HDMn7gs8S+C674a9BYGdVEDMlFKnrZdT/El2owJnA4PiAxe+R19nf++ /GUEDab/JdGoytKcOAd8X7R893hPrfp7t+wgKdPsgIzXR8a/ese0SxkHJeOc4fM5SUWG q9s9ge8s2lbeKwlyzUb9g8gAqTtLh/Ha1swDZthZv532bJN01S09WU3zThih43CX2IIc 8pfOpwzGejU0enY+WrwQx9SeMMm7NC1TLAv6Q05j9FeDZKEsW3ZRxVvVlCUP6WQnh4T0 eQipaiA/8CMQ0+1/huW3mYwXyz8Zi+w+vz0vz9NA2ZqKC6aB7ZhdNP2DQ4YJjf9e5BiU qnSQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=uUaBuQNjN+mwEK3nGm85GwqwVxv+e1kYXkYn5D57eJ4=; b=t9w0nPNGheXYRV2PxgPNfNxWuriXIWHmZANNGsStzdFDr7b5Lf8mV7uGDIcsrgcN7v W0e6m5qWqVZdjF41wmzuP7PJb2QdjDDCkZyT4CMoJLp/m/ZnuLBqv2XdBiXOc3H+XKGi 9zjd9Kic9hBjVTBohw7jWt5C3aE0TR79oDuOrSRzW2zHTV5dohym48jr+idpMwbQbgqT gfKDzt4XwfUpUlWYCHTEb/QlP5cb610XGKCzrw7OUqpLsBbQE1gjhJfT7ySBI9x3SNSQ m81WZc2XrvTASiw73VzVOrgUE/8bDUMWktRUyVL2IOQdFJdHrMCVKCzsJmp6oPYhDNkd 2Gpw== X-Gm-Message-State: AJcUukexgPqpgE1GNm8jLOsZJ/ChSylcTKUNhCNghvs/dhHwJJGLYtyk 5LqWwdHGlL162LzkiUmNPYnil4ad X-Google-Smtp-Source: ALg8bN5kfTkDJzimWD+v0ArCUWX+4rCBZ/HPvzwkd6dhQw0bZXQZoMidwXE3tE3hUUK7J8/gbjxWkw== X-Received: by 2002:a17:902:e085:: with SMTP id cb5mr25970907plb.24.1548773357655; Tue, 29 Jan 2019 06:49:17 -0800 (PST) Received: from 192-168-1-15.tpgi.com.au (203-219-255-210.tpgi.com.au. [203.219.255.210]) by smtp.gmail.com with ESMTPSA id g26sm44944677pfh.61.2019.01.29.06.49.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jan 2019 06:49:17 -0800 (PST) From: Oliver O'Halloran To: linux-nvdimm@lists.01.org Subject: [PATCH v4 3/5] ndctl/namespace: Use seed alignment as the default Date: Wed, 30 Jan 2019 01:48:55 +1100 Message-Id: <20190129144857.6741-3-oohall@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129144857.6741-1-oohall@gmail.com> References: <20190129144857.6741-1-oohall@gmail.com> MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 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 When creating a pfn or dax namespace ndctl uses a default alignment of 2MB when the user does not explicitly supply one. This works on most systems (x86, ARM, PPC64 with radix MMU), but it fails when the kernel does not support a 2MB page size (PPC64 with hash MMU). This patch makes ndctl use the alignment of the relevant seed namespace as the default instead. The kernel will always pick a valid default alignment so this should be a bit more portable. Signed-off-by: Oliver O'Halloran --- v3: Only use the pfn seed for the default alignment if there is a pfn seed. --- ndctl/namespace.c | 96 +++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 53 deletions(-) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index 12253a96e095..5d672810a712 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -39,7 +39,6 @@ static bool logfix; static struct parameters { bool do_scan; bool mode_default; - bool align_default; bool autolabel; const char *bus; const char *map; @@ -226,9 +225,6 @@ static int set_defaults(enum device_action mode) error("failed to parse namespace alignment '%s'\n", param.align); rc = -EINVAL; - } else if (!param.align) { - param.align = "2M"; - param.align_default = true; } if (param.uuid) { @@ -468,7 +464,7 @@ static int validate_namespace_options(struct ndctl_region *region, struct ndctl_namespace *ndns, struct parsed_parameters *p) { const char *region_name = ndctl_region_get_devname(region); - unsigned long long size_align = SZ_4K, units = 1, resource; + unsigned long long size_align, units = 1, resource; struct ndctl_pfn *pfn = NULL; struct ndctl_dax *dax = NULL; unsigned int ways; @@ -545,53 +541,15 @@ static int validate_namespace_options(struct ndctl_region *region, } if (param.align) { - p->align = parse_size64(param.align); - - if (p->mode == NDCTL_NS_MODE_MEMORY && p->align != SZ_2M - && (!pfn || !ndctl_pfn_has_align(pfn))) { - /* - * Initial pfn device support in the kernel - * supported a 2M default alignment when - * ndctl_pfn_has_align() returns false. - */ - debug("%s not support 'align' for fsdax mode\n", - region_name); - return -EAGAIN; - } else if (p->mode == NDCTL_NS_MODE_DAX - && (!dax || !ndctl_dax_has_align(dax))) { - /* - * Unlike the pfn case, we require the kernel to - * have 'align' support for device-dax. - */ - debug("%s not support 'align' for devdax mode\n", - region_name); - return -EAGAIN; - } else if (!param.align_default - && (p->mode == NDCTL_NS_MODE_SAFE - || p->mode == NDCTL_NS_MODE_RAW)) { - /* - * Specifying an alignment has no effect for - * raw, or btt mode namespaces. - */ + if (p->mode != NDCTL_NS_MODE_MEMORY && + p->mode != NDCTL_NS_MODE_DAX) { error("%s mode does not support setting an alignment\n", p->mode == NDCTL_NS_MODE_SAFE ? "sector" : "raw"); return -ENXIO; } - /* - * Fallback to a 4K default alignment if the region is - * not 2MB (typical default) aligned. This mainly helps - * the nfit_test use case where it is backed by vmalloc - * memory. - */ - resource = ndctl_region_get_resource(region); - if (param.align_default && resource < ULLONG_MAX - && (resource & (SZ_2M - 1))) { - debug("%s: falling back to a 4K alignment\n", - region_name); - p->align = SZ_4K; - } + p->align = parse_size64(param.align); switch (p->align) { case SZ_4K: @@ -602,16 +560,48 @@ static int validate_namespace_options(struct ndctl_region *region, error("unsupported align: %s\n", param.align); return -ENXIO; } + } else { + /* + * Use the seed namespace alignment as the default if we need + * one. If we don't then use PAGE_SIZE so the size_align + * checking works. + */ + if (p->mode == NDCTL_NS_MODE_MEMORY) { + /* + * The initial pfn device support in the kernel didn't + * have the 'align' sysfs attribute and assumed a 2MB + * alignment. Fall back to that if we don't have the + * attribute. + */ + if (pfn && ndctl_pfn_has_align(pfn)) + p->align = ndctl_pfn_get_align(pfn); + else + p->align = SZ_2M; + } else if (p->mode == NDCTL_NS_MODE_DAX) { + /* + * device dax mode was added after the align attribute + * so checking for it is unnecessary. + */ + p->align = ndctl_dax_get_align(dax); + } else { + p->align = sysconf(_SC_PAGE_SIZE); + } /* - * 'raw' and 'sector' mode namespaces don't support an - * alignment attribute. + * Fallback to a page alignment if the region is not aligned + * to the default. This is mainly useful for the nfit_test + * use case where it is backed by vmalloc memory. */ - if (p->mode == NDCTL_NS_MODE_MEMORY - || p->mode == NDCTL_NS_MODE_DAX) - size_align = p->align; + resource = ndctl_region_get_resource(region); + if (resource < ULLONG_MAX && (resource & (p->align - 1))) { + debug("%s: falling back to a page alignment\n", + region_name); + p->align = sysconf(_SC_PAGE_SIZE); + } } + size_align = p->align; + /* (re-)validate that the size satisfies the alignment */ ways = ndctl_region_get_interleave_ways(region); if (p->size % (size_align * ways)) { @@ -637,8 +627,8 @@ static int validate_namespace_options(struct ndctl_region *region, p->size *= size_align; p->size /= units; error("'--size=' must align to interleave-width: %d and alignment: %ld\n" - " did you intend --size=%lld%s?\n", ways, param.align - ? p->align : SZ_4K, p->size, suffix); + "did you intend --size=%lld%s?\n", + ways, p->align, p->size, suffix); return -EINVAL; } From patchwork Tue Jan 29 14:48:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 10786431 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C52B21399 for ; Tue, 29 Jan 2019 14:49:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADBF82C8A3 for ; Tue, 29 Jan 2019 14:49:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F0D62C8AF; Tue, 29 Jan 2019 14:49:22 +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.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,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 53A4E2C8A3 for ; Tue, 29 Jan 2019 14:49:22 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4BF28211BD5E6; Tue, 29 Jan 2019 06:49:22 -0800 (PST) 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=2607:f8b0:4864:20::643; helo=mail-pl1-x643.google.com; envelope-from=oohall@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (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 ADCA6211B5A34 for ; Tue, 29 Jan 2019 06:49:20 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id e5so9446143plb.5 for ; Tue, 29 Jan 2019 06:49:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PGMLKYyWN6m+7zcPu8D+Qb9UkgrHqlfU5cdS5j2X1o0=; b=fqJVknYelydC7TBxh4qPeh332mOz8sXfVL354c9RFh1Jqb+++EFIWU1oABAkmXS0e/ PciyPsKFIb4nohe7fFhEpdAsvVKhKQqrKTLOw1iWOEN4aO8P30xsvmzC0D3+NRqU3UOE BfjV7H6yBo4uMjG2Tua91dutvjUIKzvUmPx6+/dtmIE3um03d86sD8j92oJiqpG8qiI3 5WNgl6bWMBf7KBHtTgPs6jD//tcfAkLvPL97bYMXNM5EEvxc3yzGyjUGlrb8UEP4+V3+ +dujOUcgL8+OY1oQdZVJBloX+TZSBDsuraPaYw7I3S55u2H4ohH5//67lDgV1wVPewFj N3XQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=PGMLKYyWN6m+7zcPu8D+Qb9UkgrHqlfU5cdS5j2X1o0=; b=NRjb/jsfxhX9YpmZr11a5v4xXalpjZnJ6zEWS7tbuoIYaQNrwP9vktxhwP0eCD0dwu iN8kyVkPGmchAY0EWlG1B2SHFyvyAjfKVR4iRV0W52WJGVP2ddRQ8YQplnSYh3AGv7Gi edO3ztLDOSNrEwvE4yQUW7ufO66pmevJcThlrTKVdffFNVjAEvZ69oUS/CITXRKTo00u 9Tecglfq3kgETryYs6QEr9AAV1F5QEO5Q8046SLd3oBUrBDY8zYCQ0s2FlmZlaTaoize feFjwjf44o3uYt+eJvWFSFdAEbi101yUuuJWCTO1u3JlBWvvtTXODjxiWVX6jGbSvNlo Li5g== X-Gm-Message-State: AJcUukdt3pdLDknSlzKF6YD/KFOkaoflQcaIxZ4BQ6q+DuZRg1BD6M4w 1WqngP1t/EYqFowZk8xYJNmhRb/A X-Google-Smtp-Source: ALg8bN7AxtMTvNmwxy1mjYv6LE94+1psndPH57NKn9QjMEvie6Zq0YQD7i1rRrdSvPP9GPYvawsd+A== X-Received: by 2002:a17:902:a70b:: with SMTP id w11mr26106315plq.84.1548773360115; Tue, 29 Jan 2019 06:49:20 -0800 (PST) Received: from 192-168-1-15.tpgi.com.au (203-219-255-210.tpgi.com.au. [203.219.255.210]) by smtp.gmail.com with ESMTPSA id g26sm44944677pfh.61.2019.01.29.06.49.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jan 2019 06:49:19 -0800 (PST) From: Oliver O'Halloran To: linux-nvdimm@lists.01.org Subject: [PATCH v4 4/5] ndctl/namespace: Validate alignment from the {pfn|dax} seed Date: Wed, 30 Jan 2019 01:48:56 +1100 Message-Id: <20190129144857.6741-4-oohall@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129144857.6741-1-oohall@gmail.com> References: <20190129144857.6741-1-oohall@gmail.com> MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 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 This patch adds support to the ndctl tool for validating that the namespace alignment is valid. Signed-off-by: Oliver O'Halloran --- v3: Fail validation if an alignment is specified, but pfn mode is not supported. --- ndctl/namespace.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index 5d672810a712..25e0a87676e4 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -541,8 +541,23 @@ static int validate_namespace_options(struct ndctl_region *region, } if (param.align) { - if (p->mode != NDCTL_NS_MODE_MEMORY && - p->mode != NDCTL_NS_MODE_DAX) { + int i, alignments; + + switch (p->mode) { + case NDCTL_NS_MODE_MEMORY: + if (!pfn) { + error("Kernel does not support setting an alignment in fsdax mode\n"); + return -EINVAL; + } + + alignments = ndctl_pfn_get_num_alignments(pfn); + break; + + case NDCTL_NS_MODE_DAX: + alignments = ndctl_dax_get_num_alignments(dax); + break; + + default: error("%s mode does not support setting an alignment\n", p->mode == NDCTL_NS_MODE_SAFE ? "sector" : "raw"); @@ -550,13 +565,19 @@ static int validate_namespace_options(struct ndctl_region *region, } p->align = parse_size64(param.align); + for (i = 0; i < alignments; i++) { + uint64_t a; - switch (p->align) { - case SZ_4K: - case SZ_2M: - case SZ_1G: - break; - default: + if (p->mode == NDCTL_NS_MODE_MEMORY) + a = ndctl_pfn_get_supported_alignment(pfn, i); + else + a = ndctl_dax_get_supported_alignment(dax, i); + + if (p->align == a) + break; + } + + if (i >= alignments) { error("unsupported align: %s\n", param.align); return -ENXIO; } From patchwork Tue Jan 29 14:48:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 10786433 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C7E8014E1 for ; Tue, 29 Jan 2019 14:49:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B56672C8A4 for ; Tue, 29 Jan 2019 14:49:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9F442C8B2; Tue, 29 Jan 2019 14:49:24 +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.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,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 6BE742C8A4 for ; Tue, 29 Jan 2019 14:49:24 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 64BAF211BD5E8; Tue, 29 Jan 2019 06:49:24 -0800 (PST) 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=2607:f8b0:4864:20::542; helo=mail-pg1-x542.google.com; envelope-from=oohall@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (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 22266211B5A34 for ; Tue, 29 Jan 2019 06:49:23 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id v28so8829470pgk.10 for ; Tue, 29 Jan 2019 06:49:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lRsftHXqbcA8HYVYnpE+da6pldgpNEpRW/GWwqlthA4=; b=CU5xwkolaoJ/tPmchiTS7SLGeaCrBAxQTSv4OyBQLx4N2a3b7vVjFIQwCCTI7bOW9O N/td84toLkFQ1v75fqN+m6U0dyUhvjJBvYsIqn+j45Vcy/+o2SlVRY1z+aBBHPwXpWfr GbOivoUAhZRrAJUYptqLMnBDB6eLp5QFHfjfDbzix9nFTWqUn7rHEg/qomQkZScAyPhM 6tf45U2FYte7Ek7MEWudrgJ6TNSsf6oGurJgkTPwE2mMhdk4og32cdb9KhQTQJYF4IRs mMDwGPUm3lH/f/cu6l9WD9/fxOY86AU6ItcQdumzDfsFnQoBstzCMDd+Y4LXF0NQaNrr bX8Q== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=lRsftHXqbcA8HYVYnpE+da6pldgpNEpRW/GWwqlthA4=; b=GCRVa3V2eKdBaLYVwKX5Dd6pldGTBhHUw4bCO1FtjZiGPkhO7fPMO4IbZ0FxUTq8xh ki86Dc/annhwC9lumSNq6xRh/R0MPXyONt7p1iPwGw+nx+vNxo/KJ3H9n2gG0VTZN11U QcE8oKlY/wE60PX76OyJ0vldF/kXzSkdLEx6CT+cklIUlF6nZRM22e2hw2oP8cK2Y7Vo UllnvjB800z0B3zUtSK8E7v5/zKPjHJaskgfKyu4LnxT/i7b8j4Hov758jvTpsvuhKSt joC65hdUKRgjQ83t9PTDxXgTPRFqU1ulyRq3o/vYJDBAiullEBrH718yO0H2TssrCr0e al1g== X-Gm-Message-State: AJcUukct+ioHPd1SyRs41vGE47QUA61lurHwwhKDIWugW8FqX+AxEJe7 2YlmSeRFSRORcz8VWuL2VibkccMf X-Google-Smtp-Source: ALg8bN7guDIbGIC9ejCKiabRHDohpSuhkdGSAZqfPqiwMz/99WhgB8ztdwYqI3N1yNshivptU8dKCw== X-Received: by 2002:a63:f047:: with SMTP id s7mr23861275pgj.441.1548773362483; Tue, 29 Jan 2019 06:49:22 -0800 (PST) Received: from 192-168-1-15.tpgi.com.au (203-219-255-210.tpgi.com.au. [203.219.255.210]) by smtp.gmail.com with ESMTPSA id g26sm44944677pfh.61.2019.01.29.06.49.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jan 2019 06:49:21 -0800 (PST) From: Oliver O'Halloran To: linux-nvdimm@lists.01.org Subject: [PATCH v4 5/5] ndctl: Add alignment to the namespace JSON output Date: Wed, 30 Jan 2019 01:48:57 +1100 Message-Id: <20190129144857.6741-5-oohall@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129144857.6741-1-oohall@gmail.com> References: <20190129144857.6741-1-oohall@gmail.com> MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 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 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 5c3424e2a707..77c96fb53c27 100644 --- a/util/json.c +++ b/util/json.c @@ -753,6 +753,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; int numa; @@ -825,6 +826,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns, util_raw_uuid_to_json(ndns, flags, jndns); 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); @@ -837,6 +839,7 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns, struct daxctl_region *dax_region; dax_region = ndctl_dax_get_daxctl_region(dax); + align = ndctl_dax_get_align(dax); ndctl_dax_get_uuid(dax, uuid); uuid_unparse(uuid, buf); jobj = json_object_new_string(buf); @@ -897,6 +900,13 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns, json_object_object_add(jndns, "sector_size", jobj); } + 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)