From patchwork Fri Apr 22 19:47:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 8915351 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AC8C09F372 for ; Fri, 22 Apr 2016 19:47:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E728C2021B for ; Fri, 22 Apr 2016 19:47:58 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 2950E20212 for ; Fri, 22 Apr 2016 19:47:58 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 201381A20BA; Fri, 22 Apr 2016 12:47:58 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ml01.01.org (Postfix) with ESMTP id 1AF371A20D1 for ; Fri, 22 Apr 2016 12:47:57 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 22 Apr 2016 12:47:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,518,1455004800"; d="scan'208";a="964519476" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.14]) by fmsmga002.fm.intel.com with ESMTP; 22 Apr 2016 12:47:56 -0700 Subject: [ndctl PATCH 1/8] ndctl, create-namespace: make zero_info_block() more robust From: Dan Williams To: linux-nvdimm@lists.01.org Date: Fri, 22 Apr 2016 12:47:07 -0700 Message-ID: <146135442769.4228.5883488750920483205.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <146135442234.4228.904225076597683142.stgit@dwillia2-desk3.amr.corp.intel.com> References: <146135442234.4228.904225076597683142.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.20 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-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Arrange for zero_info_block() to continue in the case when the namespace cannot be enabled. This allows a partially configured namespace to be reset. Signed-off-by: Dan Williams --- builtin-xaction-namespace.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c index d83ad91a7258..3e13a1c0c3a1 100644 --- a/builtin-xaction-namespace.c +++ b/builtin-xaction-namespace.c @@ -463,12 +463,17 @@ static int zero_info_block(struct ndctl_namespace *ndns) char path[50]; void *buf; + ndctl_namespace_set_raw_mode(ndns, 1); + rc = ndctl_namespace_enable(ndns); + if (rc < 0) { + debug("%s failed to enable for zeroing, continuing\n", devname); + rc = 0; + goto out; + } + if (posix_memalign(&buf, 4096, 4096) != 0) return -ENXIO; - ndctl_namespace_set_raw_mode(ndns, 1); - ndctl_namespace_enable(ndns); - sprintf(path, "/dev/%s", ndctl_namespace_get_block_device(ndns)); fd = open(path, O_RDWR|O_DIRECT|O_EXCL); if (fd < 0) {