From patchwork Wed Jan 16 09:49:05 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: 10765591 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 1EFDB1580 for ; Wed, 16 Jan 2019 09:49:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D7BC2B2B4 for ; Wed, 16 Jan 2019 09:49:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01C202BA01; Wed, 16 Jan 2019 09:49:26 +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 A7C472B2B4 for ; Wed, 16 Jan 2019 09:49:26 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 763A6211B7F98; Wed, 16 Jan 2019 01:49:26 -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 55207211B7F96 for ; Wed, 16 Jan 2019 01:49:25 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id 101so2777503pld.6 for ; Wed, 16 Jan 2019 01:49:25 -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=46DR0Iy+XEU3vtV1l9nPDq2ObI9w6u0Mr70qvxM3vts=; b=s9UY0xE8tZOjER3e6xMZCQrKdHZYMKukJFnld3XdmGoa9Oj0JfGkx+qM/J3yRI3Uns J/WG5oPOyKKI+PyJQzyWMt99ziwIrbqRSSM32yvYkd0JCQGnO722eaLGhS9ipqc9stsL 9ecSXqdEHtgSIKf7oHV1t42qsAWIG2yYhd5NUwRMEXwsENcASm/EXwwwu17ESKdPeH5W HExrZHPfEJTfzpaXOy8OUv3+DapESMrPpOEnzEzvCHkbpZG22upjAeYtzZj3X7mRt+TO w5SDrJFXM3Z+0sAwWrjx3mCSZ2JvTg3/h2Q301rLjfYwTDEm43YyB3b//uhTmK+H4nae cy/g== 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=46DR0Iy+XEU3vtV1l9nPDq2ObI9w6u0Mr70qvxM3vts=; b=pES4UxvLjUAIwJUlGVY9COk+WPCvStNZn3TDK3EKlrGPNtbKoFbms1bmevJUNHyDCM KDgI9sEXL0aIbINHlZJi0l9zAaeSvg+67TGm0nSYw9L27mpEjUTcG647K7pTi6QiDHZn /MptQGlaNMa4PKBKqiNsjD/PM91/+0xFcQPeYEjF33H0pPtEbDlmzUJ7X6zjFvh/c5rm Fzuy+lA20rBea1lhUNlJWSbwt7V6YyVJ7HQz1fngmDjf9/AlJtxAxtbweL//HSA1QQgW x0Y6/JioOAYSlNU+pXq1Z5/Qkxk2DJ4+hKU7SXChTcMHtl07xVps4WmUdFT8R3JpPVfU VRxA== X-Gm-Message-State: AJcUukeUl66C2TDgb3QFJRZ036l6idpdRSmmJM2GgU3d3z+US6y32sgp SjpJojqMuQ2gYCvxy5J0ogrWKAOa X-Google-Smtp-Source: ALg8bN4YUITqxi/pYsrcNh4rWnqr5/4r8Gr9HnBxjk5DbiW2iEAtQbIIQ/uxDKJe5qN3qU6LqBfJWA== X-Received: by 2002:a17:902:8a95:: with SMTP id p21mr9085174plo.183.1547632164812; Wed, 16 Jan 2019 01:49:24 -0800 (PST) Received: from wafer.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id f13sm8777331pfa.132.2019.01.16.01.49.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Jan 2019 01:49:24 -0800 (PST) From: Oliver O'Halloran To: linux-nvdimm@lists.01.org Subject: [PATCH v3 2/6] ndctl/namespace: Check for seed namespaces earlier Date: Wed, 16 Jan 2019 20:49:05 +1100 Message-Id: <20190116094909.23112-2-oohall@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190116094909.23112-1-oohall@gmail.com> References: <20190116094909.23112-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, probably. --- ndctl/namespace.c | 48 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index b6f12306fe76..efa8250456d9 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -465,6 +465,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; @@ -521,10 +523,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 @@ -705,30 +721,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;