Blame SOURCES/0071-ndctl-test-Move-reset-to-function-in-common.patch

26ccd9
From 6538529be5738f06543a0d7178f97e0b0e6b63c2 Mon Sep 17 00:00:00 2001
26ccd9
From: Dan Williams <dan.j.williams@intel.com>
26ccd9
Date: Wed, 5 Jan 2022 13:31:55 -0800
26ccd9
Subject: [PATCH 071/217] ndctl/test: Move 'reset()' to function in 'common'
26ccd9
26ccd9
When BLK mode is removed, tests that expect the nfit_test region to allow
26ccd9
pmem namespace creation will need to 'init' rather than 'zero' labels. In
26ccd9
preparation, take the time opportunity to move reset() to a common
26ccd9
function. So that 'ndctl zero-labels' can be replaced with 'ndctl
26ccd9
init-labels' in one central location.
26ccd9
26ccd9
Link: https://lore.kernel.org/r/164141831509.3990253.14783946910211635678.stgit@dwillia2-desk3.amr.corp.intel.com
26ccd9
Tested-by: Alison Schofield <alison.schofield@intel.com>
26ccd9
Tested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
26ccd9
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
26ccd9
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
26ccd9
---
26ccd9
 test/blk-exhaust.sh             |  4 +---
26ccd9
 test/btt-check.sh               |  7 -------
26ccd9
 test/btt-errors.sh              | 12 +++---------
26ccd9
 test/btt-pad-compat.sh          |  7 -------
26ccd9
 test/clear.sh                   |  4 +---
26ccd9
 test/common                     | 15 +++++++++++++++
26ccd9
 test/create.sh                  |  4 +---
26ccd9
 test/daxctl-create.sh           |  4 ++--
26ccd9
 test/daxdev-errors.sh           |  4 +---
26ccd9
 test/firmware-update.sh         |  8 +++-----
26ccd9
 test/inject-error.sh            |  7 -------
26ccd9
 test/max_available_extent_ns.sh |  9 +--------
26ccd9
 test/monitor.sh                 | 11 ++---------
26ccd9
 test/multi-dax.sh               |  4 +---
26ccd9
 test/pfn-meta-errors.sh         |  4 +---
26ccd9
 test/pmem-errors.sh             |  4 +---
26ccd9
 test/rescan-partitions.sh       |  7 -------
26ccd9
 test/sector-mode.sh             |  9 ++-------
26ccd9
 test/track-uuid.sh              |  4 +---
26ccd9
 19 files changed, 36 insertions(+), 92 deletions(-)
26ccd9
26ccd9
diff --git a/test/blk-exhaust.sh b/test/blk-exhaust.sh
26ccd9
index 09c4aae..b6d3808 100755
26ccd9
--- a/test/blk-exhaust.sh
26ccd9
+++ b/test/blk-exhaust.sh
26ccd9
@@ -14,9 +14,7 @@ trap 'err $LINENO' ERR
26ccd9
 
26ccd9
 # setup (reset nfit_test dimms)
26ccd9
 modprobe nfit_test
26ccd9
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
+reset
26ccd9
 
26ccd9
 # if the kernel accounting is correct we should be able to create two
26ccd9
 # pmem and two blk namespaces on nfit_test.0
26ccd9
diff --git a/test/btt-check.sh b/test/btt-check.sh
26ccd9
index 8e0b489..65b5c58 100755
26ccd9
--- a/test/btt-check.sh
26ccd9
+++ b/test/btt-check.sh
26ccd9
@@ -39,13 +39,6 @@ create()
26ccd9
 	[ $size -gt 0 ] || err "$LINENO"
26ccd9
 }
26ccd9
 
26ccd9
-reset()
26ccd9
-{
26ccd9
-	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
-}
26ccd9
-
26ccd9
 # re-enable the BTT namespace, and do IO to it in an attempt to
26ccd9
 # verify it still comes up ok, and functions as expected
26ccd9
 post_repair_test()
26ccd9
diff --git a/test/btt-errors.sh b/test/btt-errors.sh
26ccd9
index 4e59f57..5a20d26 100755
26ccd9
--- a/test/btt-errors.sh
26ccd9
+++ b/test/btt-errors.sh
26ccd9
@@ -45,9 +45,7 @@ trap 'err $LINENO cleanup' ERR
26ccd9
 
26ccd9
 # setup (reset nfit_test dimms)
26ccd9
 modprobe nfit_test
26ccd9
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
+reset
26ccd9
 
26ccd9
 rc=1
26ccd9
 
