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

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