All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vishal Verma <vishal.l.verma@intel.com>
To: <linux-nvdimm@lists.01.org>
Cc: Dan Williams <dan.j.williams@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>
Subject: [ndctl PATCH 2/2] ndctl/test: fix align.sh to not expect initialized labels
Date: Wed, 20 May 2020 18:58:48 -0600	[thread overview]
Message-ID: <20200521005848.7272-2-vishal.l.verma@intel.com> (raw)
In-Reply-To: <20200521005848.7272-1-vishal.l.verma@intel.com>

A fresh qemu based system may not have its labels initialized. In this
case, align.sh would get skipped because the label-less namespaces would
be using all available region capacity.

Fix this by initializing labels if a usable region is not found the
first time around, and try again.

Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 test/align.sh | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/test/align.sh b/test/align.sh
index 81d1fbc..37b2a1d 100755
--- a/test/align.sh
+++ b/test/align.sh
@@ -34,8 +34,19 @@ is_aligned() {
 set -e
 trap 'err $LINENO cleanup' ERR
 
-region=$($NDCTL list -R -b ACPI.NFIT | jq -r '[.[] | select(.available_size == .size)][0] | .dev')
+find_region()
+{
+	$NDCTL list -R -b ACPI.NFIT | jq -r '[.[] | select(.available_size == .size)][0] | .dev'
+}
 
+region=$(find_region)
+if [ "x$region" = "xnull"  ]; then
+	# this is destructive
+	$NDCTL disable-region -b ACPI.NFIT all
+	$NDCTL init-labels -f -b ACPI.NFIT all
+	$NDCTL enable-region -b ACPI.NFIT all
+fi
+region=$(find_region)
 if [ "x$region" = "xnull"  ]; then
 	unset $region
 	echo "unable to find empty region"
-- 
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

      reply	other threads:[~2020-05-21  0:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-21  0:58 [ndctl PATCH 1/2] ndctl/test: Fix region selection in align.sh Vishal Verma
2020-05-21  0:58 ` Vishal Verma [this message]

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=20200521005848.7272-2-vishal.l.verma@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=dan.j.williams@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.