nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Vishal Verma <vishal.l.verma@intel.com>
To: linux-nvdimm@lists.01.org
Subject: [ndctl PATCH] ndctl, test: add a new unit test pfn metadata error clearing
Date: Tue, 18 Sep 2018 14:15:57 -0600	[thread overview]
Message-ID: <20180918201557.6043-1-vishal.l.verma@intel.com> (raw)

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 <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 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
-- 
2.14.4

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

                 reply	other threads:[~2018-09-18 20:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180918201557.6043-1-vishal.l.verma@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).