@@ -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
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(-)