File ndctl-Use-the-same-align-value-as-original-namespace-on-reconfigure.patch of Package ndctl

From e81ccd7f062beeae7498d04785fe55c55c857d4b Mon Sep 17 00:00:00 2001
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Date: Wed, 7 Aug 2019 10:14:16 +0530
Subject: [PATCH] ndctl: Reuse the align value from the original namespace on
 reconfiguration

Patch-mainline: v67
Git-commit: e81ccd7f062beeae7498d04785fe55c55c857d4b

When using reconfigure command to add a 'name' to the namespace we end
up updating the align attribute. Avoid this by using the value from
the original namespace. Do this only if we are keeping the namespace mode
same.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 ndctl/namespace.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index 67768f34365c..7fb00078646b 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -598,6 +598,22 @@ static int validate_namespace_options(struct ndctl_region *region,
 			return -ENXIO;
 		}
 	} else {
+		/*
+		 * If we are trying to reconfigure with the same namespace mode,
+		 * use the align details from the original namespace. Otherwise
+		 * pick the align details from seed namespace
+		 */
+		if (ndns && p->mode == ndctl_namespace_get_mode(ndns)) {
+			struct ndctl_pfn *ns_pfn = ndctl_namespace_get_pfn(ndns);
+			struct ndctl_dax *ns_dax = ndctl_namespace_get_dax(ndns);
+
+			if (ns_pfn)
+				p->align = ndctl_pfn_get_align(ns_pfn);
+			else if (ns_dax)
+				p->align = ndctl_dax_get_align(ns_dax);
+			else
+				p->align = sysconf(_SC_PAGE_SIZE);
+		} else
 		/*
 		 * Use the seed namespace alignment as the default if we need
 		 * one. If we don't then use PAGE_SIZE so the size_align
-- 
2.23.0