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;