From patchwork Thu Sep 10 20:06:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 7155791 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 0C8B39F326 for ; Thu, 10 Sep 2015 20:11:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3BF3C2073F for ; Thu, 10 Sep 2015 20:11:56 +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 60A11207B0 for ; Thu, 10 Sep 2015 20:11:55 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1ED421834EE; Thu, 10 Sep 2015 13:11:55 -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]) by ml01.01.org (Postfix) with ESMTP id BBBB21834ED for ; Thu, 10 Sep 2015 13:11:53 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 10 Sep 2015 13:11:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,506,1437462000"; d="scan'208";a="786905868" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.137]) by fmsmga001.fm.intel.com with ESMTP; 10 Sep 2015 13:11:51 -0700 Subject: [PATCH] ndctl: fix btt visibility in ndctl_namespace_enable() From: Dan Williams To: linux-nvdimm@lists.01.org Date: Thu, 10 Sep 2015 16:06:09 -0400 Message-ID: <20150910200601.22817.65746.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-8-g92dd MIME-Version: 1.0 Cc: Nicholas Moulin X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_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 We were refreshing the btt list at the end of ndctl_namespace_enable(), but that's too late for the call to ndctl_namespace_get_btt() that is used to determine whether the namespace was claimed by a btt. Move the call to region_refresh_children() earlier in the routine. Reported-by: Nicholas Moulin Tested-by: Nicholas Moulin Signed-off-by: Dan Williams --- lib/libndctl.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/libndctl.c b/lib/libndctl.c index 0e0d935e89fa..50cfbf7fe176 100644 --- a/lib/libndctl.c +++ b/lib/libndctl.c @@ -3146,14 +3146,19 @@ NDCTL_EXPORT int ndctl_namespace_enable(struct ndctl_namespace *ndns) rc = ndctl_bind(ctx, ndns->module, devname); + /* + * Rescan now as successfully enabling a namespace device leads + * to a new one being created, and potentially btts being attached + */ + region_refresh_children(region); + if (!ndctl_namespace_is_enabled(ndns)) { struct ndctl_btt *btt = ndctl_namespace_get_btt(ndns); if (btt && ndctl_btt_is_enabled(btt)) { dbg(ctx, "%s: enabled via %s\n", devname, ndctl_btt_get_devname(btt)); - rc = 1; - goto out; + return 1; } err(ctx, "%s: failed to enable\n", devname); return rc ? rc : -ENXIO; @@ -3161,12 +3166,6 @@ NDCTL_EXPORT int ndctl_namespace_enable(struct ndctl_namespace *ndns) rc = 0; dbg(ctx, "%s: enabled\n", devname); - /* - * Rescan now as successfully enabling a namespace device leads - * to a new one being created, and potentially btts being attached - */ - out: - region_refresh_children(region); return rc; }