diff mbox

ndctl: fix btt visibility in ndctl_namespace_enable()

Message ID 20150910200601.22817.65746.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit b4bc5b3fdb70
Headers show

Commit Message

Dan Williams Sept. 10, 2015, 8:06 p.m. UTC
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 <nicholas.w.moulin@intel.com>
Tested-by: Nicholas Moulin <nicholas.w.moulin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 lib/libndctl.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
diff mbox

Patch

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;
 }