anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

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

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