|
|
26ccd9 |
From f149f539e874415c0ec19b43a2c9bf2c56f3aa80 Mon Sep 17 00:00:00 2001
|
|
|
26ccd9 |
From: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
26ccd9 |
Date: Wed, 13 Jul 2022 14:37:58 -0600
|
|
|
26ccd9 |
Subject: [PATCH 187/217] cxl/test: add a test to {read,write,zero}-labels
|
|
|
26ccd9 |
|
|
|
26ccd9 |
Add a unit test to test writing, reading, and zeroing LSA aread for
|
|
|
26ccd9 |
cxl_test based memdevs using ndctl commands, and reading using cxl-cli
|
|
|
26ccd9 |
commands to exercise that route as much as possible.
|
|
|
26ccd9 |
|
|
|
26ccd9 |
Note that writing using cxl-cli requires a bit more enabling to enable,
|
|
|
26ccd9 |
as the corresponding nvdimm-bridge object will need to be disabled
|
|
|
26ccd9 |
first.
|
|
|
26ccd9 |
|
|
|
26ccd9 |
Link: https://lore.kernel.org/r/20220713203758.519892-1-vishal.l.verma@intel.com
|
|
|
26ccd9 |
Cc: Dan Williams <dan.j.williams@intel.com>
|
|
|
26ccd9 |
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
|
|
|
26ccd9 |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
26ccd9 |
---
|
|
|
26ccd9 |
test/cxl-labels.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
26ccd9 |
test/meson.build | 2 ++
|
|
|
26ccd9 |
2 files changed, 71 insertions(+)
|
|
|
26ccd9 |
create mode 100644 test/cxl-labels.sh
|
|
|
26ccd9 |
|
|
|
26ccd9 |
diff --git a/test/cxl-labels.sh b/test/cxl-labels.sh
|
|
|
26ccd9 |
new file mode 100644
|
|
|
26ccd9 |
index 0000000..e782e2d
|
|
|
26ccd9 |
--- /dev/null
|
|
|
26ccd9 |
+++ b/test/cxl-labels.sh
|
|
|
26ccd9 |
@@ -0,0 +1,69 @@
|
|
|
26ccd9 |
+#!/bin/bash
|
|
|
26ccd9 |
+# SPDX-License-Identifier: GPL-2.0
|
|
|
26ccd9 |
+# Copyright (C) 2022 Intel Corporation. All rights reserved.
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+. $(dirname $0)/common
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+rc=1
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+set -ex
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+trap 'err $LINENO' ERR
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+check_prereq "jq"
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+modprobe -r cxl_test
|
|
|
26ccd9 |
+modprobe cxl_test
|
|
|
26ccd9 |
+udevadm settle
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+test_label_ops()
|
|
|
26ccd9 |
+{
|
|
|
26ccd9 |
+ nmem="$1"
|
|
|
26ccd9 |
+ lsa=$(mktemp /tmp/lsa-$nmem.XXXX)
|
|
|
26ccd9 |
+ lsa_read=$(mktemp /tmp/lsa-read-$nmem.XXXX)
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+ # determine LSA size
|
|
|
26ccd9 |
+ "$NDCTL" read-labels -o "$lsa_read" "$nmem"
|
|
|
26ccd9 |
+ lsa_size=$(stat -c %s "$lsa_read")
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+ dd "if=/dev/urandom" "of=$lsa" "bs=$lsa_size" "count=1"
|
|
|
26ccd9 |
+ "$NDCTL" write-labels -i "$lsa" "$nmem"
|
|
|
26ccd9 |
+ "$NDCTL" read-labels -o "$lsa_read" "$nmem"
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+ # compare what was written vs read
|
|
|
26ccd9 |
+ diff "$lsa" "$lsa_read"
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+ # zero the LSA and test
|
|
|
26ccd9 |
+ "$NDCTL" zero-labels "$nmem"
|
|
|
26ccd9 |
+ dd "if=/dev/zero" "of=$lsa" "bs=$lsa_size" "count=1"
|
|
|
26ccd9 |
+ "$NDCTL" read-labels -o "$lsa_read" "$nmem"
|
|
|
26ccd9 |
+ diff "$lsa" "$lsa_read"
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+ # cleanup
|
|
|
26ccd9 |
+ rm "$lsa" "$lsa_read"
|
|
|
26ccd9 |
+}
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+test_label_ops_cxl()
|
|
|
26ccd9 |
+{
|
|
|
26ccd9 |
+ mem="$1"
|
|
|
26ccd9 |
+ lsa_read=$(mktemp /tmp/lsa-read-$mem.XXXX)
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+ "$CXL" read-labels -o "$lsa_read" "$mem"
|
|
|
26ccd9 |
+ rm "$lsa_read"
|
|
|
26ccd9 |
+}
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+# test reading labels directly through cxl-cli
|
|
|
26ccd9 |
+readarray -t mems < <("$CXL" list -b cxl_test -Mi | jq -r '.[].memdev')
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+for mem in ${mems[@]}; do
|
|
|
26ccd9 |
+ test_label_ops_cxl "$mem"
|
|
|
26ccd9 |
+done
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+# find nmem devices corresponding to cxl memdevs
|
|
|
26ccd9 |
+readarray -t nmems < <("$NDCTL" list -b cxl_test -Di | jq -r '.[].dev')
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+for nmem in ${nmems[@]}; do
|
|
|
26ccd9 |
+ test_label_ops "$nmem"
|
|
|
26ccd9 |
+done
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+modprobe -r cxl_test
|
|
|
26ccd9 |
diff --git a/test/meson.build b/test/meson.build
|
|
|
26ccd9 |
index 3203d9c..b382f46 100644
|
|
|
26ccd9 |
--- a/test/meson.build
|
|
|
26ccd9 |
+++ b/test/meson.build
|
|
|
26ccd9 |
@@ -152,6 +152,7 @@ pfn_meta_errors = find_program('pfn-meta-errors.sh')
|
|
|
26ccd9 |
track_uuid = find_program('track-uuid.sh')
|
|
|
26ccd9 |
cxl_topo = find_program('cxl-topology.sh')
|
|
|
26ccd9 |
cxl_sysfs = find_program('cxl-region-sysfs.sh')
|
|
|
26ccd9 |
+cxl_labels = find_program('cxl-labels.sh')
|
|
|
26ccd9 |
|
|
|
26ccd9 |
tests = [
|
|
|
26ccd9 |
[ 'libndctl', libndctl, 'ndctl' ],
|
|
|
26ccd9 |
@@ -178,6 +179,7 @@ tests = [
|
|
|
26ccd9 |
[ 'track-uuid.sh', track_uuid, 'ndctl' ],
|
|
|
26ccd9 |
[ 'cxl-topology.sh', cxl_topo, 'cxl' ],
|
|
|
26ccd9 |
[ 'cxl-region-sysfs.sh', cxl_sysfs, 'cxl' ],
|
|
|
26ccd9 |
+ [ 'cxl-labels.sh', cxl_labels, 'cxl' ],
|
|
|
26ccd9 |
]
|
|
|
26ccd9 |
|
|
|
26ccd9 |
if get_option('destructive').enabled()
|
|
|
26ccd9 |
--
|
|
|
26ccd9 |
2.27.0
|
|
|
26ccd9 |
|