From patchwork Tue Jul 28 03:14:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 6879171 X-Patchwork-Delegate: vishal.l.verma@intel.com 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 D974A9F380 for ; Tue, 28 Jul 2015 03:20:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 200AA206B8 for ; Tue, 28 Jul 2015 03:20:25 +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 50614206AC for ; Tue, 28 Jul 2015 03:20:24 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 44A8218283A; Mon, 27 Jul 2015 20:20:24 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ml01.01.org (Postfix) with ESMTP id 4721018280E for ; Mon, 27 Jul 2015 20:20:23 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 27 Jul 2015 20:20:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,560,1432623600"; d="scan'208";a="772504548" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.11]) by orsmga002.jf.intel.com with ESMTP; 27 Jul 2015 20:20:23 -0700 Subject: [ndctl PATCH 3/3] ndctl: refresh namespaces after btt enable From: Dan Williams To: linux-nvdimm@lists.01.org Date: Mon, 27 Jul 2015 23:14:41 -0400 Message-ID: <20150728031441.19103.75305.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <20150728030655.19103.47017.stgit@dwillia2-desk3.amr.corp.intel.com> References: <20150728030655.19103.47017.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-8-g92dd MIME-Version: 1.0 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=-3.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, 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 Enabling a btt instance may trigger the creation of a new namespace seed, so refresh the namespace list after an enable event. Unify this in a region_refresh_children() between ndctl_btt_enable() and ndctl_namespace_enable(). Signed-off-by: Dan Williams --- lib/libndctl.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/libndctl.c b/lib/libndctl.c index 6139af363b48..0b558df46893 100644 --- a/lib/libndctl.c +++ b/lib/libndctl.c @@ -3106,6 +3106,15 @@ static void btts_init(struct ndctl_region *region) device_parse(bus->ctx, bus, region->region_path, btt_fmt, region, add_btt); } +static void region_refresh_children(struct ndctl_region *region) +{ + region->namespaces_init = 0; + region->btts_init = 0; + namespaces_init(region); + btts_init(region); +} + + /* * Return 0 if enabled, < 0 if failed to enable, and > 0 if claimed by * another device and that device is enabled. In the > 0 case a @@ -3143,10 +3152,7 @@ NDCTL_EXPORT int ndctl_namespace_enable(struct ndctl_namespace *ndns) * to a new one being created, and potentially btts being attached */ out: - region->namespaces_init = 0; - region->btts_init = 0; - namespaces_init(region); - btts_init(region); + region_refresh_children(region); return rc; } @@ -3757,10 +3763,10 @@ NDCTL_EXPORT int ndctl_btt_enable(struct ndctl_btt *btt) /* * Rescan now as successfully enabling a btt device leads to a - * new one being created + * new one being created, and potentially the backing namespace + * as well. */ - region->btts_init = 0; - btts_init(region); + region_refresh_children(region); return 0; }