linux-nvdimm.lists.01.org archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Subject: [ndctl PATCH 36/36] ndctl/test: Regression test misaligned namespaces
Date: Sat, 29 Feb 2020 12:23:15 -0800	[thread overview]
Message-ID: <158300779557.2141307.1119464097611805912.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <158300760415.2141307.14060353322051900501.stgit@dwillia2-desk3.amr.corp.intel.com>

The kernel is now requiring that namespace creation results in
cross-arch compatible namespaces by default. However, it must also
continue to support previously valid, but misaligned, namespaces. Use
the write-infoblock utility to create "legacy" configurations and
validate that the kernel still accepts it along with other corner case
configurations.

Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/Makefile.am |    1 
 test/align.sh    |  118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 119 insertions(+)
 create mode 100755 test/align.sh

diff --git a/test/Makefile.am b/test/Makefile.am
index cce60c5221fd..1d24a65ded8b 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -54,6 +54,7 @@ TESTS +=\
 	dax-dev \
 	dax-ext4.sh \
 	dax-xfs.sh \
+	align.sh \
 	device-dax \
 	device-dax-fio.sh \
 	daxctl-devices.sh \
diff --git a/test/align.sh b/test/align.sh
new file mode 100755
index 000000000000..0129255610ab
--- /dev/null
+++ b/test/align.sh
@@ -0,0 +1,118 @@
+#!/bin/bash -x
+# SPDX-License-Identifier: GPL-2.0
+# Copyright(c) 2015-2020 Intel Corporation. All rights reserved.
+
+. $(dirname $0)/common
+
+rc=77
+cleanup() {
+	echo "align.sh: failed at line $1"
+	if [ "x$region" != "x" -a x$save_align != "x" ]; then
+		echo $save_align > $region_path/align
+	fi
+
+	if [ "x$ns1" != "x" ]; then
+		$NDCTL destroy-namespace -f $ns1
+	fi
+	if [ "x$ns2" != "x" ]; then
+		$NDCTL destroy-namespace -f $ns2
+	fi
+
+	exit $rc
+}
+
+is_aligned() {
+	val=$1
+	align=$2
+
+	if [ $((val & (align - 1))) -eq 0 ]; then
+		return 0
+	fi
+	return 1
+}
+
+set -e
+trap 'err $LINENO cleanup' ERR
+
+region=$($NDCTL list -R -b ACPI.NFIT | jq -r '.[] | [select(.available_size == .size)] | .[0].dev')
+
+if [ "x$region" = "xnull"  ]; then
+	unset $region
+	echo "unable to find empty region"
+	false
+fi
+
+region_path="/sys/bus/nd/devices/$region"
+save_align=$(cat $region_path/align)
+
+# check that the region is 1G aligned
+resource=$(cat $region_path/resource)
+is_aligned $resource $((1 << 30)) || (echo "need a 1GB aligned namespace to test alignment conditions" && false)
+
+rc=1
+
+# check that start-aligned, but end-misaligned namespaces can be created
+# and probed
+echo 4096 > $region_path/align
+SIZE=$(((1<<30) + (8<<10)))
+json=$($NDCTL create-namespace -r $region -s $SIZE -m fsdax -a 4K)
+eval $(json2var <<< "$json")
+$NDCTL disable-namespace $dev
+$NDCTL enable-namespace $dev
+ns1=$dev
+
+# check that start-misaligned namespaces can't be created until the
+# region alignment is set to a compatible value.
+# Note the namespace capacity alignment requirement in this case is
+# SUBSECTION_SIZE (2M) as the data alignment can be satisfied with
+# metadata padding.
+json=$($NDCTL create-namespace -r $region -s $SIZE -m fsdax -a 4K -f) || status="failed"
+if [ $status != "failed" ]; then
+	echo "expected namespace creation failure"
+	eval $(json2var <<< "$json")
+	$NDCTL destroy-namespace -f $dev
+	false
+fi
+
+# check that start-misaligned namespaces can't be probed. Since the
+# kernel does not support creating this misalignment, force it with a
+# custom info-block
+json=$($NDCTL create-namespace -r $region -s $SIZE -m raw)
+eval $(json2var <<< "$json")
+
+$NDCTL disable-namespace $dev
+$NDCTL write-infoblock $dev -a 4K
+$NDCTL enable-namespace $dev || status="failed"
+
+if [ $status != "failed" ]; then
+	echo "expected namespace enable failure"
+	$NDCTL destroy-namespace -f $dev
+	false
+fi
+ns2=$dev
+
+# check that namespace with proper inner padding can be enabled, even
+# though non-zero start_pad namespaces don't support dax
+$NDCTL write-infoblock $ns2 -a 4K -O 8K
+$NDCTL enable-namespace $ns2
+$NDCTL destroy-namespace $ns2 -f
+unset ns2
+
+# check that all namespace alignments can be created with the region
+# alignment at a compatible value
+SIZE=$((2 << 30))
+echo $((16 << 20)) > $region_path/align
+for i in $((1 << 30)) $((2 << 20)) $((4 << 10))
+do
+	json=$($NDCTL create-namespace -r $region -s $SIZE -m fsdax -a $i)
+	eval $(json2var <<< "$json")
+	ns2=$dev
+	$NDCTL disable-namespace $dev
+	$NDCTL enable-namespace $dev
+	$NDCTL destroy-namespace $dev -f
+	unset ns2
+done
+
+# final cleanup
+$NDCTL destroy-namespace $ns1 -f
+exit 0
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

  parent reply	other threads:[~2020-02-29 20:39 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-29 20:20 [ndctl PATCH 00/36] Multiple topics / backlog for v68 Dan Williams
2020-02-29 20:20 ` [ndctl PATCH 01/36] ndctl/list: Add 'target_node' to region and namespace verbose listings Dan Williams
2020-02-29 20:20 ` [ndctl PATCH 02/36] ndctl/docs: Fix mailing list sign-up link Dan Williams
2020-02-29 20:20 ` [ndctl PATCH 03/36] ndctl/list: Drop named list objects from verbose listing Dan Williams
2020-02-29 20:20 ` [ndctl PATCH 04/36] daxctl/list: Avoid memory operations without resource data Dan Williams
2020-02-29 20:20 ` [ndctl PATCH 05/36] ndctl/build: Fix distcheck Dan Williams
2020-02-29 20:20 ` [ndctl PATCH 06/36] ndctl/namespace: Fix destroy-namespace accounting relative to seed devices Dan Williams
2020-02-29 20:20 ` [ndctl PATCH 07/36] ndctl/region: Support ndctl_region_{get, set}_align() Dan Williams
2020-02-29 20:20 ` [ndctl PATCH 08/36] ndctl/namespace: Emit better errors on failure Dan Williams
2020-02-29 20:20 ` [ndctl PATCH 09/36] ndctl/namespace: Check for region alignment violations Dan Williams
2020-02-29 20:20 ` [ndctl PATCH 10/36] ndctl/util: Up-level is_power_of_2() and introduce IS_ALIGNED Dan Williams
2020-02-29 20:21 ` [ndctl PATCH 11/36] ndctl/namespace: Validate resource alignment for dax-mode namespaces Dan Williams
2020-02-29 20:21 ` [ndctl PATCH 12/36] ndctl/namespace: Add read-infoblock command Dan Williams
2020-02-29 20:21 ` [ndctl PATCH 13/36] ndctl/test: Update dax-dev to handle multiple e820 ranges Dan Williams
2020-02-29 20:21 ` [ndctl PATCH 14/36] ndctl/namespace: Always zero info-blocks Dan Williams
2020-02-29 20:21 ` [ndctl PATCH 15/36] ndctl/namespace: Disable autorecovery of create-namespace failures Dan Williams
2020-02-29 20:21 ` [ndctl PATCH 16/36] ndctl/build: Fix EXTRA_DIST already defined errors Dan Williams
2020-02-29 20:21 ` [ndctl PATCH 17/36] ndctl/test: Checkout device-mapper + dax operation Dan Williams
2020-02-29 20:21 ` [ndctl PATCH 18/36] ndctl/test: Exercise sub-section sized namespace creation/deletion Dan Williams
2020-02-29 20:21 ` [ndctl PATCH 19/36] ndctl/namespace: Kill off the legacy mode names Dan Williams
2020-02-29 20:21 ` [ndctl PATCH 20/36] ndctl/namespace: Introduce mode-to-name and name-to-mode helpers Dan Williams
2020-02-29 20:21 ` [ndctl PATCH 21/36] ndctl/namespace: Validate namespace size within validate_namespace_options() Dan Williams
2020-02-29 20:22 ` [ndctl PATCH 22/36] ndctl/namespace: Clarify 16M minimum size requirement Dan Williams
2020-02-29 20:22 ` [ndctl PATCH 23/36] ndctl/test: Regression test 'failed to track' Dan Williams
2020-02-29 20:22 ` [ndctl PATCH 24/36] ndctl/dimm: Rework dimm command status reporting Dan Williams
2020-02-29 20:22 ` [ndctl PATCH 25/36] ndctl/dimm: Rework iteration to drop unaligned pointers Dan Williams
2020-02-29 20:22 ` [ndctl PATCH 26/36] ndctl/test: Fix typos / loss of tpm.handle in security test Dan Williams
2020-02-29 20:22 ` [ndctl PATCH 27/36] ndctl/test: Relax dax_pmem_compat requirement Dan Williams
2020-03-03 13:28   ` Jan Kara
2020-03-03 21:05     ` Dan Williams
2020-03-03 22:58   ` [ndctl PATCH v2 1/2] ndctl/test: Cleanup test-vs-production nvdimm module detection Dan Williams
2020-03-04 12:44     ` Jan Kara
2020-03-03 22:58   ` [ndctl PATCH v2 2/2] ndctl/test: Relax dax_pmem_compat requirement Dan Williams
2020-03-04 12:44     ` Jan Kara
2020-02-29 20:22 ` [ndctl PATCH 28/36] ndctl/namespace: Fix namespace-action vs namespace-mode confusion Dan Williams
2020-02-29 20:22 ` [ndctl PATCH 29/36] ndctl/namespace: Update 'pfn' infoblock definition Dan Williams
2020-02-29 20:22 ` [ndctl PATCH 30/36] ndctl/util: Return 0 for NULL arguments to parse_size64() Dan Williams
2020-02-29 20:22 ` [ndctl PATCH 31/36] ndctl/namespace: Fix read-info-block vs read-infoblock Dan Williams
2020-02-29 20:22 ` [ndctl PATCH 32/36] ndctl/namespace: Parse infoblocks from stdin Dan Williams
2020-02-29 20:23 ` [ndctl PATCH 33/36] ndctl/namespace: Add write-infoblock command Dan Williams
2020-02-29 20:23 ` [ndctl PATCH 34/36] ndctl/list: Add option to list configured + disabled namespaces Dan Williams
2020-02-29 20:23 ` [ndctl PATCH 35/36] ndctl/lib/namespace: Fix resource retrieval after size change Dan Williams
2020-02-29 20:23 ` Dan Williams [this message]
2020-03-19  4:13 ` [ndctl PATCH 00/36] Multiple topics / backlog for v68 Verma, Vishal L

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=158300779557.2141307.1119464097611805912.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=aneesh.kumar@linux.ibm.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).