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

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