From patchwork Wed Sep 20 00:48:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9960561 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 435B6601E9 for ; Wed, 20 Sep 2017 00:55:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 341F128ECB for ; Wed, 20 Sep 2017 00:55:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27D0628F1B; Wed, 20 Sep 2017 00:55:25 +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.9 required=2.0 tests=BAYES_00, 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 8D7D028ECB for ; Wed, 20 Sep 2017 00:55:24 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8FDFC21E945FD; Tue, 19 Sep 2017 17:52:18 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 2165920945B80 for ; Tue, 19 Sep 2017 17:52:17 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Sep 2017 17:55:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,419,1500966000"; d="scan'208";a="902037779" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.125]) by FMSMGA003.fm.intel.com with ESMTP; 19 Sep 2017 17:55:21 -0700 Subject: [ndctl PATCH] ndctl, namespace: fix sector size default when switch modes From: Dan Williams To: linux-nvdimm@lists.01.org Date: Tue, 19 Sep 2017 17:48:57 -0700 Message-ID: <150586853757.32311.8714053831475428757.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 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 Maurice reports: I do have a question about specific behavior I observed. Before I was able to configure an NVDIMM into any mode from any mode. With these patchs if I go to sector mode and try going to memory or dax mode it fails with: # ndctl create-namespace -f -e namespace0.0 -m memory Error: namespace0.0: sector_size: 4096 not supported failed to reconfigure namespace: Invalid argument This results from the fact that we pick up the default sector size from the current btt. However, if the next mode is not btt we should fall back to the native sector size of the namespace. Validate this conversion with an extension to the 'sector-mode.sh' test. Fixes: 61e82a3d7bc8 ("ndctl, create-namespace: support sector size...") Reported-by: Maurice A. Saldivar Signed-off-by: Dan Williams --- ndctl/namespace.c | 7 ++++++- test/sector-mode.sh | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index 905ebadc6b8d..d26ed1289c33 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -653,7 +653,12 @@ static int validate_namespace_options(struct ndctl_region *region, } else if (ndns) { struct ndctl_btt *btt = ndctl_namespace_get_btt(ndns); - if (btt) + /* + * If the target mode is still 'safe' carry forward the + * sector size, otherwise fall back to what the + * namespace supports. + */ + if (btt && p->mode == NDCTL_NS_MODE_SAFE) p->sector_size = ndctl_btt_get_sector_size(btt); else p->sector_size = ndctl_namespace_get_sector_size(ndns); diff --git a/test/sector-mode.sh b/test/sector-mode.sh index 75bd3c1f82bb..ee364ebad62b 100755 --- a/test/sector-mode.sh +++ b/test/sector-mode.sh @@ -45,6 +45,8 @@ NAMESPACE=$($NDCTL list $BUS1 -N | jq -r "$query") REGION=$($NDCTL list -R --namespace=$NAMESPACE | jq -r ".dev") echo 0 > /sys/bus/nd/devices/$REGION/read_only $NDCTL create-namespace -e $NAMESPACE -m sector -f -l 4K +$NDCTL create-namespace -e $NAMESPACE -m dax -f -a 4K +$NDCTL create-namespace -e $NAMESPACE -m sector -f -l 4K $NDCTL disable-region $BUS all $NDCTL disable-region $BUS1 all