From patchwork Sat Jul 27 21:41:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 11062735 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 8B0BC1399 for ; Sat, 27 Jul 2019 21:55:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 751A6209CE for ; Sat, 27 Jul 2019 21:55:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65FEE22B27; Sat, 27 Jul 2019 21:55:37 +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.9 required=2.0 tests=BAYES_00,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 198DE209CE for ; Sat, 27 Jul 2019 21:55:37 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A5137212E46E0; Sat, 27 Jul 2019 14:58:03 -0700 (PDT) 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=192.55.52.151; helo=mga17.intel.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 95370212E259E for ; Sat, 27 Jul 2019 14:58:02 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jul 2019 14:55:35 -0700 X-IronPort-AV: E=Sophos;i="5.64,315,1559545200"; d="scan'208";a="182272570" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jul 2019 14:55:35 -0700 Subject: [ndctl PATCH v2 22/26] ndctl/namespace: Clarify 16M minimum size requirement From: Dan Williams To: linux-nvdimm@lists.01.org Date: Sat, 27 Jul 2019 14:41:18 -0700 Message-ID: <156426367840.531577.5216422482939398348.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <156426356088.531577.14828880045306313118.stgit@dwillia2-desk3.amr.corp.intel.com> References: <156426356088.531577.14828880045306313118.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f 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 The kernel enforces a minimum size for any "claimed" namespace i.e. any namespace that is wrapped in an address abstraction like the btt or devdax. The "no such device or address" default print is confusing, so replace with an explicit error message. Reported-by: Jane Chu Signed-off-by: Dan Williams --- ndctl/namespace.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index 69900c4e4e60..75ea366574f8 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -534,6 +534,7 @@ static int validate_namespace_options(struct ndctl_region *region, unsigned long long size_align, units = 1, resource; struct ndctl_pfn *pfn = NULL; struct ndctl_dax *dax = NULL; + bool default_size = false; unsigned int ways; int rc = 0; @@ -548,10 +549,13 @@ static int validate_namespace_options(struct ndctl_region *region, p->size = __parse_size64(param.size, &units); else if (ndns) p->size = ndctl_namespace_get_size(ndns); + else + default_size = true; /* * Validate available capacity in the create case, in the - * reconfigure case the capacity is already allocated. + * reconfigure case the capacity is already allocated. A default + * size will be established from available capacity. */ if (!ndns) { rc = validate_available_capacity(region, p); @@ -719,6 +723,21 @@ static int validate_namespace_options(struct ndctl_region *region, return -EINVAL; } + /* + * Catch attempts to create sub-16M namespaces to match the + * kernel's restriction (see nd_namespace_store()) + */ + if (p->size < SZ_16M && p->mode != NDCTL_NS_MODE_RAW) { + if (default_size) { + debug("%s: insufficient capacity for mode: %s\n", + region_name, util_nsmode_name(p->mode)); + return -EAGAIN; + } + error("'--size=' must be >= 16MiB for '%s' mode\n", + util_nsmode_name(p->mode)); + return -EINVAL; + } + if (param.sector_size) { struct ndctl_btt *btt; int num, i;