Blame SOURCES/fe831b5-Use-page-size-as-alignment-value.patch

f9a104
Use page size as alignment value
f9a104
f9a104
BZ: 
f9a104
Brew: 
f9a104
f9a104
commit fe831b526b88f6ca7a27fdb149b8a7d2ecddbc55
f9a104
Author: Santosh Sivaraj <santosh@fossix.org>
f9a104
Date:   Thu May 13 11:42:18 2021 +0530
f9a104
f9a104
    Use page size as alignment value
f9a104
    
f9a104
    The alignment sizes passed to ndctl in the tests are all hardcoded to 4k,
f9a104
    the default page size on x86. Change those to the default page size on that
f9a104
    architecture (sysconf/getconf). No functional changes otherwise.
f9a104
    
f9a104
    Link: https://lore.kernel.org/r/20210513061218.760322-4-santosh@fossix.org
f9a104
    Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
f9a104
    Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
f9a104
f9a104
diff -up ndctl-71.1/test/dpa-alloc.c.orig ndctl-71.1/test/dpa-alloc.c
f9a104
--- ndctl-71.1/test/dpa-alloc.c.orig	2020-12-22 16:44:57.000000000 -0500
f9a104
+++ ndctl-71.1/test/dpa-alloc.c	2022-06-06 17:13:12.045108349 -0400
f9a104
@@ -38,12 +38,13 @@ static int do_test(struct ndctl_ctx *ctx
f9a104
 	struct ndctl_region *region, *blk_region = NULL;
f9a104
 	struct ndctl_namespace *ndns;
f9a104
 	struct ndctl_dimm *dimm;
f9a104
-	unsigned long size;
f9a104
+	unsigned long size, page_size;
f9a104
 	struct ndctl_bus *bus;
f9a104
 	char uuid_str[40];
f9a104
 	int round;
f9a104
 	int rc;
f9a104
 
f9a104
+	page_size = sysconf(_SC_PAGESIZE);
f9a104
 	/* disable nfit_test.1, not used in this test */
f9a104
 	bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER1);
f9a104
 	if (!bus)
f9a104
@@ -124,11 +125,11 @@ static int do_test(struct ndctl_ctx *ctx
f9a104
 			return rc;
f9a104
 		}
f9a104
 		ndctl_namespace_disable_invalidate(ndns);
f9a104
-		rc = ndctl_namespace_set_size(ndns, SZ_4K);
f9a104
+		rc = ndctl_namespace_set_size(ndns, page_size);
f9a104
 		if (rc) {
f9a104
-			fprintf(stderr, "failed to init %s to size: %d\n",
f9a104
+			fprintf(stderr, "failed to init %s to size: %lu\n",
f9a104
 					ndctl_namespace_get_devname(ndns),
f9a104
-					SZ_4K);
f9a104
+					page_size);
f9a104
 			return rc;
f9a104
 		}
f9a104
 		namespaces[i].ndns = ndns;
f9a104
@@ -150,7 +151,7 @@ static int do_test(struct ndctl_ctx *ctx
f9a104
 		ndns = namespaces[i % ARRAY_SIZE(namespaces)].ndns;
f9a104
 		if (i % ARRAY_SIZE(namespaces) == 0)
f9a104
 			round++;
f9a104
-		size = SZ_4K * round;
f9a104
+		size = page_size * round;
f9a104
 		rc = ndctl_namespace_set_size(ndns, size);
f9a104
 		if (rc) {
f9a104
 			fprintf(stderr, "%s: set_size: %lx failed: %d\n",
f9a104
@@ -166,7 +167,7 @@ static int do_test(struct ndctl_ctx *ctx
f9a104
 	i--;
f9a104
 	round++;
f9a104
 	ndns = namespaces[i % ARRAY_SIZE(namespaces)].ndns;
f9a104
-	size = SZ_4K * round;
f9a104
+	size = page_size * round;
f9a104
 	rc = ndctl_namespace_set_size(ndns, size);
f9a104
 	if (rc) {
f9a104
 		fprintf(stderr, "%s failed to update while labels full\n",
f9a104
@@ -175,7 +176,7 @@ static int do_test(struct ndctl_ctx *ctx
f9a104
 	}
f9a104
 
f9a104
 	round--;
f9a104
-	size = SZ_4K * round;
f9a104
+	size = page_size * round;
f9a104
 	rc = ndctl_namespace_set_size(ndns, size);
f9a104
 	if (rc) {
f9a104
 		fprintf(stderr, "%s failed to reduce size while labels full\n",
f9a104
diff -up ndctl-71.1/test/multi-dax.sh.orig ndctl-71.1/test/multi-dax.sh
f9a104
--- ndctl-71.1/test/multi-dax.sh.orig	2020-12-22 16:44:57.000000000 -0500
f9a104
+++ ndctl-71.1/test/multi-dax.sh	2022-06-06 17:13:12.046108353 -0400
f9a104
@@ -12,6 +12,8 @@ check_min_kver "4.13" || do_skip "may la
f9a104
 
f9a104
 trap 'err $LINENO' ERR
f9a104
 
f9a104
+ALIGN_SIZE=`getconf PAGESIZE`
f9a104
+
f9a104
 # setup (reset nfit_test dimms)
f9a104
 modprobe nfit_test
f9a104
 $NDCTL disable-region -b $NFIT_TEST_BUS0 all
f9a104
@@ -22,9 +24,9 @@ rc=1
f9a104
 query=". | sort_by(.available_size) | reverse | .[0].dev"
f9a104
 region=$($NDCTL list -b $NFIT_TEST_BUS0 -t pmem -Ri | jq -r "$query")
f9a104
 
f9a104
-json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a 4096 -s 16M)
f9a104
+json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a $ALIGN_SIZE -s 16M)
f9a104
 chardev1=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[0].chardev")
f9a104
-json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a 4096 -s 16M)
f9a104
+json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a $ALIGN_SIZE -s 16M)
f9a104
 chardev2=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[0].chardev")
f9a104
 
f9a104
 _cleanup
f9a104
diff -up ndctl-71.1/test/sector-mode.sh.orig ndctl-71.1/test/sector-mode.sh
f9a104
--- ndctl-71.1/test/sector-mode.sh.orig	2020-12-22 16:44:57.000000000 -0500
f9a104
+++ ndctl-71.1/test/sector-mode.sh	2022-06-06 17:13:12.046108353 -0400
f9a104
@@ -9,6 +9,8 @@ rc=77
f9a104
 set -e
f9a104
 trap 'err $LINENO' ERR
f9a104
 
f9a104
+ALIGN_SIZE=`getconf PAGESIZE`
f9a104
+
f9a104
 # setup (reset nfit_test dimms)
f9a104
 modprobe nfit_test
f9a104
 $NDCTL disable-region -b $NFIT_TEST_BUS0 all
f9a104
@@ -25,7 +27,7 @@ NAMESPACE=$($NDCTL list -b $NFIT_TEST_BU
f9a104
 REGION=$($NDCTL list -R --namespace=$NAMESPACE | jq -r "(.[]) | .dev")
f9a104
 echo 0 > /sys/bus/nd/devices/$REGION/read_only
f9a104
 $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K
f9a104
-$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m dax -f -a 4K
f9a104
+$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m dax -f -a $ALIGN_SIZE
f9a104
 $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K
f9a104
 
f9a104
 _cleanup