Skip to contentSkip to conversation

test/clear.sh: test to making sure cleared badblocks don't reappear

PATCH New Vishal Verma 1 participant 1 message Oct 1, 2016 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Vishal Verma

author maintainer
#0 lore raw

PATCH v3 1/1 test/clear.sh: test to making sure cleared badblocks don't reappear

Quoted 1 line

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.

---

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(-)
test/clear.sh +22 -8
index 7765c10..dd5316a 100755
@@ -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
Signature · 6 lines
2.7.4

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm