From patchwork Tue Sep 19 19:56:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9960109 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 A34726038F for ; Tue, 19 Sep 2017 20:03:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FCD228E0F for ; Tue, 19 Sep 2017 20:03:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83AA528E1E; Tue, 19 Sep 2017 20:03:05 +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 11EBD28E0F for ; Tue, 19 Sep 2017 20:03:04 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 605CC21E2BE3E; Tue, 19 Sep 2017 12:59:59 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 E3DA021CEB108 for ; Tue, 19 Sep 2017 12:59:57 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Sep 2017 13:03:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,418,1500966000"; d="scan'208";a="901968811" 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 13:03:02 -0700 Subject: [ndctl PATCH 1/2] ndctl: fix sector size manipulation for NVDIMM-N namespaces From: Dan Williams To: linux-nvdimm@lists.01.org Date: Tue, 19 Sep 2017 12:56:38 -0700 Message-ID: <150585099801.18300.4357728197672633739.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 The autolabel operation that enables sector_size settings for namespaces will fail on label-less NVDIMMs. In that case we need to abort attempts to set the sector_size. Typically when specifying a sector_size we are also specifying 'sector' mode so the failure to set a sector_size at the raw namespace level can be ignored. Reported-by: Maurice A. Saldivar Signed-off-by: Dan Williams --- ndctl/namespace.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index bbd404f4abcf..905ebadc6b8d 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -354,8 +354,30 @@ static int setup_namespace(struct ndctl_region *region, try(ndctl_namespace, set_size, ndns, p->size); } - if (p->sector_size && p->sector_size < UINT_MAX) - try(ndctl_namespace, set_sector_size, ndns, p->sector_size); + if (p->sector_size && p->sector_size < UINT_MAX) { + int i, num = ndctl_namespace_get_num_sector_sizes(ndns); + + /* + * With autolabel support we need to recheck if the + * namespace gained sector_size support late in + * namespace_reconfig(). + */ + for (i = 0; i < num; i++) + if (ndctl_namespace_get_supported_sector_size(ndns, i) + == p->sector_size) + break; + if (i < num) + try(ndctl_namespace, set_sector_size, ndns, + p->sector_size); + else if (p->mode == NDCTL_NS_MODE_SAFE) + /* pass, the btt sector_size will override */; + else if (p->sector_size != 512) { + error("%s: sector_size: %ld not supported\n", + ndctl_namespace_get_devname(ndns), + p->sector_size); + return -EINVAL; + } + } uuid_generate(uuid);