From patchwork Tue Sep 18 20:15:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 10604843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 918C2913 for ; Tue, 18 Sep 2018 20:16:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 758CD2BDF4 for ; Tue, 18 Sep 2018 20:16:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 672DE2BDF8; Tue, 18 Sep 2018 20:16:45 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 532442BDF4 for ; Tue, 18 Sep 2018 20:16:41 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 29A3121A07A80; Tue, 18 Sep 2018 13:16:41 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=vishal.l.verma@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C273C21A07A80 for ; Tue, 18 Sep 2018 13:16:39 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Sep 2018 13:16:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,391,1531810800"; d="scan'208";a="264662794" Received: from vverma7-desk1.lm.intel.com ([10.232.112.133]) by fmsmga006.fm.intel.com with ESMTP; 18 Sep 2018 13:16:01 -0700 From: Vishal Verma To: Subject: [ndctl PATCH] ndctl, test: add a new unit test pfn metadata error clearing Date: Tue, 18 Sep 2018 14:15:57 -0600 Message-Id: <20180918201557.6043-1-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.14.4 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 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 The pfn driver lacked a way to clear badblocks in the volatile struct page area, but this is expected to be fixed for v4.20. Add a unit test that creates an fsdax namespace, forces it to raw mode, injects errors to the metadata area, and converts it back to fsdax. For a kernel with the error clearing improvements, this will clear the injected errors, but if the kernel changes are missing, the errors will stay intact. At this point, convert the namespace back to raw mode and check for the presence of badblocks. Cc: Dan Williams Signed-off-by: Vishal Verma --- test/Makefile.am | 3 +- test/pfn-meta-errors.sh | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100755 test/pfn-meta-errors.sh diff --git a/test/Makefile.am b/test/Makefile.am index 50bb2e4..ebdd23f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -24,7 +24,8 @@ TESTS =\ rescan-partitions.sh \ inject-smart.sh \ monitor.sh \ - max_available_extent_ns.sh + max_available_extent_ns.sh \ + pfn-meta-errors.sh check_PROGRAMS =\ libndctl \ diff --git a/test/pfn-meta-errors.sh b/test/pfn-meta-errors.sh new file mode 100755 index 0000000..2b57f19 --- /dev/null +++ b/test/pfn-meta-errors.sh @@ -0,0 +1,74 @@ +#!/bin/bash -Ex + +# SPDX-License-Identifier: GPL-2.0 +# Copyright(c) 2018 Intel Corporation. All rights reserved. + +blockdev="" +rc=77 + +. ./common + +force_raw() +{ + raw="$1" + $NDCTL disable-namespace "$dev" + echo "$raw" > "/sys/bus/nd/devices/$dev/force_raw" + $NDCTL enable-namespace "$dev" + echo "Set $dev to raw mode: $raw" + if [[ "$raw" == "1" ]]; then + raw_bdev=${blockdev} + test -b "/dev/$raw_bdev" + else + raw_bdev="" + fi +} + +check_min_kver "4.20" || do_skip "may lack PFN metadata error handling" + +set -e +trap 'err $LINENO' ERR + +# setup (reset nfit_test dimms) +modprobe nfit_test +$NDCTL disable-region -b $NFIT_TEST_BUS0 all +$NDCTL zero-labels -b $NFIT_TEST_BUS0 all +$NDCTL enable-region -b $NFIT_TEST_BUS0 all + +rc=1 + +# create a fsdax namespace and clear errors (if any) +dev="x" +json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m fsdax) +eval "$(echo "$json" | json2var)" +[ $dev = "x" ] && echo "fail: $LINENO" && exit 1 + +force_raw 1 +if read -r sector len < "/sys/block/$raw_bdev/badblocks"; then + dd of=/dev/$raw_bdev if=/dev/zero oflag=direct bs=512 seek="$sector" count="$len" +fi +force_raw 0 + +# find dataoff from sb +force_raw 1 +doff=$(hexdump -s $((4096 + 56)) -n 4 "/dev/$raw_bdev" | head -1 | cut -d' ' -f2-) +doff=$(tr -d ' ' <<< "0x${doff#* }${doff%% *}") +printf "pfn dataoff: %x\n" "$doff" +dblk="$((doff/512))" + +metaoff="0x2000" +mblk="$((metaoff/512))" + +# inject in the middle of the struct page area +bb_inj=$(((dblk - mblk)/2)) +$NDCTL inject-error --block="$bb_inj" --count=32 $dev +$NDCTL start-scrub && $NDCTL wait-scrub + +# after probe from the enable-namespace, the error should've been cleared +force_raw 0 +force_raw 1 +if read -r sector len < "/sys/block/$raw_bdev/badblocks"; then + false +fi + +_cleanup +exit 0