26ccd9
@@ -126,9 +124,7 @@ dd if=$MNT/$FILE of=/dev/null iflag=direct bs=4096 count=1
26ccd9
 
26ccd9
 # reset everything to get a clean log
26ccd9
 if grep -q "$MNT" /proc/mounts; then umount $MNT; fi
26ccd9
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
+reset
26ccd9
 dev="x"
26ccd9
 json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m sector)
26ccd9
 eval "$(echo "$json" | json2var)"
26ccd9
@@ -148,9 +144,7 @@ force_raw 0
26ccd9
 dd if=/dev/$blockdev of=/dev/null iflag=direct bs=4096 count=1 && err $LINENO || true
26ccd9
 
26ccd9
 # done, exit
26ccd9
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
+reset
26ccd9
 cleanup
26ccd9
 _cleanup
26ccd9
 exit 0
26ccd9
diff --git a/test/btt-pad-compat.sh b/test/btt-pad-compat.sh
26ccd9
index bf1ea54..be538b7 100755
26ccd9
--- a/test/btt-pad-compat.sh
26ccd9
+++ b/test/btt-pad-compat.sh
26ccd9
@@ -37,13 +37,6 @@ create()
26ccd9
 	fi
26ccd9
 }
26ccd9
 
26ccd9
-reset()
26ccd9
-{
26ccd9
-	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
-}
26ccd9
-
26ccd9
 verify_idx()
26ccd9
 {
26ccd9
 	idx0="$1"
26ccd9
diff --git a/test/clear.sh b/test/clear.sh
26ccd9
index fb9d52c..c4d02d5 100755
26ccd9
--- a/test/clear.sh
26ccd9
+++ b/test/clear.sh
26ccd9
@@ -14,9 +14,7 @@ trap 'err $LINENO' ERR
26ccd9
 
26ccd9
 # setup (reset nfit_test dimms)
26ccd9
 modprobe nfit_test
26ccd9
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
+reset
26ccd9
 
26ccd9
 rc=1
26ccd9
 
26ccd9
diff --git a/test/common b/test/common
26ccd9
index 6bcefca..3c54d63 100644
26ccd9
--- a/test/common
26ccd9
+++ b/test/common
26ccd9
@@ -46,6 +46,21 @@ err()
26ccd9
 	exit $rc
26ccd9
 }
26ccd9
 
26ccd9
+reset()
26ccd9
+{
26ccd9
+	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
+	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
+	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
+}
26ccd9
+
26ccd9
+reset1()
26ccd9
+{
26ccd9
+	$NDCTL disable-region -b $NFIT_TEST_BUS1 all
26ccd9
+	$NDCTL zero-labels -b $NFIT_TEST_BUS1 all
26ccd9
+	$NDCTL enable-region -b $NFIT_TEST_BUS1 all
26ccd9
+}
26ccd9
+
26ccd9
+
26ccd9
 # check_min_kver
26ccd9
 # $1: Supported kernel version. format: X.Y
26ccd9
 #
26ccd9
diff --git a/test/create.sh b/test/create.sh
26ccd9
index b0fd99f..e9baaa0 100755
26ccd9
--- a/test/create.sh
26ccd9
+++ b/test/create.sh
26ccd9
@@ -15,9 +15,7 @@ trap 'err $LINENO' ERR
26ccd9
 
26ccd9
 # setup (reset nfit_test dimms)
26ccd9
 modprobe nfit_test
26ccd9
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
+reset
26ccd9
 
26ccd9
 rc=1
26ccd9
 
26ccd9
diff --git a/test/daxctl-create.sh b/test/daxctl-create.sh
26ccd9
index 198779a..d319a39 100755
26ccd9
--- a/test/daxctl-create.sh
26ccd9
+++ b/test/daxctl-create.sh
26ccd9
@@ -10,7 +10,7 @@ trap 'cleanup $LINENO' ERR
26ccd9
 cleanup()
26ccd9
 {
26ccd9
 	printf "Error at line %d\n" "$1"
26ccd9
-	[[ $testdev ]] && reset
26ccd9
+	[[ $testdev ]] && reset_dax
26ccd9
 	exit $rc
26ccd9
 }
26ccd9
 
26ccd9
@@ -70,7 +70,7 @@ reset_dev()
26ccd9
 	"$DAXCTL" enable-device "$testdev"
26ccd9
 }
26ccd9
 
