Skip to contentSkip to conversation

namespace-action: Don't act on any seed namespaces

PATCH Superseded Santosh Sivaraj 2 participants 2 messages Jul 5, 2020 – Jul 6, 2020 libnvdimm: non-volatile memory device

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 namespace-action: Don't act on any seed namespaces

Catch seed namespaces early on. This will prevent checking for sizes in enable, disable and destroy namespace code path, which in turn prevents the inconsistent reporting in count of enabled/disabled namespaces.

---
 ndctl/lib/libndctl.c |  5 -----
 ndctl/namespace.c    | 14 ++------------
 2 files changed, 2 insertions(+), 17 deletions(-)
ndctl/lib/libndctl.c +0 -5
index ee737cb..d0599f7 100644
@@ -4130,16 +4130,11 @@ NDCTL_EXPORT int ndctl_namespace_enable(struct ndctl_namespace *ndns)
 	const char *devname = ndctl_namespace_get_devname(ndns);
 	struct ndctl_ctx *ctx = ndctl_namespace_get_ctx(ndns);
 	struct ndctl_region *region = ndns->region;
-	unsigned long long size = ndctl_namespace_get_size(ndns);
 	int rc;
 
 	if (ndctl_namespace_is_enabled(ndns))
 		return 0;
 
-	/* Don't try to enable idle namespace (no capacity allocated) */
-	if (size == 0)
-		return -ENXIO;
-
 	rc = ndctl_bind(ctx, ndns->module, devname);
 
 	/*
ndctl/namespace.c +2 -12
index 0550580..5a086d0 100644
@@ -1102,7 +1102,6 @@ static int namespace_destroy(struct ndctl_region *region,
 		struct ndctl_namespace *ndns)
 {
 	const char *devname = ndctl_namespace_get_devname(ndns);
-	unsigned long long size;
 	bool did_zero = false;
 	int rc;
 
@@ -1147,19 +1146,9 @@ static int namespace_destroy(struct ndctl_region *region,
 		goto out;
 	}
 
-	size = ndctl_namespace_get_size(ndns);
-
 	rc = ndctl_namespace_delete(ndns);
 	if (rc)
 		debug("%s: failed to reclaim\n", devname);
-
-	/*
-	 * Don't report a destroyed namespace when no capacity was
-	 * allocated.
-	 */
-	if (size == 0 && rc == 0)
-		rc = 1;
-
 out:
 	return rc;
 }
@@ -2128,8 +2117,9 @@ static int do_xaction_namespace(const char *namespace,
 			ndctl_namespace_foreach_safe(region, ndns, _n) {
 				ndns_name = ndctl_namespace_get_devname(ndns);
 
-				if (strcmp(namespace, "all") != 0
+				if ((strcmp(namespace, "all") != 0
 						&& strcmp(namespace, ndns_name) != 0)
+				    || ndctl_namespace_get_size(ndns) == 0)
 					continue;
 				switch (action) {
 				case ACTION_DISABLE:
Signature · 4 lines
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Tested-by on v1 1/1
#1 lore raw

- Harish

Quoted 64 lines · Santosh Sivaraj

Catch seed namespaces early on. This will prevent checking for sizes in enable, disable and destroy namespace code path, which in turn prevents the inconsistent reporting in count of enabled/disabled namespaces.

---
  ndctl/lib/libndctl.c |  5 -----
  ndctl/namespace.c    | 14 ++------------
  2 files changed, 2 insertions(+), 17 deletions(-)
ndctl/lib/libndctl.c +0 -5
index ee737cb..d0599f7 100644
@@ -4130,16 +4130,11 @@ NDCTL_EXPORT int ndctl_namespace_enable(struct ndctl_namespace *ndns)
  	const char *devname = ndctl_namespace_get_devname(ndns);
  	struct ndctl_ctx *ctx = ndctl_namespace_get_ctx(ndns);
  	struct ndctl_region *region = ndns->region;
-	unsigned long long size = ndctl_namespace_get_size(ndns);
  	int rc;
 
  	if (ndctl_namespace_is_enabled(ndns))
  		return 0;
 
-	/* Don't try to enable idle namespace (no capacity allocated) */
-	if (size == 0)
-		return -ENXIO;
-
  	rc = ndctl_bind(ctx, ndns->module, devname);
 
  	/*
ndctl/namespace.c +0 -11
index 0550580..5a086d0 100644
@@ -1102,7 +1102,6 @@ static int namespace_destroy(struct ndctl_region *region,
  		struct ndctl_namespace *ndns)
  {
  	const char *devname = ndctl_namespace_get_devname(ndns);
-	unsigned long long size;
  	bool did_zero = false;
  	int rc;
 
@@ -1147,19 +1146,9 @@ static int namespace_destroy(struct ndctl_region *region,
  		goto out;
  	}
 
-	size = ndctl_namespace_get_size(ndns);
-
  	rc = ndctl_namespace_delete(ndns);
  	if (rc)
  		debug("%s: failed to reclaim\n", devname);
-
-	/*
-	 * Don't report a destroyed namespace when no capacity was
-	 * allocated.
-	 */
-	if (size == 0 && rc == 0)
-		rc = 1;
-
  out:
  	return rc;
  }

ndctl/namespace.c static int do_xaction_namespace(const char *namespace, · line 2125

Quoted 10 lines
ndctl/namespace.c +2 -1
@@ -2128,8 +2117,9 @@ static int do_xaction_namespace(const char *namespace,
  			ndctl_namespace_foreach_safe(region, ndns, _n) {
  				ndns_name = ndctl_namespace_get_devname(ndns);
 
-				if (strcmp(namespace, "all") != 0
+				if ((strcmp(namespace, "all") != 0
  						&& strcmp(namespace, ndns_name) != 0)
+				    || ndctl_namespace_get_size(ndns) == 0)
  					continue;
  				switch (action) {
  				case ACTION_DISABLE:

_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]