From patchwork Wed Jan 30 10:59:22 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: 10788265 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 D8C561874 for ; Wed, 30 Jan 2019 10:59:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1A442E395 for ; Wed, 30 Jan 2019 10:59:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B433C2E3EF; Wed, 30 Jan 2019 10:59:43 +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 5C6F02E3BB for ; Wed, 30 Jan 2019 10:59:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 526FC211BFCD0; Wed, 30 Jan 2019 02:59:43 -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 95681211BFCC4 for ; Wed, 30 Jan 2019 02:59:42 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id z23so10905039plo.0 for ; Wed, 30 Jan 2019 02:59:42 -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=PaW1+WdbU1RRFdw7IyOK2Nl+27lOYMrTEaMsCjdcbrg7teN0ztZ8J/qInCehM82wQu jc4nOipbXCPbvHXdE4P+kVV0GA5jlr+Zg3Xu5gNs8aq2lJs10BTUM62jEMlJ8lfUk0A3 DUfHO0wmgVpO/MkipimHP4rz2j0Qc+g/0wC1DTk8Q1pHcxTwp32p9/CTMKD1PWGN5Smk rfdEFljXa8YdHsKxJ99VATH0PbbNTz5oH8jR4abTfrYPQmg5M7mNk8+uSp5zL4A8oFKV BWFNcS4Hy2D6jV5f5Cb6BiU123Q8OVujvnRIyESEIhq9vBnIVSgbSXKmo05AYg4EoYeG oyRg== 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=fvCBVxHHQcBLY5fmLrNWh9JFiZtzNSCjZWXWFmlQhjfQkjpWUHmoS0VKgCNTkbc7I6 DDA/DGGVfcselTHlKs9uV36ewl5N5LrIQB+cLxL5w5J4YU9Fta2YruDs08kX55o1Dj+Y KEcqjdnKnPtAtESqK6wfxz6eJ7yOAw2/XNgGo76gw45sHmUn1iHWBFNVrGvlAxFi44Xw ydHUeOr6OH188Xigia881/t4OUPHr6v60GIOatFh6AXuS+nG7NEXYMk3WsntmSe4Osrg bLmhBys+Hg1RtvfHpmMtNy/xXPWVlpHU1K+oEvM1K1YlGJ2nFbkR87M/IUF5yPG/AewW 0I2A== X-Gm-Message-State: AJcUukfj1JZAFDpdhAGMslHSvId6H87dJ0CafHcP4HjGaYLNfrROGr2l KoO1QSdIv+/7YA0lvVmpN+ZSbxHY X-Google-Smtp-Source: ALg8bN7xXmjtjgCfVJtUrZ1SeSaB3Y4EKalh5mudV4SidBt7zq+C5u1CCocwb8Rr6vvoEmN4KVHpgA== X-Received: by 2002:a17:902:32c3:: with SMTP id z61mr29811449plb.114.1548845981977; Wed, 30 Jan 2019 02:59:41 -0800 (PST) Received: from wafer.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id r1sm3547452pgo.17.2019.01.30.02.59.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Jan 2019 02:59:41 -0800 (PST) From: Oliver O'Halloran To: linux-nvdimm@lists.01.org Subject: [PATCH v5 2/7] ndctl/namespace: Check for seed namespaces earlier Date: Wed, 30 Jan 2019 21:59:22 +1100 Message-Id: <20190130105927.31901-2-oohall@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190130105927.31901-1-oohall@gmail.com> References: <20190130105927.31901-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;