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

e0018b
From fe831b526b88f6ca7a27fdb149b8a7d2ecddbc55 Mon Sep 17 00:00:00 2001
e0018b
From: Santosh Sivaraj <santosh@fossix.org>
e0018b
Date: Thu, 13 May 2021 11:42:18 +0530
e0018b
Subject: [PATCH 021/217] Use page size as alignment value
e0018b
e0018b
The alignment sizes passed to ndctl in the tests are all hardcoded to 4k,
e0018b
the default page size on x86. Change those to the default page size on that
e0018b
architecture (sysconf/getconf). No functional changes otherwise.
e0018b
e0018b
Link: https://lore.kernel.org/r/20210513061218.760322-4-santosh@fossix.org
e0018b
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
e0018b
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
e0018b
---
e0018b
 test/dpa-alloc.c    | 15 ++++++++-------
e0018b
 test/multi-dax.sh   |  6 ++++--
e0018b
 test/sector-mode.sh |  4 +++-
e0018b
 3 files changed, 15 insertions(+), 10 deletions(-)
e0018b
e0018b
diff --git a/test/dpa-alloc.c b/test/dpa-alloc.c
e0018b
index 0b3bb7a..59185cf 100644
e0018b
--- a/test/dpa-alloc.c
e0018b
+++ b/test/dpa-alloc.c
e0018b
@@ -38,12 +38,13 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test)
e0018b
 	struct ndctl_region *region, *blk_region = NULL;
e0018b
 	struct ndctl_namespace *ndns;
e0018b
 	struct ndctl_dimm *dimm;
e0018b
-	unsigned long size;
e0018b
+	unsigned long size, page_size;
e0018b
 	struct ndctl_bus *bus;
e0018b
 	char uuid_str[40];
e0018b
 	int round;
e0018b
 	int rc;
e0018b
 
e0018b
+	page_size = sysconf(_SC_PAGESIZE);
e0018b
 	/* disable nfit_test.1, not used in this test */
e0018b
 	bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER1);
e0018b
 	if (!bus)
e0018b
@@ -124,11 +125,11 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test)
e0018b
 			return rc;
e0018b
 		}
e0018b
 		ndctl_namespace_disable_invalidate(ndns);
e0018b
-		rc = ndctl_namespace_set_size(ndns, SZ_4K);
e0018b
+		rc = ndctl_namespace_set_size(ndns, page_size);
e0018b
 		if (rc) {
e0018b
-			fprintf(stderr, "failed to init %s to size: %d\n",
e0018b
+			fprintf(stderr, "failed to init %s to size: %lu\n",
e0018b
 					ndctl_namespace_get_devname(ndns),
e0018b
-					SZ_4K);
e0018b
+					page_size);
e0018b
 			return rc;
e0018b
 		}
e0018b
 		namespaces[i].ndns = ndns;
e0018b
@@ -150,7 +151,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test)
e0018b
 		ndns = namespaces[i % ARRAY_SIZE(namespaces)].ndns;
e0018b
 		if (i % ARRAY_SIZE(namespaces) == 0)
e0018b
 			round++;
e0018b
-		size = SZ_4K * round;
e0018b
+		size = page_size * round;
e0018b
 		rc = ndctl_namespace_set_size(ndns, size);
e0018b
 		if (rc) {
e0018b
 			fprintf(stderr, "%s: set_size: %lx failed: %d\n",
e0018b
@@ -166,7 +167,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test)
e0018b
 	i--;
e0018b
 	round++;
e0018b
 	ndns = namespaces[i % ARRAY_SIZE(namespaces)].ndns;
e0018b
-	size = SZ_4K * round;
e0018b
+	size = page_size * round;
e0018b
 	rc = ndctl_namespace_set_size(ndns, size);
e0018b
 	if (rc) {
e0018b
 		fprintf(stderr, "%s failed to update while labels full\n",
e0018b
@@ -175,7 +176,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test)
e0018b
 	}
e0018b
 
e0018b
 	round--;
e0018b
-	size = SZ_4K * round;
e0018b
+	size = page_size * round;
e0018b
 	rc = ndctl_namespace_set_size(ndns, size);
e0018b
 	if (rc) {
e0018b
 		fprintf(stderr, "%s failed to reduce size while labels full\n",
e0018b
diff --git a/test/multi-dax.sh b/test/multi-dax.sh
e0018b
index 8496619..b343a38 100755
e0018b
--- a/test/multi-dax.sh
e0018b
+++ b/test/multi-dax.sh
e0018b
@@ -13,6 +13,8 @@ check_prereq "jq"
e0018b
 
e0018b
 trap 'err $LINENO' ERR
e0018b
 
e0018b
+ALIGN_SIZE=`getconf PAGESIZE`
e0018b
+
e0018b
 # setup (reset nfit_test dimms)
e0018b
 modprobe nfit_test
e0018b
 $NDCTL disable-region -b $NFIT_TEST_BUS0 all
e0018b
@@ -23,9 +25,9 @@ rc=1
e0018b
 query=". | sort_by(.available_size) | reverse | .[0].dev"
e0018b
 region=$($NDCTL list -b $NFIT_TEST_BUS0 -t pmem -Ri | jq -r "$query")
e0018b
 
e0018b
-json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a 4096 -s 16M)
e0018b
+json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a $ALIGN_SIZE -s 16M)
e0018b
 chardev1=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[0].chardev")
e0018b
-json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a 4096 -s 16M)
e0018b
+json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a $ALIGN_SIZE -s 16M)
e0018b
 chardev2=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[0].chardev")
e0018b
 
e0018b
 _cleanup
e0018b
diff --git a/test/sector-mode.sh b/test/sector-mode.sh
e0018b
index 54fa806..7a2faea 100755
e0018b
--- a/test/sector-mode.sh
e0018b
+++ b/test/sector-mode.sh
e0018b
@@ -11,6 +11,8 @@ check_prereq "jq"
e0018b
 set -e
e0018b
 trap 'err $LINENO' ERR
e0018b
 
e0018b
+ALIGN_SIZE=`getconf PAGESIZE`
e0018b
+
e0018b
 # setup (reset nfit_test dimms)
e0018b
 modprobe nfit_test
e0018b
 $NDCTL disable-region -b $NFIT_TEST_BUS0 all
e0018b
@@ -27,7 +29,7 @@ NAMESPACE=$($NDCTL list -b $NFIT_TEST_BUS1 -N | jq -r "$query")
e0018b
 REGION=$($NDCTL list -R --namespace=$NAMESPACE | jq -r "(.[]) | .dev")
e0018b
 echo 0 > /sys/bus/nd/devices/$REGION/read_only
e0018b
 $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K
e0018b
-$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m dax -f -a 4K
e0018b
+$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m dax -f -a $ALIGN_SIZE
e0018b
 $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K
e0018b
 
e0018b
 _cleanup
e0018b
-- 
e0018b
2.27.0
e0018b