From patchwork Thu Aug 4 17:59:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9264035 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 81EC66048B for ; Thu, 4 Aug 2016 17:59:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C9C027F0B for ; Thu, 4 Aug 2016 17:59:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E01528426; Thu, 4 Aug 2016 17:59:54 +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=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no 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 E361827F0B for ; Thu, 4 Aug 2016 17:59:53 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4CF311A1DF5; Thu, 4 Aug 2016 10:59:53 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mail-oi0-x22c.google.com (mail-oi0-x22c.google.com [IPv6:2607:f8b0:4003:c06::22c]) (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 F277A1A1DF5 for ; Thu, 4 Aug 2016 10:59:51 -0700 (PDT) Received: by mail-oi0-x22c.google.com with SMTP id k131so24218829oib.1 for ; Thu, 04 Aug 2016 10:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=ppLOs1mcCod/Iybc/hlgFq2rmIYhVzT0hUArBCT+QqA=; b=Fs0hKb4JygL2uilEisT/+4y64Fiazok/P7q7ZyobVoCBvTHPW5gtWL5v23DiPIgu/R uuoBFiExFw64qhDeVcE6Gbyv+khBOsQypjzumLutRFs3oTosawtIHYs7LngBRU69wOLq wsg0HMrAiQUxatOjTL4EEcabCA4w2/PCIIHihwd0uYIW9M7te/ZBjk+7JGgSedg9mbAz oXLxLXplewNWQCFXYew6uUPyQSlHM05/bJiGzweANjMCm/qjMZrE5Dp0U1KheAW5kbTh bg0EplhxGv7vpI6xK4XTpK1Kcah1toRMPPViq8+DvsqkEBaHyH5jkCYJa83Q04bDOz+t XNYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=ppLOs1mcCod/Iybc/hlgFq2rmIYhVzT0hUArBCT+QqA=; b=eqHN+JjpYYCz7GOKxRHwSe5l/L8rEIcii+xQeNISB9rK0akCjaHKcRLIZPEacjoERV HNZwhg2NotIpFmXizgkxvrLg0Tr12YdQCbhvKi+e8jMqiNMhNfQsEl7LJ5Pg9EeASDCS /nSklRkbYsfAEvX+QspMW1QMhowJn8MunFxongMoMU92qxThzAOwjeia1m/Hi8txBCBp e1zsHJryXPMQJ2EH75bX6MPEYUnoevZYTIlEkQQ80jL7Yt55HQWLFx8PkJZdBAxs8H6p TMSYXIQwpifcQ6ITpJNFWBJC2g7ybpriJ0kWKZvUDCP/rrs7gUkrGehWgMOJCjEjP0i6 eWgw== X-Gm-Message-State: AEkoouss372YsxPlp67cW5bJsDGd0htRKlhEQCjMbw2kvxfNOnI29SmjDiANGQxxvE0DxYR4Pb58eb0tfZxpAE6E X-Received: by 10.202.180.9 with SMTP id d9mr45681033oif.49.1470333590893; Thu, 04 Aug 2016 10:59:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.62.182 with HTTP; Thu, 4 Aug 2016 10:59:50 -0700 (PDT) In-Reply-To: <147032474225.32368.15775067933518377793.stgit@dwillia2-desk3.amr.corp.intel.com> References: <147032474225.32368.15775067933518377793.stgit@dwillia2-desk3.amr.corp.intel.com> From: Dan Williams Date: Thu, 4 Aug 2016 10:59:50 -0700 Message-ID: Subject: Re: [ndctl PATCH] ndctl, create-namespace: trap and report invalid sector-size values To: "linux-nvdimm@lists.01.org" X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 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 On Thu, Aug 4, 2016 at 8:32 AM, Dan Williams wrote: > While the kernel will prevent invalid configurations, the user > experience of a kernel error message and disabling of the namespace is > too harsh. Trap and report these attempts to make create-namespace more > user friendly. > > # ndctl create-namespace -e namespace0.0 -m sector -l 513 -f -v > validate_namespace_options:437: region0: does not support btt sector_size 513 > failed to reconfigure namespace > > Reported-by: Yi Zhang > Signed-off-by: Dan Williams > --- > ndctl/builtin-xaction-namespace.c | 40 +++++++++++++++++++++++++++++++------ > 1 file changed, 34 insertions(+), 6 deletions(-) Unit tests say we also need the following so that we don't try to set a sector size on pmem namespaces. } diff --git a/ndctl/builtin-xaction-namespace.c b/ndctl/builtin-xaction-namespace.c index e136bfdefa39..35345fb26ec3 100644 --- a/ndctl/builtin-xaction-namespace.c +++ b/ndctl/builtin-xaction-namespace.c @@ -210,8 +210,13 @@ static int set_defaults(enum namespace_action mode) error("'pmem' namespaces do not support setting 'sector size'\n"); rc = -EINVAL; } - } else if (!param.reconfig) - param.sector_size = "4096"; + } else if (!param.reconfig + && (param.type && strcmp(param.type, "blk") == 0 + || (param.mode + && strcmp(param.mode, "safe") == 0))) { + /* default sector size for blk-type or safe-mode */ + param.sector_size = "4096"; + } return rc;