diff mbox

[ndctl,v3] test/clear.sh: test to making sure cleared badblocks don't reappear

Message ID 1475280440-14641-1-git-send-email-vishal.l.verma@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Verma, Vishal L Oct. 1, 2016, 12:07 a.m. UTC
From v4.9 onwards, cleared badblocks won't reappear on an ARS or simply
after disabling/re-enabling a namespace. Add a test to make sure this
doesn't regress.

Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---

v3: make the script's kernel version check also use the new
check_min_kver function

 test/clear.sh | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/test/clear.sh b/test/clear.sh
index 7765c10..dd5316a 100755
--- a/test/clear.sh
+++ b/test/clear.sh
@@ -13,14 +13,16 @@  err() {
 	exit $rc
 }
 
-eval $(uname -r | awk -F. '{print "maj="$1 ";" "min="$2}')
-if [ $maj -lt 4 ]; then
-	echo "kernel $maj.$min lacks clear poison support"
-	exit $rc
-elif [ $maj -eq 4 -a $min -lt 6 ]; then
-	echo "kernel $maj.$min lacks clear poison support"
-	exit $rc
-fi
+check_min_kver()
+{
+	local ver="$1"
+	${KVER:=$(uname -r)}
+
+	[ -n "$ver" ] || return 1
+	[[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)" ]]
+}
+
+check_min_kver "4.6" || { echo "kernel $KVER lacks clear poison support"; exit $rc; }
 
 set -e
 trap 'err $LINENO' ERR
@@ -69,6 +71,18 @@  if read sector len < /sys/block/$blockdev/badblocks; then
 	echo "fail: $LINENO" && exit 1
 fi
 
+if check_min_kver "4.9.0"; then
+	# check for re-appearance of stale badblocks from poison_list
+	$NDCTL disable-region $BUS all
+	$NDCTL enable-region $BUS all
+
+	# since we have cleared the errors, a disable/reenable shouldn't bring them back
+	if read sector len < /sys/block/$blockdev/badblocks; then
+		# fail if reading badblocks returns data
+		echo "fail: $LINENO" && exit 1
+	fi
+fi
+
 $NDCTL disable-region $BUS all
 $NDCTL disable-region $BUS1 all
 modprobe -r nfit_test