Blame SOURCES/0169-namespace-action-Drop-more-zero-namespace-checks.patch

e0018b
From 2f3851912624e9ede3132cd3749b4f60a348b1d4 Mon Sep 17 00:00:00 2001
e0018b
From: Michal Suchanek <msuchanek@suse.de>
e0018b
Date: Thu, 10 Mar 2022 14:31:06 +0100
e0018b
Subject: [PATCH 169/217] namespace-action: Drop more zero namespace checks
e0018b
e0018b
With seed namespaces caught early on with
e0018b
commit 9bd2994 ("ndctl/namespace: Skip seed namespaces when processing all namespaces.")
e0018b
commit 07011a3 ("ndctl/namespace: Suppress -ENXIO when processing all namespaces.")
e0018b
the function-specific checks are no longer needed and can be dropped.
e0018b
e0018b
Reverts commit fb13dfb ("zero_info_block: skip seed devices")
e0018b
Reverts commit fe626a8 ("ndctl/namespace: Fix disable-namespace accounting relative to seed devices")
e0018b
e0018b
Link: https://lore.kernel.org/r/20220310133106.GA106734@kunlun.suse.cz
e0018b
Fixes: 80e0d88 ("namespace-action: Drop zero namespace checks.")
e0018b
Fixes: fb13dfb ("zero_info_block: skip seed devices")
e0018b
Fixes: fe626a8 ("ndctl/namespace: Fix disable-namespace accounting relative to seed devices")
e0018b
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
e0018b
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
e0018b
---
e0018b
 ndctl/lib/libndctl.c |  7 +------
e0018b
 ndctl/namespace.c    | 11 ++++-------
e0018b
 ndctl/region.c       |  2 +-
e0018b
 3 files changed, 6 insertions(+), 14 deletions(-)
e0018b
e0018b
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
e0018b
index ccca8b5..110d8a5 100644
e0018b
--- a/ndctl/lib/libndctl.c
e0018b
+++ b/ndctl/lib/libndctl.c
e0018b
@@ -4593,7 +4593,6 @@ NDCTL_EXPORT int ndctl_namespace_disable_safe(struct ndctl_namespace *ndns)
e0018b
 	const char *bdev = NULL;
e0018b
 	int fd, active = 0;
e0018b
 	char path[50];
e0018b
-	unsigned long long size = ndctl_namespace_get_size(ndns);
e0018b
 
e0018b
 	if (pfn && ndctl_pfn_is_enabled(pfn))
e0018b
 		bdev = ndctl_pfn_get_block_device(pfn);
e0018b
@@ -4630,11 +4629,7 @@ NDCTL_EXPORT int ndctl_namespace_disable_safe(struct ndctl_namespace *ndns)
e0018b
 				devname);
e0018b
 		return -EBUSY;
e0018b
 	} else {
e0018b
-		if (size == 0)
e0018b
-			/* No disable necessary due to no capacity allocated */
e0018b
-			return 1;
e0018b
-		else
e0018b
-			ndctl_namespace_disable_invalidate(ndns);
e0018b
+		ndctl_namespace_disable_invalidate(ndns);
e0018b
 	}
e0018b
 
e0018b
 	return 0;
e0018b
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
e0018b
index 257b58c..722f13a 100644
e0018b
--- a/ndctl/namespace.c
e0018b
+++ b/ndctl/namespace.c
e0018b
@@ -1054,9 +1054,6 @@ static int zero_info_block(struct ndctl_namespace *ndns)
e0018b
 	void *buf = NULL, *read_buf = NULL;
e0018b
 	char path[50];
e0018b
 
e0018b
-	if (ndctl_namespace_get_size(ndns) == 0)
e0018b
-		return 1;
e0018b
-
e0018b
 	ndctl_namespace_set_raw_mode(ndns, 1);
e0018b
 	rc = ndctl_namespace_enable(ndns);
e0018b
 	if (rc < 0) {
e0018b
@@ -1130,7 +1127,7 @@ static int namespace_prep_reconfig(struct ndctl_region *region,
e0018b
 	}
e0018b
 
e0018b
 	rc = ndctl_namespace_disable_safe(ndns);
e0018b
-	if (rc < 0)
e0018b
+	if (rc)
e0018b
 		return rc;
e0018b
 
e0018b
 	ndctl_namespace_set_enforce_mode(ndns, NDCTL_NS_MODE_RAW);
e0018b
@@ -1426,7 +1423,7 @@ static int dax_clear_badblocks(struct ndctl_dax *dax)
e0018b
 		return -ENXIO;
e0018b
 
e0018b
 	rc = ndctl_namespace_disable_safe(ndns);
e0018b
-	if (rc < 0) {
e0018b
+	if (rc) {
e0018b
 		error("%s: unable to disable namespace: %s\n", devname,
e0018b
 			strerror(-rc));
e0018b
 		return rc;
e0018b
@@ -1450,7 +1447,7 @@ static int pfn_clear_badblocks(struct ndctl_pfn *pfn)
e0018b
 		return -ENXIO;
e0018b
 
e0018b
 	rc = ndctl_namespace_disable_safe(ndns);
e0018b
-	if (rc < 0) {
e0018b
+	if (rc) {
e0018b
 		error("%s: unable to disable namespace: %s\n", devname,
e0018b
 			strerror(-rc));
e0018b
 		return rc;
e0018b
@@ -1473,7 +1470,7 @@ static int raw_clear_badblocks(struct ndctl_namespace *ndns)
e0018b
 		return -ENXIO;
e0018b
 
e0018b
 	rc = ndctl_namespace_disable_safe(ndns);
e0018b
-	if (rc < 0) {
e0018b
+	if (rc) {
e0018b
 		error("%s: unable to disable namespace: %s\n", devname,
e0018b
 			strerror(-rc));
e0018b
 		return rc;
e0018b
diff --git a/ndctl/region.c b/ndctl/region.c
e0018b
index e499546..33828b0 100644
e0018b
--- a/ndctl/region.c
e0018b
+++ b/ndctl/region.c
e0018b
@@ -71,7 +71,7 @@ static int region_action(struct ndctl_region *region, enum device_action mode)
e0018b
 	case ACTION_DISABLE:
e0018b
 		ndctl_namespace_foreach(region, ndns) {
e0018b
 			rc = ndctl_namespace_disable_safe(ndns);
e0018b
-			if (rc < 0)
e0018b
+			if (rc)
e0018b
 				return rc;
e0018b
 		}
e0018b
 		rc = ndctl_region_disable_invalidate(region);
e0018b
-- 
e0018b
2.27.0
e0018b