anitazha / rpms / ndctl

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