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

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