From patchwork Sat Oct 1 00:07:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 9359031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CECCD607D6 for ; Sat, 1 Oct 2016 00:08:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B64062A12A for ; Sat, 1 Oct 2016 00:08:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A70652A10B; Sat, 1 Oct 2016 00:08:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 291CD2A10B for ; Sat, 1 Oct 2016 00:08:12 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 579881A1E05; Fri, 30 Sep 2016 17:08:12 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 94D7D1A1E05 for ; Fri, 30 Sep 2016 17:08:11 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP; 30 Sep 2016 17:08:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.31,423,1473145200"; d="scan'208,223"; a="15096458" Received: from omniknight.lm.intel.com ([10.232.112.53]) by fmsmga006.fm.intel.com with ESMTP; 30 Sep 2016 17:08:11 -0700 From: Vishal Verma To: Subject: [ndctl PATCH v3] test/clear.sh: test to making sure cleared badblocks don't reappear Date: Fri, 30 Sep 2016 18:07:20 -0600 Message-Id: <1475280440-14641-1-git-send-email-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.7.4 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 --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