anitazha / rpms / ndctl

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