From patchwork Mon Nov 19 08:00:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 10688263 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 D4F0A14BD for ; Mon, 19 Nov 2018 08:10:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C583529A57 for ; Mon, 19 Nov 2018 08:10:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9D2529A62; Mon, 19 Nov 2018 08:10:42 +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 68B3F29A57 for ; Mon, 19 Nov 2018 08:10:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5E83A21DF809D; Mon, 19 Nov 2018 00:10:35 -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 E721521A09130 for ; Mon, 19 Nov 2018 00:01:09 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id b22-v6so8749166pls.7 for ; Mon, 19 Nov 2018 00:01:09 -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; bh=lRSuHadXYH/JHI9nBWMdlUc1F60ZTgL1sZQkOjahN38=; b=fvvdGBPjmZPH+r6dhgBQROwv5wkNcCQn0oBq002V6VejDZdYiBmdlLwjIC1H6LzX20 PTYbJjIiX3OVI1tNy1RpbOCk9HLtyJ4mtVG416CQapvyW12EsnX5q3FUsbyPt2VmRP4H EL2FfsKBpwFJz6MxCHXPnjVtGd0U1EgklmSS+MtYVaxQcI/aPMCke/YnGn2xYFtHwQ/N GBqW/5XXeurrwSeQJJY4gVTiWTWNyEgoVE9TXzhbqE/mMp77zNPPMQLvEX1PyonNwfl3 /4wzpBlZbeMWcxNVqD3wDtfoxLCAFDZeNGswF0dulO0Rg9lXMTnCCh/KebqWu7vCqy9l T3Bw== 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; bh=lRSuHadXYH/JHI9nBWMdlUc1F60ZTgL1sZQkOjahN38=; b=WSrgd0nleY//ozoXcoNA4WydZclPkIfy5i6k6xXJBKVioPSAgcgoSddT2KnO/t2VXb zCANfVEZaZJ7pK8jisd9Yzw16Zazp0O863KEOpjXrHK/WVtIavsX5F7csQP6q2c6MTXi prlLMQqqF2krsrPFSb9fQ2d2WCkXjisB4gwZzrcswHPW71jqVnHFW7Sj68XGA6EEUvo1 UA3Faikw0EXBAQNvgnqDyGlp9QO7NejgZvG3ZydCt5B5Nyh8hBefeAFj0tEkGdnOo9GF fLB0ASO0NAYjQ38HtVFQT44dxEwf0qwmmt5mGoCdHTbDCQCtRjadZjeipLDsFx33DouZ +WJA== X-Gm-Message-State: AA+aEWbJYegqkuq7SwXnp6L108l336+iUbr51uCQ7nbZPAY7TCJg6yNn n1jWothGEHDHDWDkMrTONz3Hx9LV X-Google-Smtp-Source: AFSGD/V8PIsqNO4Eo27ngqRPIXyt9B0v3qdkd7fnEht/PH1hJgIM90Z0WT/UZ+q6X+QC/W3+QQVFAQ== X-Received: by 2002:a17:902:9b93:: with SMTP id y19mr10859701plp.336.1542614469405; Mon, 19 Nov 2018 00:01:09 -0800 (PST) Received: from wafer.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id g123-v6sm56059007pfc.155.2018.11.19.00.01.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Nov 2018 00:01:08 -0800 (PST) From: Oliver O'Halloran To: linux-nvdimm@lists.01.org Subject: [PATCH 2/4] ndctl/namespace: Check for seed namespaces earlier Date: Mon, 19 Nov 2018 19:00:54 +1100 Message-Id: <20181119080056.13386-2-oohall@gmail.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181119080056.13386-1-oohall@gmail.com> References: <20181119080056.13386-1-oohall@gmail.com> 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: , MIME-Version: 1.0 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. No functional changes. Signed-off-by: Oliver O'Halloran --- ndctl/namespace.c | 51 +++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index b6f12306fe76..dc9a56609881 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,14 +523,28 @@ 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; + } else if (!pfn) { + error("Kernel does not support fsdax mode\n"); + return -ENODEV; + } + } 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 - && (!pfn || !ndctl_pfn_has_align(pfn))) { + && !ndctl_pfn_has_align(pfn)) { /* * Initial pfn device support in the kernel * supported a 2M default alignment when @@ -538,7 +554,7 @@ static int validate_namespace_options(struct ndctl_region *region, region_name); return -EAGAIN; } else if (p->mode == NDCTL_NS_MODE_DAX - && (!dax || !ndctl_dax_has_align(dax))) { + && !ndctl_dax_has_align(dax)) { /* * Unlike the pfn case, we require the kernel to * have 'align' support for device-dax. @@ -705,31 +721,6 @@ 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; - } - } - - /* 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; return 0;