26ccd9
-reset()
26ccd9
+reset_dax()
26ccd9
 {
26ccd9
 	test -n "$testdev"
26ccd9
 
26ccd9
diff --git a/test/daxdev-errors.sh b/test/daxdev-errors.sh
26ccd9
index 9547d78..e13453d 100755
26ccd9
--- a/test/daxdev-errors.sh
26ccd9
+++ b/test/daxdev-errors.sh
26ccd9
@@ -15,9 +15,7 @@ trap 'err $LINENO' ERR
26ccd9
 
26ccd9
 # setup (reset nfit_test dimms)
26ccd9
 modprobe nfit_test
26ccd9
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
+reset
26ccd9
 
26ccd9
 rc=1
26ccd9
 
26ccd9
diff --git a/test/firmware-update.sh b/test/firmware-update.sh
26ccd9
index 8cc9c41..93ce166 100755
26ccd9
--- a/test/firmware-update.sh
26ccd9
+++ b/test/firmware-update.sh
26ccd9
@@ -10,11 +10,9 @@ image="update-fw.img"
26ccd9
 
26ccd9
 trap 'err $LINENO' ERR
26ccd9
 
26ccd9
-reset()
26ccd9
+fwupd_reset()
26ccd9
 {
26ccd9
-	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
+	reset
26ccd9
 	if [ -f $image ]; then
26ccd9
 		rm -f $image
26ccd9
 	fi
26ccd9
@@ -73,7 +71,7 @@ do_tests()
26ccd9
 check_min_kver "4.16" || do_skip "may lack firmware update test handling"
26ccd9
 
26ccd9
 modprobe nfit_test
26ccd9
-reset
26ccd9
+fwupd_reset
26ccd9
 detect
26ccd9
 rc=1
26ccd9
 do_tests
26ccd9
diff --git a/test/inject-error.sh b/test/inject-error.sh
26ccd9
index 7d0b826..fd823b6 100755
26ccd9
--- a/test/inject-error.sh
26ccd9
+++ b/test/inject-error.sh
26ccd9
@@ -37,13 +37,6 @@ create()
26ccd9
 	[ $size -gt 0 ] || err "$LINENO"
26ccd9
 }
26ccd9
 
26ccd9
-reset()
26ccd9
-{
26ccd9
-	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
-}
26ccd9
-
26ccd9
 check_status()
26ccd9
 {
26ccd9
 	local sector="$1"
26ccd9
diff --git a/test/max_available_extent_ns.sh b/test/max_available_extent_ns.sh
26ccd9
index 343f3c9..47a921f 100755
26ccd9
--- a/test/max_available_extent_ns.sh
26ccd9
+++ b/test/max_available_extent_ns.sh
26ccd9
@@ -11,13 +11,6 @@ trap 'err $LINENO' ERR
26ccd9
 check_min_kver "4.19" || do_skip "kernel $KVER may not support max_available_size"
26ccd9
 check_prereq "jq"
26ccd9
 
26ccd9
-init()
26ccd9
-{
26ccd9
-	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
-}
26ccd9
-
26ccd9
 do_test()
26ccd9
 {
26ccd9
 	region=$($NDCTL list -b $NFIT_TEST_BUS0 -R -t pmem | jq -r 'sort_by(-.size) | .[].dev' | head -1)
26ccd9
@@ -40,7 +33,7 @@ do_test()
26ccd9
 
26ccd9
 modprobe nfit_test
26ccd9
 rc=1
26ccd9
-init
26ccd9
+reset
26ccd9
 do_test
26ccd9
 _cleanup
26ccd9
 exit 0
26ccd9
diff --git a/test/monitor.sh b/test/monitor.sh
26ccd9
index c015c11..6aa4196 100755
26ccd9
--- a/test/monitor.sh
26ccd9
+++ b/test/monitor.sh
26ccd9
@@ -19,13 +19,6 @@ trap 'err $LINENO' ERR
26ccd9
 
26ccd9
 check_min_kver "4.15" || do_skip "kernel $KVER may not support monitor service"
26ccd9
 
26ccd9
-init()
26ccd9
-{
26ccd9
-	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
-}
26ccd9
-
26ccd9
 start_monitor()
26ccd9
 {
26ccd9
 	logfile=$(mktemp)
26ccd9
@@ -112,7 +105,7 @@ test_filter_region()
26ccd9
 
26ccd9
 test_filter_namespace()
26ccd9
 {
26ccd9
-	init
26ccd9
+	reset
26ccd9
 	monitor_namespace=$($NDCTL create-namespace -b $smart_supported_bus | jq -r .dev)
26ccd9
 	monitor_dimms=$(get_monitor_dimm "-n $monitor_namespace")
26ccd9
 	start_monitor "-n $monitor_namespace"
26ccd9
@@ -170,7 +163,7 @@ do_tests()
26ccd9
 
26ccd9
 modprobe nfit_test
26ccd9
 rc=1
26ccd9
-init
26ccd9
+reset
26ccd9
 set_smart_supported_bus
26ccd9
 do_tests
26ccd9
 _cleanup
26ccd9
diff --git a/test/multi-dax.sh b/test/multi-dax.sh
26ccd9
index b343a38..04070ad 100755
26ccd9
--- a/test/multi-dax.sh
26ccd9
+++ b/test/multi-dax.sh
26ccd9
@@ -17,9 +17,7 @@ ALIGN_SIZE=`getconf PAGESIZE`
26ccd9
 
26ccd9
 # setup (reset nfit_test dimms)
26ccd9
 modprobe nfit_test
26ccd9
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
+reset
26ccd9
 rc=1
26ccd9
 
26ccd9
 query=". | sort_by(.available_size) | reverse | .[0].dev"
26ccd9
diff --git a/test/pfn-meta-errors.sh b/test/pfn-meta-errors.sh
26ccd9
index 0ade2e5..6314897 100755
26ccd9
--- a/test/pfn-meta-errors.sh
26ccd9
+++ b/test/pfn-meta-errors.sh
26ccd9
@@ -29,9 +29,7 @@ trap 'err $LINENO' ERR
26ccd9
 
26ccd9
 # setup (reset nfit_test dimms)
26ccd9
 modprobe nfit_test
26ccd9
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
+reset
26ccd9
 
26ccd9
 rc=1
26ccd9
 
26ccd9
diff --git a/test/pmem-errors.sh b/test/pmem-errors.sh
26ccd9
index 4225c3b..2065780 100755
26ccd9
--- a/test/pmem-errors.sh
26ccd9
+++ b/test/pmem-errors.sh
26ccd9
@@ -28,9 +28,7 @@ trap 'err $LINENO cleanup' ERR
26ccd9
 
26ccd9
 # setup (reset nfit_test dimms)
26ccd9
 modprobe nfit_test
26ccd9
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
+reset
26ccd9
 
26ccd9
 rc=1
26ccd9
 
26ccd9
diff --git a/test/rescan-partitions.sh b/test/rescan-partitions.sh
26ccd9
index 1686de3..51bbd73 100755
26ccd9
--- a/test/rescan-partitions.sh
26ccd9
+++ b/test/rescan-partitions.sh
26ccd9
@@ -25,13 +25,6 @@ check_min_kver "4.16" || do_skip "may not contain fixes for partition rescanning
26ccd9
 check_prereq "parted"
26ccd9
 check_prereq "blockdev"
26ccd9
 
26ccd9
-reset()
26ccd9
-{
26ccd9
-	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
-}
26ccd9
-
26ccd9
 test_mode()
26ccd9
 {
26ccd9
 	local mode="$1"
26ccd9
diff --git a/test/sector-mode.sh b/test/sector-mode.sh
26ccd9
index 7a2faea..439ef33 100755
26ccd9
--- a/test/sector-mode.sh
26ccd9
+++ b/test/sector-mode.sh
26ccd9
@@ -15,13 +15,8 @@ ALIGN_SIZE=`getconf PAGESIZE`
26ccd9
 
26ccd9
 # setup (reset nfit_test dimms)
26ccd9
 modprobe nfit_test
26ccd9
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
-
26ccd9
-$NDCTL disable-region -b $NFIT_TEST_BUS1 all
26ccd9
-$NDCTL zero-labels -b $NFIT_TEST_BUS1 all
26ccd9
-$NDCTL enable-region -b $NFIT_TEST_BUS1 all
26ccd9
+reset
26ccd9
+reset1
26ccd9
 
26ccd9
 rc=1
26ccd9
 query=". | sort_by(.size) | reverse | .[0].dev"
26ccd9
diff --git a/test/track-uuid.sh b/test/track-uuid.sh
26ccd9
index be3cf9c..3bacd2c 100755
26ccd9
--- a/test/track-uuid.sh
26ccd9
+++ b/test/track-uuid.sh
26ccd9
@@ -12,9 +12,7 @@ trap 'err $LINENO' ERR
26ccd9
 
26ccd9
 # setup (reset nfit_test dimms)
26ccd9
 modprobe nfit_test
26ccd9
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
26ccd9
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
26ccd9
+reset
26ccd9
 
26ccd9
 rc=1
26ccd9
 
26ccd9
-- 
26ccd9
2.27.0
26ccd9