|
Jeff Moyer |
2c91dc |
From 2e05cd6b4aee656f69e11cf8b5e280dd47a14b1b Mon Sep 17 00:00:00 2001
|
|
Jeff Moyer |
2c91dc |
From: Dan Williams <dan.j.williams@intel.com>
|
|
Jeff Moyer |
2c91dc |
Date: Wed, 5 Jan 2022 13:32:15 -0800
|
|
Jeff Moyer |
2c91dc |
Subject: [PATCH 075/217] ndctl: Deprecate BLK aperture support
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
The kernel is dropping its BLK aperture support, so deprecate the same in
|
|
Jeff Moyer |
2c91dc |
ndctl. The options will still be supported, and the library calls will not
|
|
Jeff Moyer |
2c91dc |
be deleted in case code needs them to compile. However the documentation
|
|
Jeff Moyer |
2c91dc |
and the tests for BLK mode can be removed.
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
Link: https://lore.kernel.org/r/164141833579.3990253.17885822648406789915.stgit@dwillia2-desk3.amr.corp.intel.com
|
|
Jeff Moyer |
2c91dc |
Tested-by: Alison Schofield <alison.schofield@intel.com>
|
|
Jeff Moyer |
2c91dc |
Tested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
|
|
Jeff Moyer |
2c91dc |
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
|
|
Jeff Moyer |
2c91dc |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
Jeff Moyer |
2c91dc |
---
|
|
Jeff Moyer |
2c91dc |
.gitignore | 4 -
|
|
Jeff Moyer |
2c91dc |
Documentation/ndctl/labels-description.txt | 5 +-
|
|
Jeff Moyer |
2c91dc |
.../ndctl/ndctl-create-namespace.txt | 29 +-
|
|
Jeff Moyer |
2c91dc |
Documentation/ndctl/ndctl-init-labels.txt | 7 +-
|
|
Jeff Moyer |
2c91dc |
Documentation/ndctl/ndctl-list.txt | 4 -
|
|
Jeff Moyer |
2c91dc |
Documentation/ndctl/region-description.txt | 10 +-
|
|
Jeff Moyer |
2c91dc |
README.md | 1 -
|
|
Jeff Moyer |
2c91dc |
contrib/nfit_test_depmod.conf | 1 -
|
|
Jeff Moyer |
2c91dc |
ndctl/Makefile.am | 6 +-
|
|
Jeff Moyer |
2c91dc |
ndctl/bat.c | 5 -
|
|
Jeff Moyer |
2c91dc |
ndctl/test.c | 11 -
|
|
Jeff Moyer |
2c91dc |
test.h | 3 -
|
|
Jeff Moyer |
2c91dc |
test/Makefile.am | 31 --
|
|
Jeff Moyer |
2c91dc |
test/blk-exhaust.sh | 30 --
|
|
Jeff Moyer |
2c91dc |
test/blk_namespaces.c | 357 ------------------
|
|
Jeff Moyer |
2c91dc |
test/core.c | 1 -
|
|
Jeff Moyer |
2c91dc |
test/create.sh | 13 -
|
|
Jeff Moyer |
2c91dc |
test/dpa-alloc.c | 326 ----------------
|
|
Jeff Moyer |
2c91dc |
test/libndctl.c | 198 ++--------
|
|
Jeff Moyer |
2c91dc |
test/multi-pmem.c | 285 --------------
|
|
Jeff Moyer |
2c91dc |
test/parent-uuid.c | 254 -------------
|
|
Jeff Moyer |
2c91dc |
21 files changed, 51 insertions(+), 1530 deletions(-)
|
|
Jeff Moyer |
2c91dc |
delete mode 100755 test/blk-exhaust.sh
|
|
Jeff Moyer |
2c91dc |
delete mode 100644 test/blk_namespaces.c
|
|
Jeff Moyer |
2c91dc |
delete mode 100644 test/dpa-alloc.c
|
|
Jeff Moyer |
2c91dc |
delete mode 100644 test/multi-pmem.c
|
|
Jeff Moyer |
2c91dc |
delete mode 100644 test/parent-uuid.c
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
diff --git a/.gitignore b/.gitignore
|
|
Jeff Moyer |
2c91dc |
index 6468c7a..6b19d90 100644
|
|
Jeff Moyer |
2c91dc |
--- a/.gitignore
|
|
Jeff Moyer |
2c91dc |
+++ b/.gitignore
|
|
Jeff Moyer |
2c91dc |
@@ -42,20 +42,16 @@ cscope*.out
|
|
Jeff Moyer |
2c91dc |
tags
|
|
Jeff Moyer |
2c91dc |
test/*.log
|
|
Jeff Moyer |
2c91dc |
test/*.trs
|
|
Jeff Moyer |
2c91dc |
-test/blk-ns
|
|
Jeff Moyer |
2c91dc |
test/dax-dev
|
|
Jeff Moyer |
2c91dc |
test/dax-errors
|
|
Jeff Moyer |
2c91dc |
test/dax-pmd
|
|
Jeff Moyer |
2c91dc |
test/daxdev-errors
|
|
Jeff Moyer |
2c91dc |
test/device-dax
|
|
Jeff Moyer |
2c91dc |
-test/dpa-alloc
|
|
Jeff Moyer |
2c91dc |
test/dsm-fail
|
|
Jeff Moyer |
2c91dc |
test/hugetlb
|
|
Jeff Moyer |
2c91dc |
test/image
|
|
Jeff Moyer |
2c91dc |
test/libndctl
|
|
Jeff Moyer |
2c91dc |
test/mmap
|
|
Jeff Moyer |
2c91dc |
-test/multi-pmem
|
|
Jeff Moyer |
2c91dc |
-test/parent-uuid
|
|
Jeff Moyer |
2c91dc |
test/pmem-ns
|
|
Jeff Moyer |
2c91dc |
test/smart-listen
|
|
Jeff Moyer |
2c91dc |
test/smart-notify
|
|
Jeff Moyer |
2c91dc |
diff --git a/Documentation/ndctl/labels-description.txt b/Documentation/ndctl/labels-description.txt
|
|
Jeff Moyer |
2c91dc |
index 6244a49..a246edc 100644
|
|
Jeff Moyer |
2c91dc |
--- a/Documentation/ndctl/labels-description.txt
|
|
Jeff Moyer |
2c91dc |
+++ b/Documentation/ndctl/labels-description.txt
|
|
Jeff Moyer |
2c91dc |
@@ -3,6 +3,5 @@
|
|
Jeff Moyer |
2c91dc |
DESCRIPTION
|
|
Jeff Moyer |
2c91dc |
-----------
|
|
Jeff Moyer |
2c91dc |
The namespace label area is a small persistent partition of capacity
|
|
Jeff Moyer |
2c91dc |
-available on some NVDIMM devices. The label area is used to resolve
|
|
Jeff Moyer |
2c91dc |
-aliasing between 'pmem' and 'blk' capacity by delineating namespace
|
|
Jeff Moyer |
2c91dc |
-boundaries.
|
|
Jeff Moyer |
2c91dc |
+available on some NVDIMM devices. The label area is used to provision
|
|
Jeff Moyer |
2c91dc |
+one, or more, namespaces from regions.
|
|
Jeff Moyer |
2c91dc |
diff --git a/Documentation/ndctl/ndctl-create-namespace.txt b/Documentation/ndctl/ndctl-create-namespace.txt
|
|
Jeff Moyer |
2c91dc |
index 92a89dd..afb085e 100644
|
|
Jeff Moyer |
2c91dc |
--- a/Documentation/ndctl/ndctl-create-namespace.txt
|
|
Jeff Moyer |
2c91dc |
+++ b/Documentation/ndctl/ndctl-create-namespace.txt
|
|
Jeff Moyer |
2c91dc |
@@ -28,27 +28,17 @@ ndctl create-namespace -f -e namespace0.0 --mode=sector
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
OPTIONS
|
|
Jeff Moyer |
2c91dc |
-------
|
|
Jeff Moyer |
2c91dc |
--t::
|
|
Jeff Moyer |
2c91dc |
---type=::
|
|
Jeff Moyer |
2c91dc |
- Create a 'pmem' or 'blk' namespace (subject to available
|
|
Jeff Moyer |
2c91dc |
- capacity). A pmem namespace supports the dax (direct access)
|
|
Jeff Moyer |
2c91dc |
- capability to linkndctl:mmap[2] persistent memory directly into
|
|
Jeff Moyer |
2c91dc |
- a process address space. A blk namespace access persistent
|
|
Jeff Moyer |
2c91dc |
- memory through a block-window-aperture. Compared to pmem it
|
|
Jeff Moyer |
2c91dc |
- supports a traditional storage error model (EIO on error rather
|
|
Jeff Moyer |
2c91dc |
- than a cpu exception on a bad memory access), but it does not
|
|
Jeff Moyer |
2c91dc |
- support dax.
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-m::
|
|
Jeff Moyer |
2c91dc |
--mode=::
|
|
Jeff Moyer |
2c91dc |
- "raw": expose the namespace capacity directly with
|
|
Jeff Moyer |
2c91dc |
- limitations. Neither a raw pmem namepace nor raw blk
|
|
Jeff Moyer |
2c91dc |
- namespace support sector atomicity by default (see "sector"
|
|
Jeff Moyer |
2c91dc |
- mode below). A raw pmem namespace may have limited to no dax
|
|
Jeff Moyer |
2c91dc |
- support depending the kernel. In other words operations like
|
|
Jeff Moyer |
2c91dc |
- direct-I/O targeting a dax buffer may fail for a pmem
|
|
Jeff Moyer |
2c91dc |
- namespace in raw mode or indirect through a page-cache buffer.
|
|
Jeff Moyer |
2c91dc |
- See "fsdax" and "devdax" mode for dax operation.
|
|
Jeff Moyer |
2c91dc |
+ limitations. A raw pmem namepace namespace does not support
|
|
Jeff Moyer |
2c91dc |
+ sector atomicity (see "sector" mode below). A raw pmem
|
|
Jeff Moyer |
2c91dc |
+ namespace may have limited to no dax support depending the
|
|
Jeff Moyer |
2c91dc |
+ kernel. In other words operations like direct-I/O targeting a
|
|
Jeff Moyer |
2c91dc |
+ dax buffer may fail for a pmem namespace in raw mode or
|
|
Jeff Moyer |
2c91dc |
+ indirect through a page-cache buffer. See "fsdax" and
|
|
Jeff Moyer |
2c91dc |
+ "devdax" mode for dax operation.
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
- "sector": persistent memory, given that it is byte
|
|
Jeff Moyer |
2c91dc |
addressable, does not support sector atomicity. The
|
|
Jeff Moyer |
2c91dc |
@@ -206,8 +196,7 @@ OPTIONS
|
|
Jeff Moyer |
2c91dc |
* NVDIMM does not support labels
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
* The NVDIMM supports labels, but the Label Index Block (see
|
|
Jeff Moyer |
2c91dc |
- UEFI 2.7) is not present and there is no capacity aliasing
|
|
Jeff Moyer |
2c91dc |
- between 'blk' and 'pmem' regions.
|
|
Jeff Moyer |
2c91dc |
+ UEFI 2.7) is not present.
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
- In the latter case the configuration can be upgraded to
|
|
Jeff Moyer |
2c91dc |
labelled operation by writing an index block on all DIMMs in a
|
|
Jeff Moyer |
2c91dc |
diff --git a/Documentation/ndctl/ndctl-init-labels.txt b/Documentation/ndctl/ndctl-init-labels.txt
|
|
Jeff Moyer |
2c91dc |
index 733ef0e..73685b3 100644
|
|
Jeff Moyer |
2c91dc |
--- a/Documentation/ndctl/ndctl-init-labels.txt
|
|
Jeff Moyer |
2c91dc |
+++ b/Documentation/ndctl/ndctl-init-labels.txt
|
|
Jeff Moyer |
2c91dc |
@@ -13,10 +13,9 @@ SYNOPSIS
|
|
Jeff Moyer |
2c91dc |
'ndctl init-labels' <nmem0> [<nmem1>..<nmemN>] [<options>]
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
include::labels-description.txt[]
|
|
Jeff Moyer |
2c91dc |
-By default, and in kernels prior to v4.10, the kernel only honors labels
|
|
Jeff Moyer |
2c91dc |
-when a DIMM aliases PMEM and BLK capacity. Starting with v4.10 the
|
|
Jeff Moyer |
2c91dc |
-kernel will honor labels for sub-dividing PMEM if all the DIMMs in an
|
|
Jeff Moyer |
2c91dc |
-interleave set / region have a valid namespace index block.
|
|
Jeff Moyer |
2c91dc |
+Starting with v4.10 the kernel will honor labels for sub-dividing PMEM
|
|
Jeff Moyer |
2c91dc |
+if all the DIMMs in an interleave set / region have a valid namespace
|
|
Jeff Moyer |
2c91dc |
+index block.
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
This command can be used to initialize the namespace index block if it
|
|
Jeff Moyer |
2c91dc |
is missing or reinitialize it if it is damaged. Note that
|
|
Jeff Moyer |
2c91dc |
diff --git a/Documentation/ndctl/ndctl-list.txt b/Documentation/ndctl/ndctl-list.txt
|
|
Jeff Moyer |
2c91dc |
index b8d517d..2922f10 100644
|
|
Jeff Moyer |
2c91dc |
--- a/Documentation/ndctl/ndctl-list.txt
|
|
Jeff Moyer |
2c91dc |
+++ b/Documentation/ndctl/ndctl-list.txt
|
|
Jeff Moyer |
2c91dc |
@@ -82,10 +82,6 @@ include::xable-bus-options.txt[]
|
|
Jeff Moyer |
2c91dc |
'X.Y'. Limit the namespace list to the single identified device
|
|
Jeff Moyer |
2c91dc |
if present.
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
--t::
|
|
Jeff Moyer |
2c91dc |
---type=::
|
|
Jeff Moyer |
2c91dc |
- Filter listing by region type ('pmem' or 'blk')
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-m::
|
|
Jeff Moyer |
2c91dc |
--mode=::
|
|
Jeff Moyer |
2c91dc |
Filter listing by the mode ('raw', 'fsdax', 'sector' or 'devdax')
|
|
Jeff Moyer |
2c91dc |
diff --git a/Documentation/ndctl/region-description.txt b/Documentation/ndctl/region-description.txt
|
|
Jeff Moyer |
2c91dc |
index c14416a..ce268a0 100644
|
|
Jeff Moyer |
2c91dc |
--- a/Documentation/ndctl/region-description.txt
|
|
Jeff Moyer |
2c91dc |
+++ b/Documentation/ndctl/region-description.txt
|
|
Jeff Moyer |
2c91dc |
@@ -2,9 +2,7 @@
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
DESCRIPTION
|
|
Jeff Moyer |
2c91dc |
-----------
|
|
Jeff Moyer |
2c91dc |
-A generic REGION device is registered for each PMEM range or
|
|
Jeff Moyer |
2c91dc |
-BLK-aperture set. LIBNVDIMM provides a built-in driver for these REGION
|
|
Jeff Moyer |
2c91dc |
-devices. This driver is responsible for reconciling the aliased DPA
|
|
Jeff Moyer |
2c91dc |
-mappings across all regions, parsing the LABEL, if present, and then
|
|
Jeff Moyer |
2c91dc |
-emitting NAMESPACE devices with the resolved/exclusive DPA-boundaries
|
|
Jeff Moyer |
2c91dc |
-for the nd_pmem or nd_blk device driver to consume.
|
|
Jeff Moyer |
2c91dc |
+A generic REGION device is registered for each PMEM range /
|
|
Jeff Moyer |
2c91dc |
+interleave-set. LIBNVDIMM provides a built-in driver for these REGION
|
|
Jeff Moyer |
2c91dc |
+devices. This driver is responsible for parsing namespace labels and
|
|
Jeff Moyer |
2c91dc |
+instantiating PMEM namespaces for each coherent set of labels.
|
|
Jeff Moyer |
2c91dc |
diff --git a/README.md b/README.md
|
|
Jeff Moyer |
2c91dc |
index 89dfc87..6f36a6d 100644
|
|
Jeff Moyer |
2c91dc |
--- a/README.md
|
|
Jeff Moyer |
2c91dc |
+++ b/README.md
|
|
Jeff Moyer |
2c91dc |
@@ -110,7 +110,6 @@ override dax_pmem * extra
|
|
Jeff Moyer |
2c91dc |
override dax_pmem_core * extra
|
|
Jeff Moyer |
2c91dc |
override dax_pmem_compat * extra
|
|
Jeff Moyer |
2c91dc |
override libnvdimm * extra
|
|
Jeff Moyer |
2c91dc |
-override nd_blk * extra
|
|
Jeff Moyer |
2c91dc |
override nd_btt * extra
|
|
Jeff Moyer |
2c91dc |
override nd_e820 * extra
|
|
Jeff Moyer |
2c91dc |
override nd_pmem * extra
|
|
Jeff Moyer |
2c91dc |
diff --git a/contrib/nfit_test_depmod.conf b/contrib/nfit_test_depmod.conf
|
|
Jeff Moyer |
2c91dc |
index 9f8498e..0e0574e 100644
|
|
Jeff Moyer |
2c91dc |
--- a/contrib/nfit_test_depmod.conf
|
|
Jeff Moyer |
2c91dc |
+++ b/contrib/nfit_test_depmod.conf
|
|
Jeff Moyer |
2c91dc |
@@ -5,7 +5,6 @@ override dax_pmem * extra
|
|
Jeff Moyer |
2c91dc |
override dax_pmem_core * extra
|
|
Jeff Moyer |
2c91dc |
override dax_pmem_compat * extra
|
|
Jeff Moyer |
2c91dc |
override libnvdimm * extra
|
|
Jeff Moyer |
2c91dc |
-override nd_blk * extra
|
|
Jeff Moyer |
2c91dc |
override nd_btt * extra
|
|
Jeff Moyer |
2c91dc |
override nd_e820 * extra
|
|
Jeff Moyer |
2c91dc |
override nd_pmem * extra
|
|
Jeff Moyer |
2c91dc |
diff --git a/ndctl/Makefile.am b/ndctl/Makefile.am
|
|
Jeff Moyer |
2c91dc |
index 4e99510..93b682e 100644
|
|
Jeff Moyer |
2c91dc |
--- a/ndctl/Makefile.am
|
|
Jeff Moyer |
2c91dc |
+++ b/ndctl/Makefile.am
|
|
Jeff Moyer |
2c91dc |
@@ -45,8 +45,7 @@ endif
|
|
Jeff Moyer |
2c91dc |
EXTRA_DIST += keys.readme monitor.conf ndctl-monitor.service
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
if ENABLE_DESTRUCTIVE
|
|
Jeff Moyer |
2c91dc |
-ndctl_SOURCES += ../test/blk_namespaces.c \
|
|
Jeff Moyer |
2c91dc |
- ../test/pmem_namespaces.c
|
|
Jeff Moyer |
2c91dc |
+ndctl_SOURCES += ../test/pmem_namespaces.c
|
|
Jeff Moyer |
2c91dc |
ndctl_SOURCES += bat.c
|
|
Jeff Moyer |
2c91dc |
endif
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
@@ -67,9 +66,6 @@ if ENABLE_TEST
|
|
Jeff Moyer |
2c91dc |
ndctl_SOURCES += ../test/libndctl.c \
|
|
Jeff Moyer |
2c91dc |
../test/dsm-fail.c \
|
|
Jeff Moyer |
2c91dc |
../util/sysfs.c \
|
|
Jeff Moyer |
2c91dc |
- ../test/dpa-alloc.c \
|
|
Jeff Moyer |
2c91dc |
- ../test/parent-uuid.c \
|
|
Jeff Moyer |
2c91dc |
- ../test/multi-pmem.c \
|
|
Jeff Moyer |
2c91dc |
../test/core.c \
|
|
Jeff Moyer |
2c91dc |
test.c
|
|
Jeff Moyer |
2c91dc |
endif
|
|
Jeff Moyer |
2c91dc |
diff --git a/ndctl/bat.c b/ndctl/bat.c
|
|
Jeff Moyer |
2c91dc |
index ef00a3b..13e964d 100644
|
|
Jeff Moyer |
2c91dc |
--- a/ndctl/bat.c
|
|
Jeff Moyer |
2c91dc |
+++ b/ndctl/bat.c
|
|
Jeff Moyer |
2c91dc |
@@ -41,11 +41,6 @@ int cmd_bat(int argc, const char **argv, struct ndctl_ctx *ctx)
|
|
Jeff Moyer |
2c91dc |
return EXIT_FAILURE;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
- rc = test_blk_namespaces(loglevel, test, ctx);
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "test_blk_namespaces: %s\n", rc ? "FAIL" : "PASS");
|
|
Jeff Moyer |
2c91dc |
- if (rc && rc != 77)
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
rc = test_pmem_namespaces(loglevel, test, ctx);
|
|
Jeff Moyer |
2c91dc |
fprintf(stderr, "test_pmem_namespaces: %s\n", rc ? "FAIL" : "PASS");
|
|
Jeff Moyer |
2c91dc |
return ndctl_test_result(test, rc);
|
|
Jeff Moyer |
2c91dc |
diff --git a/ndctl/test.c b/ndctl/test.c
|
|
Jeff Moyer |
2c91dc |
index 6a05d8d..a0f5bc9 100644
|
|
Jeff Moyer |
2c91dc |
--- a/ndctl/test.c
|
|
Jeff Moyer |
2c91dc |
+++ b/ndctl/test.c
|
|
Jeff Moyer |
2c91dc |
@@ -58,16 +58,5 @@ int cmd_test(int argc, const char **argv, struct ndctl_ctx *ctx)
|
|
Jeff Moyer |
2c91dc |
if (rc && rc != 77)
|
|
Jeff Moyer |
2c91dc |
return rc;
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
- rc = test_dpa_alloc(loglevel, test, ctx);
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "test-dpa-alloc: %s\n", result(rc));
|
|
Jeff Moyer |
2c91dc |
- if (rc && rc != 77)
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = test_parent_uuid(loglevel, test, ctx);
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "test-parent-uuid: %s\n", result(rc));
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = test_multi_pmem(loglevel, test, ctx);
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "test-multi-pmem: %s\n", result(rc));
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
return ndctl_test_result(test, rc);
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
diff --git a/test.h b/test.h
|
|
Jeff Moyer |
2c91dc |
index 7de13fe..b2267e6 100644
|
|
Jeff Moyer |
2c91dc |
--- a/test.h
|
|
Jeff Moyer |
2c91dc |
+++ b/test.h
|
|
Jeff Moyer |
2c91dc |
@@ -26,7 +26,6 @@ int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
struct ndctl_ctx;
|
|
Jeff Moyer |
2c91dc |
int test_parent_uuid(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
|
|
Jeff Moyer |
2c91dc |
-int test_multi_pmem(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
|
|
Jeff Moyer |
2c91dc |
int test_dax_directio(int dax_fd, unsigned long align, void *dax_addr, off_t offset);
|
|
Jeff Moyer |
2c91dc |
int test_dax_remap(struct ndctl_test *test, int dax_fd, unsigned long align, void *dax_addr,
|
|
Jeff Moyer |
2c91dc |
off_t offset, bool fsdax);
|
|
Jeff Moyer |
2c91dc |
@@ -40,9 +39,7 @@ static inline int test_dax_poison(struct ndctl_test *test, int dax_fd,
|
|
Jeff Moyer |
2c91dc |
return 0;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
#endif
|
|
Jeff Moyer |
2c91dc |
-int test_dpa_alloc(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
|
|
Jeff Moyer |
2c91dc |
int test_dsm_fail(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
|
|
Jeff Moyer |
2c91dc |
int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
|
|
Jeff Moyer |
2c91dc |
-int test_blk_namespaces(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
|
|
Jeff Moyer |
2c91dc |
int test_pmem_namespaces(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
|
|
Jeff Moyer |
2c91dc |
#endif /* __TEST_H__ */
|
|
Jeff Moyer |
2c91dc |
diff --git a/test/Makefile.am b/test/Makefile.am
|
|
Jeff Moyer |
2c91dc |
index c5b8764..a5a54df 100644
|
|
Jeff Moyer |
2c91dc |
--- a/test/Makefile.am
|
|
Jeff Moyer |
2c91dc |
+++ b/test/Makefile.am
|
|
Jeff Moyer |
2c91dc |
@@ -3,9 +3,6 @@ include $(top_srcdir)/Makefile.am.in
|
|
Jeff Moyer |
2c91dc |
TESTS =\
|
|
Jeff Moyer |
2c91dc |
libndctl \
|
|
Jeff Moyer |
2c91dc |
dsm-fail \
|
|
Jeff Moyer |
2c91dc |
- dpa-alloc \
|
|
Jeff Moyer |
2c91dc |
- parent-uuid \
|
|
Jeff Moyer |
2c91dc |
- multi-pmem \
|
|
Jeff Moyer |
2c91dc |
create.sh \
|
|
Jeff Moyer |
2c91dc |
clear.sh \
|
|
Jeff Moyer |
2c91dc |
pmem-errors.sh \
|
|
Jeff Moyer |
2c91dc |
@@ -13,7 +10,6 @@ TESTS =\
|
|
Jeff Moyer |
2c91dc |
multi-dax.sh \
|
|
Jeff Moyer |
2c91dc |
btt-check.sh \
|
|
Jeff Moyer |
2c91dc |
label-compat.sh \
|
|
Jeff Moyer |
2c91dc |
- blk-exhaust.sh \
|
|
Jeff Moyer |
2c91dc |
sector-mode.sh \
|
|
Jeff Moyer |
2c91dc |
inject-error.sh \
|
|
Jeff Moyer |
2c91dc |
btt-errors.sh \
|
|
Jeff Moyer |
2c91dc |
@@ -35,9 +31,6 @@ EXTRA_DIST += $(TESTS) common \
|
|
Jeff Moyer |
2c91dc |
check_PROGRAMS =\
|
|
Jeff Moyer |
2c91dc |
libndctl \
|
|
Jeff Moyer |
2c91dc |
dsm-fail \
|
|
Jeff Moyer |
2c91dc |
- dpa-alloc \
|
|
Jeff Moyer |
2c91dc |
- parent-uuid \
|
|
Jeff Moyer |
2c91dc |
- multi-pmem \
|
|
Jeff Moyer |
2c91dc |
dax-errors \
|
|
Jeff Moyer |
2c91dc |
smart-notify \
|
|
Jeff Moyer |
2c91dc |
smart-listen \
|
|
Jeff Moyer |
2c91dc |
@@ -48,7 +41,6 @@ check_PROGRAMS =\
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
if ENABLE_DESTRUCTIVE
|
|
Jeff Moyer |
2c91dc |
TESTS +=\
|
|
Jeff Moyer |
2c91dc |
- blk-ns \
|
|
Jeff Moyer |
2c91dc |
pmem-ns \
|
|
Jeff Moyer |
2c91dc |
sub-section.sh \
|
|
Jeff Moyer |
2c91dc |
dax-dev \
|
|
Jeff Moyer |
2c91dc |
@@ -68,7 +60,6 @@ TESTS += security.sh
|
|
Jeff Moyer |
2c91dc |
endif
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
check_PROGRAMS +=\
|
|
Jeff Moyer |
2c91dc |
- blk-ns \
|
|
Jeff Moyer |
2c91dc |
pmem-ns \
|
|
Jeff Moyer |
2c91dc |
dax-dev \
|
|
Jeff Moyer |
2c91dc |
dax-pmd \
|
|
Jeff Moyer |
2c91dc |
@@ -108,18 +99,9 @@ ack_shutdown_count_set_SOURCES =\
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
ack_shutdown_count_set_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
-blk_ns_SOURCES = blk_namespaces.c $(testcore)
|
|
Jeff Moyer |
2c91dc |
-blk_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS) $(UUID_LIBS)
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
pmem_ns_SOURCES = pmem_namespaces.c $(testcore)
|
|
Jeff Moyer |
2c91dc |
pmem_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS) $(UUID_LIBS)
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
-dpa_alloc_SOURCES = dpa-alloc.c $(testcore)
|
|
Jeff Moyer |
2c91dc |
-dpa_alloc_LDADD = $(LIBNDCTL_LIB) $(UUID_LIBS) $(KMOD_LIBS)
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-parent_uuid_SOURCES = parent-uuid.c $(testcore)
|
|
Jeff Moyer |
2c91dc |
-parent_uuid_LDADD = $(LIBNDCTL_LIB) $(UUID_LIBS) $(KMOD_LIBS)
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
dax_dev_SOURCES = dax-dev.c $(testcore)
|
|
Jeff Moyer |
2c91dc |
dax_dev_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
@@ -169,19 +151,6 @@ smart_notify_LDADD = $(LIBNDCTL_LIB)
|
|
Jeff Moyer |
2c91dc |
smart_listen_SOURCES = smart-listen.c
|
|
Jeff Moyer |
2c91dc |
smart_listen_LDADD = $(LIBNDCTL_LIB)
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
-multi_pmem_SOURCES = \
|
|
Jeff Moyer |
2c91dc |
- multi-pmem.c \
|
|
Jeff Moyer |
2c91dc |
- $(testcore) \
|
|
Jeff Moyer |
2c91dc |
- ../ndctl/namespace.c \
|
|
Jeff Moyer |
2c91dc |
- ../ndctl/check.c \
|
|
Jeff Moyer |
2c91dc |
- ../util/json.c
|
|
Jeff Moyer |
2c91dc |
-multi_pmem_LDADD = \
|
|
Jeff Moyer |
2c91dc |
- $(LIBNDCTL_LIB) \
|
|
Jeff Moyer |
2c91dc |
- $(JSON_LIBS) \
|
|
Jeff Moyer |
2c91dc |
- $(UUID_LIBS) \
|
|
Jeff Moyer |
2c91dc |
- $(KMOD_LIBS) \
|
|
Jeff Moyer |
2c91dc |
- ../libutil.a
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
list_smart_dimm_SOURCES = \
|
|
Jeff Moyer |
2c91dc |
list-smart-dimm.c \
|
|
Jeff Moyer |
2c91dc |
../util/json.c
|
|
Jeff Moyer |
2c91dc |
diff --git a/test/blk-exhaust.sh b/test/blk-exhaust.sh
|
|
Jeff Moyer |
2c91dc |
deleted file mode 100755
|
|
Jeff Moyer |
2c91dc |
index b6d3808..0000000
|
|
Jeff Moyer |
2c91dc |
--- a/test/blk-exhaust.sh
|
|
Jeff Moyer |
2c91dc |
+++ /dev/null
|
|
Jeff Moyer |
2c91dc |
@@ -1,30 +0,0 @@
|
|
Jeff Moyer |
2c91dc |
-#!/bin/bash -x
|
|
Jeff Moyer |
2c91dc |
-# SPDX-License-Identifier: GPL-2.0
|
|
Jeff Moyer |
2c91dc |
-# Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-set -e
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-rc=77
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-. $(dirname $0)/common
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-check_min_kver "4.11" || do_skip "may lack blk-exhaustion fix"
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-trap 'err $LINENO' ERR
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-# setup (reset nfit_test dimms)
|
|
Jeff Moyer |
2c91dc |
-modprobe nfit_test
|
|
Jeff Moyer |
2c91dc |
-reset
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-# if the kernel accounting is correct we should be able to create two
|
|
Jeff Moyer |
2c91dc |
-# pmem and two blk namespaces on nfit_test.0
|
|
Jeff Moyer |
2c91dc |
-rc=1
|
|
Jeff Moyer |
2c91dc |
-$NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem
|
|
Jeff Moyer |
2c91dc |
-$NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem
|
|
Jeff Moyer |
2c91dc |
-$NDCTL create-namespace -b $NFIT_TEST_BUS0 -t blk -m raw
|
|
Jeff Moyer |
2c91dc |
-$NDCTL create-namespace -b $NFIT_TEST_BUS0 -t blk -m raw
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-# clearnup and exit
|
|
Jeff Moyer |
2c91dc |
-_cleanup
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-exit 0
|
|
Jeff Moyer |
2c91dc |
diff --git a/test/blk_namespaces.c b/test/blk_namespaces.c
|
|
Jeff Moyer |
2c91dc |
deleted file mode 100644
|
|
Jeff Moyer |
2c91dc |
index f076e85..0000000
|
|
Jeff Moyer |
2c91dc |
--- a/test/blk_namespaces.c
|
|
Jeff Moyer |
2c91dc |
+++ /dev/null
|
|
Jeff Moyer |
2c91dc |
@@ -1,357 +0,0 @@
|
|
Jeff Moyer |
2c91dc |
-// SPDX-License-Identifier: LGPL-2.1
|
|
Jeff Moyer |
2c91dc |
-// Copyright (C) 2015-2020, Intel Corporation. All rights reserved.
|
|
Jeff Moyer |
2c91dc |
-#include <errno.h>
|
|
Jeff Moyer |
2c91dc |
-#include <fcntl.h>
|
|
Jeff Moyer |
2c91dc |
-#include <linux/fs.h>
|
|
Jeff Moyer |
2c91dc |
-#include <ndctl/libndctl.h>
|
|
Jeff Moyer |
2c91dc |
-#include <stdio.h>
|
|
Jeff Moyer |
2c91dc |
-#include <stdlib.h>
|
|
Jeff Moyer |
2c91dc |
-#include <string.h>
|
|
Jeff Moyer |
2c91dc |
-#include <sys/ioctl.h>
|
|
Jeff Moyer |
2c91dc |
-#include <syslog.h>
|
|
Jeff Moyer |
2c91dc |
-#include <sys/stat.h>
|
|
Jeff Moyer |
2c91dc |
-#include <sys/types.h>
|
|
Jeff Moyer |
2c91dc |
-#include <ndctl.h>
|
|
Jeff Moyer |
2c91dc |
-#include <unistd.h>
|
|
Jeff Moyer |
2c91dc |
-#include <uuid/uuid.h>
|
|
Jeff Moyer |
2c91dc |
-#include <linux/version.h>
|
|
Jeff Moyer |
2c91dc |
-#include <test.h>
|
|
Jeff Moyer |
2c91dc |
-#include <libkmod.h>
|
|
Jeff Moyer |
2c91dc |
-#include <ccan/array_size/array_size.h>
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-/* The purpose of this test is to verify that we can successfully do I/O to
|
|
Jeff Moyer |
2c91dc |
- * multiple nd_blk namespaces that have discontiguous segments. It first
|
|
Jeff Moyer |
2c91dc |
- * sets up two namespaces, each 1/2 the total size of the NVDIMM and each with
|
|
Jeff Moyer |
2c91dc |
- * two discontiguous segments, arranged like this:
|
|
Jeff Moyer |
2c91dc |
- *
|
|
Jeff Moyer |
2c91dc |
- * +-------+-------+-------+-------+
|
|
Jeff Moyer |
2c91dc |
- * | nd0 | nd1 | nd0 | nd1 |
|
|
Jeff Moyer |
2c91dc |
- * +-------+-------+-------+-------+
|
|
Jeff Moyer |
2c91dc |
- *
|
|
Jeff Moyer |
2c91dc |
- * It then runs some I/O to the beginning, middle and end of each of these
|
|
Jeff Moyer |
2c91dc |
- * namespaces, checking data integrity. The I/O to the middle of the
|
|
Jeff Moyer |
2c91dc |
- * namespace will hit two pages, one on either side of the segment boundary.
|
|
Jeff Moyer |
2c91dc |
- */
|
|
Jeff Moyer |
2c91dc |
-#define err(msg)\
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s:%d: %s (%s)\n", __func__, __LINE__, msg, strerror(errno))
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static struct ndctl_namespace *create_blk_namespace(int region_fraction,
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_region *region)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_namespace *ndns, *seed_ns = NULL;
|
|
Jeff Moyer |
2c91dc |
- unsigned long long size;
|
|
Jeff Moyer |
2c91dc |
- uuid_t uuid;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_set_align(region, sysconf(_SC_PAGESIZE));
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_foreach(region, ndns)
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_get_size(ndns) == 0) {
|
|
Jeff Moyer |
2c91dc |
- seed_ns = ndns;
|
|
Jeff Moyer |
2c91dc |
- break;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!seed_ns)
|
|
Jeff Moyer |
2c91dc |
- return NULL;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- uuid_generate(uuid);
|
|
Jeff Moyer |
2c91dc |
- size = ndctl_region_get_size(region)/region_fraction;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_set_uuid(seed_ns, uuid) < 0)
|
|
Jeff Moyer |
2c91dc |
- return NULL;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_set_size(seed_ns, size) < 0)
|
|
Jeff Moyer |
2c91dc |
- return NULL;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_set_sector_size(seed_ns, 512) < 0)
|
|
Jeff Moyer |
2c91dc |
- return NULL;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_enable(seed_ns) < 0)
|
|
Jeff Moyer |
2c91dc |
- return NULL;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- return seed_ns;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static int disable_blk_namespace(struct ndctl_namespace *ndns)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_disable_invalidate(ndns) < 0)
|
|
Jeff Moyer |
2c91dc |
- return -ENODEV;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_delete(ndns) < 0)
|
|
Jeff Moyer |
2c91dc |
- return -ENODEV;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- return 0;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static int ns_do_io(const char *bdev)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- int fd, i;
|
|
Jeff Moyer |
2c91dc |
- int rc = 0;
|
|
Jeff Moyer |
2c91dc |
- const int page_size = 4096;
|
|
Jeff Moyer |
2c91dc |
- const int num_pages = 4;
|
|
Jeff Moyer |
2c91dc |
- unsigned long num_dev_pages, num_blocks;
|
|
Jeff Moyer |
2c91dc |
- off_t addr;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- void *random_page[num_pages];
|
|
Jeff Moyer |
2c91dc |
- void *blk_page[num_pages];
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = posix_memalign(random_page, page_size, page_size * num_pages);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "posix_memalign failure\n");
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = posix_memalign(blk_page, page_size, page_size * num_pages);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "posix_memalign failure\n");
|
|
Jeff Moyer |
2c91dc |
- goto err_free_blk;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- for (i = 1; i < num_pages; i++) {
|
|
Jeff Moyer |
2c91dc |
- random_page[i] = (char*)random_page[0] + page_size * i;
|
|
Jeff Moyer |
2c91dc |
- blk_page[i] = (char*)blk_page[0] + page_size * i;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* read random data into random_page */
|
|
Jeff Moyer |
2c91dc |
- if ((fd = open("/dev/urandom", O_RDONLY)) < 0) {
|
|
Jeff Moyer |
2c91dc |
- err("open");
|
|
Jeff Moyer |
2c91dc |
- rc = -ENODEV;
|
|
Jeff Moyer |
2c91dc |
- goto err_free_all;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = read(fd, random_page[0], page_size * num_pages);
|
|
Jeff Moyer |
2c91dc |
- if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
- err("read");
|
|
Jeff Moyer |
2c91dc |
- close(fd);
|
|
Jeff Moyer |
2c91dc |
- goto err_free_all;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- close(fd);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if ((fd = open(bdev, O_RDWR|O_DIRECT)) < 0) {
|
|
Jeff Moyer |
2c91dc |
- err("open");
|
|
Jeff Moyer |
2c91dc |
- rc = -ENODEV;
|
|
Jeff Moyer |
2c91dc |
- goto err_free_all;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ioctl(fd, BLKGETSIZE, &num_blocks);
|
|
Jeff Moyer |
2c91dc |
- num_dev_pages = num_blocks / 8;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* write the random data out to each of the segments */
|
|
Jeff Moyer |
2c91dc |
- rc = pwrite(fd, random_page[0], page_size, 0);
|
|
Jeff Moyer |
2c91dc |
- if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
- err("write");
|
|
Jeff Moyer |
2c91dc |
- goto err_close;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* two pages that span the region discontinuity */
|
|
Jeff Moyer |
2c91dc |
- addr = page_size * (num_dev_pages/2 - 1);
|
|
Jeff Moyer |
2c91dc |
- rc = pwrite(fd, random_page[1], page_size*2, addr);
|
|
Jeff Moyer |
2c91dc |
- if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
- err("write");
|
|
Jeff Moyer |
2c91dc |
- goto err_close;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- addr = page_size * (num_dev_pages - 1);
|
|
Jeff Moyer |
2c91dc |
- rc = pwrite(fd, random_page[3], page_size, addr);
|
|
Jeff Moyer |
2c91dc |
- if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
- err("write");
|
|
Jeff Moyer |
2c91dc |
- goto err_close;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* read back the random data into blk_page */
|
|
Jeff Moyer |
2c91dc |
- rc = pread(fd, blk_page[0], page_size, 0);
|
|
Jeff Moyer |
2c91dc |
- if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
- err("read");
|
|
Jeff Moyer |
2c91dc |
- goto err_close;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* two pages that span the region discontinuity */
|
|
Jeff Moyer |
2c91dc |
- addr = page_size * (num_dev_pages/2 - 1);
|
|
Jeff Moyer |
2c91dc |
- rc = pread(fd, blk_page[1], page_size*2, addr);
|
|
Jeff Moyer |
2c91dc |
- if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
- err("read");
|
|
Jeff Moyer |
2c91dc |
- goto err_close;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- addr = page_size * (num_dev_pages - 1);
|
|
Jeff Moyer |
2c91dc |
- rc = pread(fd, blk_page[3], page_size, addr);
|
|
Jeff Moyer |
2c91dc |
- if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
- err("read");
|
|
Jeff Moyer |
2c91dc |
- goto err_close;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* verify the data */
|
|
Jeff Moyer |
2c91dc |
- if (memcmp(random_page[0], blk_page[0], page_size * num_pages)) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "Block data miscompare\n");
|
|
Jeff Moyer |
2c91dc |
- rc = -EIO;
|
|
Jeff Moyer |
2c91dc |
- goto err_close;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = 0;
|
|
Jeff Moyer |
2c91dc |
- err_close:
|
|
Jeff Moyer |
2c91dc |
- close(fd);
|
|
Jeff Moyer |
2c91dc |
- err_free_all:
|
|
Jeff Moyer |
2c91dc |
- free(random_page[0]);
|
|
Jeff Moyer |
2c91dc |
- err_free_blk:
|
|
Jeff Moyer |
2c91dc |
- free(blk_page[0]);
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static const char *comm = "test-blk-namespaces";
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-int test_blk_namespaces(int log_level, struct ndctl_test *test,
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_ctx *ctx)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- char bdev[50];
|
|
Jeff Moyer |
2c91dc |
- int rc = -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_bus *bus;
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_dimm *dimm;
|
|
Jeff Moyer |
2c91dc |
- struct kmod_module *mod = NULL;
|
|
Jeff Moyer |
2c91dc |
- struct kmod_ctx *kmod_ctx = NULL;
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_namespace *ndns[2];
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_region *region, *blk_region = NULL;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 2, 0)))
|
|
Jeff Moyer |
2c91dc |
- return 77;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_set_log_priority(ctx, log_level);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- bus = ndctl_bus_get_by_provider(ctx, "ACPI.NFIT");
|
|
Jeff Moyer |
2c91dc |
- if (bus) {
|
|
Jeff Moyer |
2c91dc |
- /* skip this bus if no BLK regions */
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region)
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_region_get_nstype(region)
|
|
Jeff Moyer |
2c91dc |
- == ND_DEVICE_NAMESPACE_BLK)
|
|
Jeff Moyer |
2c91dc |
- break;
|
|
Jeff Moyer |
2c91dc |
- if (!region)
|
|
Jeff Moyer |
2c91dc |
- bus = NULL;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!bus) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n");
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_test_init(&kmod_ctx, &mod, NULL, log_level, test);
|
|
Jeff Moyer |
2c91dc |
- ndctl_invalidate(ctx);
|
|
Jeff Moyer |
2c91dc |
- bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
|
|
Jeff Moyer |
2c91dc |
- if (rc < 0 || !bus) {
|
|
Jeff Moyer |
2c91dc |
- ndctl_test_skip(test);
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "nfit_test unavailable skipping tests\n");
|
|
Jeff Moyer |
2c91dc |
- return 77;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s: found provider: %s\n", comm,
|
|
Jeff Moyer |
2c91dc |
- ndctl_bus_get_provider(bus));
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* get the system to a clean state */
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region)
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_disable_invalidate(region);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_dimm_foreach(bus, dimm) {
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_dimm_zero_labels(dimm);
|
|
Jeff Moyer |
2c91dc |
- if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to zero %s\n",
|
|
Jeff Moyer |
2c91dc |
- ndctl_dimm_get_devname(dimm));
|
|
Jeff Moyer |
2c91dc |
- goto err_module;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* create our config */
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region)
|
|
Jeff Moyer |
2c91dc |
- if (strcmp(ndctl_region_get_type_name(region), "blk") == 0) {
|
|
Jeff Moyer |
2c91dc |
- blk_region = region;
|
|
Jeff Moyer |
2c91dc |
- break;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!blk_region || ndctl_region_enable(blk_region) < 0) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s: failed to find block region\n", comm);
|
|
Jeff Moyer |
2c91dc |
- rc = -ENODEV;
|
|
Jeff Moyer |
2c91dc |
- goto err_cleanup;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = -ENODEV;
|
|
Jeff Moyer |
2c91dc |
- ndns[0] = create_blk_namespace(4, blk_region);
|
|
Jeff Moyer |
2c91dc |
- if (!ndns[0]) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s: failed to create block namespace\n", comm);
|
|
Jeff Moyer |
2c91dc |
- goto err_cleanup;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndns[1] = create_blk_namespace(4, blk_region);
|
|
Jeff Moyer |
2c91dc |
- if (!ndns[1]) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s: failed to create block namespace\n", comm);
|
|
Jeff Moyer |
2c91dc |
- goto err_cleanup;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = disable_blk_namespace(ndns[0]);
|
|
Jeff Moyer |
2c91dc |
- if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s: failed to disable block namespace\n", comm);
|
|
Jeff Moyer |
2c91dc |
- goto err_cleanup;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndns[0] = create_blk_namespace(2, blk_region);
|
|
Jeff Moyer |
2c91dc |
- if (!ndns[0]) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s: failed to create block namespace\n", comm);
|
|
Jeff Moyer |
2c91dc |
- rc = -ENODEV;
|
|
Jeff Moyer |
2c91dc |
- goto err_cleanup;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = disable_blk_namespace(ndns[1]);
|
|
Jeff Moyer |
2c91dc |
- if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s: failed to disable block namespace\n", comm);
|
|
Jeff Moyer |
2c91dc |
- goto err_cleanup;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = -ENODEV;
|
|
Jeff Moyer |
2c91dc |
- ndns[1] = create_blk_namespace(2, blk_region);
|
|
Jeff Moyer |
2c91dc |
- if (!ndns[1]) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s: failed to create block namespace\n", comm);
|
|
Jeff Moyer |
2c91dc |
- goto err_cleanup;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* okay, all set up, do some I/O */
|
|
Jeff Moyer |
2c91dc |
- rc = -EIO;
|
|
Jeff Moyer |
2c91dc |
- sprintf(bdev, "/dev/%s", ndctl_namespace_get_block_device(ndns[0]));
|
|
Jeff Moyer |
2c91dc |
- if (ns_do_io(bdev))
|
|
Jeff Moyer |
2c91dc |
- goto err_cleanup;
|
|
Jeff Moyer |
2c91dc |
- sprintf(bdev, "/dev/%s", ndctl_namespace_get_block_device(ndns[1]));
|
|
Jeff Moyer |
2c91dc |
- if (ns_do_io(bdev))
|
|
Jeff Moyer |
2c91dc |
- goto err_cleanup;
|
|
Jeff Moyer |
2c91dc |
- rc = 0;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- err_cleanup:
|
|
Jeff Moyer |
2c91dc |
- /* unload nfit_test */
|
|
Jeff Moyer |
2c91dc |
- bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
|
|
Jeff Moyer |
2c91dc |
- if (bus)
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region)
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_disable_invalidate(region);
|
|
Jeff Moyer |
2c91dc |
- bus = ndctl_bus_get_by_provider(ctx, "nfit_test.1");
|
|
Jeff Moyer |
2c91dc |
- if (bus)
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region)
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_disable_invalidate(region);
|
|
Jeff Moyer |
2c91dc |
- if (mod)
|
|
Jeff Moyer |
2c91dc |
- kmod_module_remove_module(mod, 0);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- err_module:
|
|
Jeff Moyer |
2c91dc |
- if (kmod_ctx)
|
|
Jeff Moyer |
2c91dc |
- kmod_unref(kmod_ctx);
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-int __attribute__((weak)) main(int argc, char *argv[])
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_test *test = ndctl_test_new(0);
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_ctx *ctx;
|
|
Jeff Moyer |
2c91dc |
- int rc;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- comm = argv[0];
|
|
Jeff Moyer |
2c91dc |
- if (!test) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to initialize test\n");
|
|
Jeff Moyer |
2c91dc |
- return EXIT_FAILURE;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_new(&ctx;;
|
|
Jeff Moyer |
2c91dc |
- if (rc)
|
|
Jeff Moyer |
2c91dc |
- return ndctl_test_result(test, rc);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = test_blk_namespaces(LOG_DEBUG, test, ctx);
|
|
Jeff Moyer |
2c91dc |
- ndctl_unref(ctx);
|
|
Jeff Moyer |
2c91dc |
- return ndctl_test_result(test, rc);
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
diff --git a/test/core.c b/test/core.c
|
|
Jeff Moyer |
2c91dc |
index 93e1dae..dc1405d 100644
|
|
Jeff Moyer |
2c91dc |
--- a/test/core.c
|
|
Jeff Moyer |
2c91dc |
+++ b/test/core.c
|
|
Jeff Moyer |
2c91dc |
@@ -123,7 +123,6 @@ int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
|
|
Jeff Moyer |
2c91dc |
"dax_pmem_core",
|
|
Jeff Moyer |
2c91dc |
"dax_pmem_compat",
|
|
Jeff Moyer |
2c91dc |
"libnvdimm",
|
|
Jeff Moyer |
2c91dc |
- "nd_blk",
|
|
Jeff Moyer |
2c91dc |
"nd_btt",
|
|
Jeff Moyer |
2c91dc |
"nd_e820",
|
|
Jeff Moyer |
2c91dc |
"nd_pmem",
|
|
Jeff Moyer |
2c91dc |
diff --git a/test/create.sh b/test/create.sh
|
|
Jeff Moyer |
2c91dc |
index e9baaa0..9a6f373 100755
|
|
Jeff Moyer |
2c91dc |
--- a/test/create.sh
|
|
Jeff Moyer |
2c91dc |
+++ b/test/create.sh
|
|
Jeff Moyer |
2c91dc |
@@ -40,19 +40,6 @@ eval $(echo $json | json2var)
|
|
Jeff Moyer |
2c91dc |
# free capacity for blk creation
|
|
Jeff Moyer |
2c91dc |
$NDCTL destroy-namespace -f $dev
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
-# create blk
|
|
Jeff Moyer |
2c91dc |
-dev="x"
|
|
Jeff Moyer |
2c91dc |
-json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t blk -m raw -v)
|
|
Jeff Moyer |
2c91dc |
-eval $(echo $json | json2var)
|
|
Jeff Moyer |
2c91dc |
-[ $dev = "x" ] && echo "fail: $LINENO" && exit 1
|
|
Jeff Moyer |
2c91dc |
-[ $mode != "raw" ] && echo "fail: $LINENO" && exit 1
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-# convert blk to sector mode
|
|
Jeff Moyer |
2c91dc |
-json=$($NDCTL create-namespace -m sector -l $SECTOR_SIZE -f -e $dev)
|
|
Jeff Moyer |
2c91dc |
-eval $(echo $json | json2var)
|
|
Jeff Moyer |
2c91dc |
-[ $sector_size != $SECTOR_SIZE ] && echo "fail: $LINENO" && exit 1
|
|
Jeff Moyer |
2c91dc |
-[ $mode != "sector" ] && echo "fail: $LINENO" && exit 1
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
_cleanup
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
exit 0
|
|
Jeff Moyer |
2c91dc |
diff --git a/test/dpa-alloc.c b/test/dpa-alloc.c
|
|
Jeff Moyer |
2c91dc |
deleted file mode 100644
|
|
Jeff Moyer |
2c91dc |
index 59185cf..0000000
|
|
Jeff Moyer |
2c91dc |
--- a/test/dpa-alloc.c
|
|
Jeff Moyer |
2c91dc |
+++ /dev/null
|
|
Jeff Moyer |
2c91dc |
@@ -1,326 +0,0 @@
|
|
Jeff Moyer |
2c91dc |
-// SPDX-License-Identifier: LGPL-2.1
|
|
Jeff Moyer |
2c91dc |
-// Copyright (C) 2014-2020, Intel Corporation. All rights reserved.
|
|
Jeff Moyer |
2c91dc |
-#include <stdio.h>
|
|
Jeff Moyer |
2c91dc |
-#include <stddef.h>
|
|
Jeff Moyer |
2c91dc |
-#include <stdlib.h>
|
|
Jeff Moyer |
2c91dc |
-#include <string.h>
|
|
Jeff Moyer |
2c91dc |
-#include <fcntl.h>
|
|
Jeff Moyer |
2c91dc |
-#include <ctype.h>
|
|
Jeff Moyer |
2c91dc |
-#include <errno.h>
|
|
Jeff Moyer |
2c91dc |
-#include <unistd.h>
|
|
Jeff Moyer |
2c91dc |
-#include <limits.h>
|
|
Jeff Moyer |
2c91dc |
-#include <syslog.h>
|
|
Jeff Moyer |
2c91dc |
-#include <libkmod.h>
|
|
Jeff Moyer |
2c91dc |
-#include <uuid/uuid.h>
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-#include <test.h>
|
|
Jeff Moyer |
2c91dc |
-#include <ndctl.h>
|
|
Jeff Moyer |
2c91dc |
-#include <util/size.h>
|
|
Jeff Moyer |
2c91dc |
-#include <linux/version.h>
|
|
Jeff Moyer |
2c91dc |
-#include <ndctl/libndctl.h>
|
|
Jeff Moyer |
2c91dc |
-#include <ccan/array_size/array_size.h>
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static const char *NFIT_PROVIDER0 = "nfit_test.0";
|
|
Jeff Moyer |
2c91dc |
-static const char *NFIT_PROVIDER1 = "nfit_test.1";
|
|
Jeff Moyer |
2c91dc |
-#define NUM_NAMESPACES 4
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-struct test_dpa_namespace {
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_namespace *ndns;
|
|
Jeff Moyer |
2c91dc |
- unsigned long long size;
|
|
Jeff Moyer |
2c91dc |
- uuid_t uuid;
|
|
Jeff Moyer |
2c91dc |
-} namespaces[NUM_NAMESPACES];
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-#define MIN_SIZE SZ_4M
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- unsigned int default_available_slots, available_slots, i;
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_region *region, *blk_region = NULL;
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_namespace *ndns;
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_dimm *dimm;
|
|
Jeff Moyer |
2c91dc |
- unsigned long size, page_size;
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_bus *bus;
|
|
Jeff Moyer |
2c91dc |
- char uuid_str[40];
|
|
Jeff Moyer |
2c91dc |
- int round;
|
|
Jeff Moyer |
2c91dc |
- int rc;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- page_size = sysconf(_SC_PAGESIZE);
|
|
Jeff Moyer |
2c91dc |
- /* disable nfit_test.1, not used in this test */
|
|
Jeff Moyer |
2c91dc |
- bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER1);
|
|
Jeff Moyer |
2c91dc |
- if (!bus)
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region) {
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_disable_invalidate(region);
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_set_align(region, sysconf(_SC_PAGESIZE)
|
|
Jeff Moyer |
2c91dc |
- * ndctl_region_get_interleave_ways(region));
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* init nfit_test.0 */
|
|
Jeff Moyer |
2c91dc |
- bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER0);
|
|
Jeff Moyer |
2c91dc |
- if (!bus)
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region) {
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_disable_invalidate(region);
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_set_align(region, sysconf(_SC_PAGESIZE)
|
|
Jeff Moyer |
2c91dc |
- * ndctl_region_get_interleave_ways(region));
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_dimm_foreach(bus, dimm) {
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_dimm_zero_labels(dimm);
|
|
Jeff Moyer |
2c91dc |
- if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to zero %s\n",
|
|
Jeff Moyer |
2c91dc |
- ndctl_dimm_get_devname(dimm));
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /*
|
|
Jeff Moyer |
2c91dc |
- * Find a guineapig BLK region, we know that the dimm with
|
|
Jeff Moyer |
2c91dc |
- * handle==0 from nfit_test.0 always allocates from highest DPA
|
|
Jeff Moyer |
2c91dc |
- * to lowest with no excursions into BLK only ranges.
|
|
Jeff Moyer |
2c91dc |
- */
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region) {
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_region_get_type(region) != ND_DEVICE_REGION_BLK)
|
|
Jeff Moyer |
2c91dc |
- continue;
|
|
Jeff Moyer |
2c91dc |
- dimm = ndctl_region_get_first_dimm(region);
|
|
Jeff Moyer |
2c91dc |
- if (!dimm)
|
|
Jeff Moyer |
2c91dc |
- continue;
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_dimm_get_handle(dimm) == 0) {
|
|
Jeff Moyer |
2c91dc |
- blk_region = region;
|
|
Jeff Moyer |
2c91dc |
- break;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- if (!blk_region || ndctl_region_enable(blk_region) < 0) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to find a usable BLK region\n");
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- region = blk_region;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_region_get_available_size(region) / MIN_SIZE < NUM_NAMESPACES) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s insufficient available_size\n",
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_get_devname(region));
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- default_available_slots = ndctl_dimm_get_available_labels(dimm);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* grow namespaces */
|
|
Jeff Moyer |
2c91dc |
- for (i = 0; i < ARRAY_SIZE(namespaces); i++) {
|
|
Jeff Moyer |
2c91dc |
- uuid_t uuid;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndns = ndctl_region_get_namespace_seed(region);
|
|
Jeff Moyer |
2c91dc |
- if (!ndns) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s: failed to get seed: %d\n",
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_get_devname(region), i);
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- uuid_generate_random(uuid);
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_set_uuid(ndns, uuid);
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_set_sector_size(ndns, 512);
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_set_size(ndns, MIN_SIZE);
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_namespace_enable(ndns);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to enable %s: %d\n",
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_get_devname(ndns), rc);
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_disable_invalidate(ndns);
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_namespace_set_size(ndns, page_size);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to init %s to size: %lu\n",
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_get_devname(ndns),
|
|
Jeff Moyer |
2c91dc |
- page_size);
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- namespaces[i].ndns = ndns;
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_get_uuid(ndns, namespaces[i].uuid);
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- available_slots = ndctl_dimm_get_available_labels(dimm);
|
|
Jeff Moyer |
2c91dc |
- if (available_slots != default_available_slots
|
|
Jeff Moyer |
2c91dc |
- - ARRAY_SIZE(namespaces)) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "expected %ld slots available\n",
|
|
Jeff Moyer |
2c91dc |
- default_available_slots
|
|
Jeff Moyer |
2c91dc |
- - ARRAY_SIZE(namespaces));
|
|
Jeff Moyer |
2c91dc |
- return -ENOSPC;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* exhaust label space, by round-robin allocating 4K */
|
|
Jeff Moyer |
2c91dc |
- round = 1;
|
|
Jeff Moyer |
2c91dc |
- for (i = 0; i < available_slots; i++) {
|
|
Jeff Moyer |
2c91dc |
- ndns = namespaces[i % ARRAY_SIZE(namespaces)].ndns;
|
|
Jeff Moyer |
2c91dc |
- if (i % ARRAY_SIZE(namespaces) == 0)
|
|
Jeff Moyer |
2c91dc |
- round++;
|
|
Jeff Moyer |
2c91dc |
- size = page_size * round;
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_namespace_set_size(ndns, size);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s: set_size: %lx failed: %d\n",
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_get_devname(ndns), size, rc);
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /*
|
|
Jeff Moyer |
2c91dc |
- * The last namespace we updated should still be modifiable via
|
|
Jeff Moyer |
2c91dc |
- * the kernel's reserve label
|
|
Jeff Moyer |
2c91dc |
- */
|
|
Jeff Moyer |
2c91dc |
- i--;
|
|
Jeff Moyer |
2c91dc |
- round++;
|
|
Jeff Moyer |
2c91dc |
- ndns = namespaces[i % ARRAY_SIZE(namespaces)].ndns;
|
|
Jeff Moyer |
2c91dc |
- size = page_size * round;
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_namespace_set_size(ndns, size);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s failed to update while labels full\n",
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_get_devname(ndns));
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- round--;
|
|
Jeff Moyer |
2c91dc |
- size = page_size * round;
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_namespace_set_size(ndns, size);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s failed to reduce size while labels full\n",
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_get_devname(ndns));
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* do the allocations survive a region cycle? */
|
|
Jeff Moyer |
2c91dc |
- for (i = 0; i < ARRAY_SIZE(namespaces); i++) {
|
|
Jeff Moyer |
2c91dc |
- ndns = namespaces[i].ndns;
|
|
Jeff Moyer |
2c91dc |
- namespaces[i].size = ndctl_namespace_get_size(ndns);
|
|
Jeff Moyer |
2c91dc |
- namespaces[i].ndns = NULL;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_disable_invalidate(region);
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_region_enable(region);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to re-enable %s: %d\n",
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_get_devname(region), rc);
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_foreach(region, ndns) {
|
|
Jeff Moyer |
2c91dc |
- uuid_t uuid;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_get_uuid(ndns, uuid);
|
|
Jeff Moyer |
2c91dc |
- for (i = 0; i < ARRAY_SIZE(namespaces); i++) {
|
|
Jeff Moyer |
2c91dc |
- if (uuid_compare(uuid, namespaces[i].uuid) == 0) {
|
|
Jeff Moyer |
2c91dc |
- namespaces[i].ndns = ndns;
|
|
Jeff Moyer |
2c91dc |
- break;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* validate that they all came back */
|
|
Jeff Moyer |
2c91dc |
- for (i = 0; i < ARRAY_SIZE(namespaces); i++) {
|
|
Jeff Moyer |
2c91dc |
- ndns = namespaces[i].ndns;
|
|
Jeff Moyer |
2c91dc |
- size = ndns ? ndctl_namespace_get_size(ndns) : 0;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (ndns && size == namespaces[i].size)
|
|
Jeff Moyer |
2c91dc |
- continue;
|
|
Jeff Moyer |
2c91dc |
- uuid_unparse(namespaces[i].uuid, uuid_str);
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to recover %s\n", uuid_str);
|
|
Jeff Moyer |
2c91dc |
- return -ENODEV;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* test deletion and merging */
|
|
Jeff Moyer |
2c91dc |
- ndns = namespaces[0].ndns;
|
|
Jeff Moyer |
2c91dc |
- for (i = 1; i < ARRAY_SIZE(namespaces); i++) {
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_namespace *victim = namespaces[i].ndns;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- uuid_unparse(namespaces[i].uuid, uuid_str);
|
|
Jeff Moyer |
2c91dc |
- size = ndctl_namespace_get_size(victim);
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_namespace_disable(victim);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to disable %s\n", uuid_str);
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_namespace_delete(victim);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to delete %s\n", uuid_str);
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- size += ndctl_namespace_get_size(ndns);
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_namespace_set_size(ndns, size);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to merge %s\n", uuid_str);
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* there can be only one */
|
|
Jeff Moyer |
2c91dc |
- i = 0;
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_foreach(region, ndns) {
|
|
Jeff Moyer |
2c91dc |
- unsigned long long sz = ndctl_namespace_get_size(ndns);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (sz) {
|
|
Jeff Moyer |
2c91dc |
- i++;
|
|
Jeff Moyer |
2c91dc |
- if (sz == size)
|
|
Jeff Moyer |
2c91dc |
- continue;
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s size: %llx expected %lx\n",
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_get_devname(ndns),
|
|
Jeff Moyer |
2c91dc |
- sz, size);
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- if (i != 1) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to delete namespaces\n");
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- available_slots = ndctl_dimm_get_available_labels(dimm);
|
|
Jeff Moyer |
2c91dc |
- if (available_slots != default_available_slots - 1) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "mishandled slot count\n");
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region)
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_disable_invalidate(region);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- return 0;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-int test_dpa_alloc(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct kmod_module *mod;
|
|
Jeff Moyer |
2c91dc |
- struct kmod_ctx *kmod_ctx;
|
|
Jeff Moyer |
2c91dc |
- int err, result = EXIT_FAILURE;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 2, 0)))
|
|
Jeff Moyer |
2c91dc |
- return 77;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_set_log_priority(ctx, loglevel);
|
|
Jeff Moyer |
2c91dc |
- err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
|
|
Jeff Moyer |
2c91dc |
- if (err < 0) {
|
|
Jeff Moyer |
2c91dc |
- ndctl_test_skip(test);
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "nfit_test unavailable skipping tests\n");
|
|
Jeff Moyer |
2c91dc |
- return 77;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- err = do_test(ctx, test);
|
|
Jeff Moyer |
2c91dc |
- if (err == 0)
|
|
Jeff Moyer |
2c91dc |
- result = EXIT_SUCCESS;
|
|
Jeff Moyer |
2c91dc |
- kmod_module_remove_module(mod, 0);
|
|
Jeff Moyer |
2c91dc |
- kmod_unref(kmod_ctx);
|
|
Jeff Moyer |
2c91dc |
- return result;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-int __attribute__((weak)) main(int argc, char *argv[])
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_test *test = ndctl_test_new(0);
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_ctx *ctx;
|
|
Jeff Moyer |
2c91dc |
- int rc;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!test) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to initialize test\n");
|
|
Jeff Moyer |
2c91dc |
- return EXIT_FAILURE;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_new(&ctx;;
|
|
Jeff Moyer |
2c91dc |
- if (rc)
|
|
Jeff Moyer |
2c91dc |
- return ndctl_test_result(test, rc);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = test_dpa_alloc(LOG_DEBUG, test, ctx);
|
|
Jeff Moyer |
2c91dc |
- ndctl_unref(ctx);
|
|
Jeff Moyer |
2c91dc |
- return ndctl_test_result(test, rc);
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
diff --git a/test/libndctl.c b/test/libndctl.c
|
|
Jeff Moyer |
2c91dc |
index 1e97926..35e7cfa 100644
|
|
Jeff Moyer |
2c91dc |
--- a/test/libndctl.c
|
|
Jeff Moyer |
2c91dc |
+++ b/test/libndctl.c
|
|
Jeff Moyer |
2c91dc |
@@ -30,46 +30,35 @@
|
|
Jeff Moyer |
2c91dc |
/*
|
|
Jeff Moyer |
2c91dc |
* Kernel provider "nfit_test.0" produces an NFIT with the following attributes:
|
|
Jeff Moyer |
2c91dc |
*
|
|
Jeff Moyer |
2c91dc |
- * (a) (b) DIMM BLK-REGION
|
|
Jeff Moyer |
2c91dc |
- * +-------------------+--------+--------+--------+
|
|
Jeff Moyer |
2c91dc |
- * +------+ | pm0.0 | blk2.0 | pm1.0 | blk2.1 | 0 region2
|
|
Jeff Moyer |
2c91dc |
- * | imc0 +--+- - - region0- - - +--------+ +--------+
|
|
Jeff Moyer |
2c91dc |
- * +--+---+ | pm0.0 | blk3.0 | pm1.0 | blk3.1 | 1 region3
|
|
Jeff Moyer |
2c91dc |
- * | +-------------------+--------v v--------+
|
|
Jeff Moyer |
2c91dc |
- * +--+---+ | |
|
|
Jeff Moyer |
2c91dc |
- * | cpu0 | region1
|
|
Jeff Moyer |
2c91dc |
- * +--+---+ | |
|
|
Jeff Moyer |
2c91dc |
- * | +----------------------------^ ^--------+
|
|
Jeff Moyer |
2c91dc |
- * +--+---+ | blk4.0 | pm1.0 | blk4.0 | 2 region4
|
|
Jeff Moyer |
2c91dc |
- * | imc1 +--+----------------------------| +--------+
|
|
Jeff Moyer |
2c91dc |
- * +------+ | blk5.0 | pm1.0 | blk5.0 | 3 region5
|
|
Jeff Moyer |
2c91dc |
- * +----------------------------+--------+--------+
|
|
Jeff Moyer |
2c91dc |
+ * (a) (b) DIMM
|
|
Jeff Moyer |
2c91dc |
+ * +-------------------+--------+--------+--------+
|
|
Jeff Moyer |
2c91dc |
+ * +------+ | pm0.0 | free | pm1.0 | free | 0
|
|
Jeff Moyer |
2c91dc |
+ * | imc0 +--+- - - region0- - - +--------+ +--------+
|
|
Jeff Moyer |
2c91dc |
+ * +--+---+ | pm0.0 | free | pm1.0 | free | 1
|
|
Jeff Moyer |
2c91dc |
+ * | +-------------------+--------v v--------+
|
|
Jeff Moyer |
2c91dc |
+ * +--+---+ | |
|
|
Jeff Moyer |
2c91dc |
+ * | cpu0 | region1
|
|
Jeff Moyer |
2c91dc |
+ * +--+---+ | |
|
|
Jeff Moyer |
2c91dc |
+ * | +----------------------------^ ^--------+
|
|
Jeff Moyer |
2c91dc |
+ * +--+---+ | free | pm1.0 | free | 2
|
|
Jeff Moyer |
2c91dc |
+ * | imc1 +--+----------------------------| +--------+
|
|
Jeff Moyer |
2c91dc |
+ * +------+ | free | pm1.0 | free | 3
|
|
Jeff Moyer |
2c91dc |
+ * +----------------------------+--------+--------+
|
|
Jeff Moyer |
2c91dc |
*
|
|
Jeff Moyer |
2c91dc |
- * *) In this layout we have four dimms and two memory controllers in one
|
|
Jeff Moyer |
2c91dc |
- * socket. Each unique interface ("blk" or "pmem") to DPA space
|
|
Jeff Moyer |
2c91dc |
- * is identified by a region device with a dynamically assigned id.
|
|
Jeff Moyer |
2c91dc |
+ * In this platform we have four DIMMs and two memory controllers in one
|
|
Jeff Moyer |
2c91dc |
+ * socket. Each PMEM interleave set is identified by a region device with
|
|
Jeff Moyer |
2c91dc |
+ * a dynamically assigned id.
|
|
Jeff Moyer |
2c91dc |
*
|
|
Jeff Moyer |
2c91dc |
- * *) The first portion of dimm0 and dimm1 are interleaved as REGION0.
|
|
Jeff Moyer |
2c91dc |
- * A single "pmem" namespace is created in the REGION0-"spa"-range
|
|
Jeff Moyer |
2c91dc |
- * that spans dimm0 and dimm1 with a user-specified name of "pm0.0".
|
|
Jeff Moyer |
2c91dc |
- * Some of that interleaved "spa" range is reclaimed as "bdw"
|
|
Jeff Moyer |
2c91dc |
- * accessed space starting at offset (a) into each dimm. In that
|
|
Jeff Moyer |
2c91dc |
- * reclaimed space we create two "bdw" "namespaces" from REGION2 and
|
|
Jeff Moyer |
2c91dc |
- * REGION3 where "blk2.0" and "blk3.0" are just human readable names
|
|
Jeff Moyer |
2c91dc |
- * that could be set to any user-desired name in the label.
|
|
Jeff Moyer |
2c91dc |
+ * 1. The first portion of DIMM0 and DIMM1 are interleaved as REGION0. A
|
|
Jeff Moyer |
2c91dc |
+ * single PMEM namespace is created in the REGION0-SPA-range that spans most
|
|
Jeff Moyer |
2c91dc |
+ * of DIMM0 and DIMM1 with a user-specified name of "pm0.0". Some of that
|
|
Jeff Moyer |
2c91dc |
+ * interleaved system-physical-address range is left free for
|
|
Jeff Moyer |
2c91dc |
+ * another PMEM namespace to be defined.
|
|
Jeff Moyer |
2c91dc |
*
|
|
Jeff Moyer |
2c91dc |
- * *) In the last portion of dimm0 and dimm1 we have an interleaved
|
|
Jeff Moyer |
2c91dc |
- * "spa" range, REGION1, that spans those two dimms as well as dimm2
|
|
Jeff Moyer |
2c91dc |
- * and dimm3. Some of REGION1 allocated to a "pmem" namespace named
|
|
Jeff Moyer |
2c91dc |
- * "pm1.0" the rest is reclaimed in 4 "bdw" namespaces (for each
|
|
Jeff Moyer |
2c91dc |
- * dimm in the interleave set), "blk2.1", "blk3.1", "blk4.0", and
|
|
Jeff Moyer |
2c91dc |
- * "blk5.0".
|
|
Jeff Moyer |
2c91dc |
- *
|
|
Jeff Moyer |
2c91dc |
- * *) The portion of dimm2 and dimm3 that do not participate in the
|
|
Jeff Moyer |
2c91dc |
- * REGION1 interleaved "spa" range (i.e. the DPA address below
|
|
Jeff Moyer |
2c91dc |
- * offset (b) are also included in the "blk4.0" and "blk5.0"
|
|
Jeff Moyer |
2c91dc |
- * namespaces. Note, that this example shows that "bdw" namespaces
|
|
Jeff Moyer |
2c91dc |
- * don't need to be contiguous in DPA-space.
|
|
Jeff Moyer |
2c91dc |
+ * 2. In the last portion of DIMM0 and DIMM1 we have an interleaved
|
|
Jeff Moyer |
2c91dc |
+ * system-physical-address range, REGION1, that spans those two DIMMs as
|
|
Jeff Moyer |
2c91dc |
+ * well as DIMM2 and DIMM3. Some of REGION1 is allocated to a PMEM namespace
|
|
Jeff Moyer |
2c91dc |
+ * named "pm1.0".
|
|
Jeff Moyer |
2c91dc |
*
|
|
Jeff Moyer |
2c91dc |
* Kernel provider "nfit_test.1" produces an NFIT with the following attributes:
|
|
Jeff Moyer |
2c91dc |
*
|
|
Jeff Moyer |
2c91dc |
@@ -127,10 +116,10 @@ struct dimm {
|
|
Jeff Moyer |
2c91dc |
(((n & 0xfff) << 16) | ((s & 0xf) << 12) | ((i & 0xf) << 8) \
|
|
Jeff Moyer |
2c91dc |
| ((c & 0xf) << 4) | (d & 0xf))
|
|
Jeff Moyer |
2c91dc |
static struct dimm dimms0[] = {
|
|
Jeff Moyer |
2c91dc |
- { DIMM_HANDLE(0, 0, 0, 0, 0), 0, 0, 2016, 10, 42, { 0 }, 2, { 0x201, 0x301, }, },
|
|
Jeff Moyer |
2c91dc |
- { DIMM_HANDLE(0, 0, 0, 0, 1), 1, 0, 2016, 10, 42, { 0 }, 2, { 0x201, 0x301, }, },
|
|
Jeff Moyer |
2c91dc |
- { DIMM_HANDLE(0, 0, 1, 0, 0), 2, 0, 2016, 10, 42, { 0 }, 2, { 0x201, 0x301, }, },
|
|
Jeff Moyer |
2c91dc |
- { DIMM_HANDLE(0, 0, 1, 0, 1), 3, 0, 2016, 10, 42, { 0 }, 2, { 0x201, 0x301, }, },
|
|
Jeff Moyer |
2c91dc |
+ { DIMM_HANDLE(0, 0, 0, 0, 0), 0, 0, 2016, 10, 42, { 0 }, 1, { 0x201, }, },
|
|
Jeff Moyer |
2c91dc |
+ { DIMM_HANDLE(0, 0, 0, 0, 1), 1, 0, 2016, 10, 42, { 0 }, 1, { 0x201, }, },
|
|
Jeff Moyer |
2c91dc |
+ { DIMM_HANDLE(0, 0, 1, 0, 0), 2, 0, 2016, 10, 42, { 0 }, 1, { 0x201, }, },
|
|
Jeff Moyer |
2c91dc |
+ { DIMM_HANDLE(0, 0, 1, 0, 1), 3, 0, 2016, 10, 42, { 0 }, 1, { 0x201, }, },
|
|
Jeff Moyer |
2c91dc |
};
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
static struct dimm dimms1[] = {
|
|
Jeff Moyer |
2c91dc |
@@ -240,7 +229,6 @@ struct namespace {
|
|
Jeff Moyer |
2c91dc |
};
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
static uuid_t null_uuid;
|
|
Jeff Moyer |
2c91dc |
-static unsigned long blk_sector_sizes[] = { 512, 520, 528, 4096, 4104, 4160, 4224, };
|
|
Jeff Moyer |
2c91dc |
static unsigned long pmem_sector_sizes[] = { 512, 4096 };
|
|
Jeff Moyer |
2c91dc |
static unsigned long io_sector_sizes[] = { 0 };
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
@@ -262,60 +250,6 @@ static struct namespace namespace1_pmem0 = {
|
|
Jeff Moyer |
2c91dc |
ARRAY_SIZE(pmem_sector_sizes), pmem_sector_sizes,
|
|
Jeff Moyer |
2c91dc |
};
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
-static struct namespace namespace2_blk0 = {
|
|
Jeff Moyer |
2c91dc |
- 0, "namespace_blk", NULL, NULL, NULL, SZ_7M,
|
|
Jeff Moyer |
2c91dc |
- { 3, 3, 3, 3,
|
|
Jeff Moyer |
2c91dc |
- 3, 3, 3, 3,
|
|
Jeff Moyer |
2c91dc |
- 3, 3, 3, 3,
|
|
Jeff Moyer |
2c91dc |
- 3, 3, 3, 3, }, 1, 1, 0,
|
|
Jeff Moyer |
2c91dc |
- ARRAY_SIZE(blk_sector_sizes), blk_sector_sizes,
|
|
Jeff Moyer |
2c91dc |
-};
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static struct namespace namespace2_blk1 = {
|
|
Jeff Moyer |
2c91dc |
- 1, "namespace_blk", NULL, NULL, NULL, SZ_11M,
|
|
Jeff Moyer |
2c91dc |
- { 4, 4, 4, 4,
|
|
Jeff Moyer |
2c91dc |
- 4, 4, 4, 4,
|
|
Jeff Moyer |
2c91dc |
- 4, 4, 4, 4,
|
|
Jeff Moyer |
2c91dc |
- 4, 4, 4, 4, }, 1, 1, 0,
|
|
Jeff Moyer |
2c91dc |
- ARRAY_SIZE(blk_sector_sizes), blk_sector_sizes,
|
|
Jeff Moyer |
2c91dc |
-};
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static struct namespace namespace3_blk0 = {
|
|
Jeff Moyer |
2c91dc |
- 0, "namespace_blk", NULL, NULL, NULL, SZ_7M,
|
|
Jeff Moyer |
2c91dc |
- { 5, 5, 5, 5,
|
|
Jeff Moyer |
2c91dc |
- 5, 5, 5, 5,
|
|
Jeff Moyer |
2c91dc |
- 5, 5, 5, 5,
|
|
Jeff Moyer |
2c91dc |
- 5, 5, 5, 5, }, 1, 1, 0,
|
|
Jeff Moyer |
2c91dc |
- ARRAY_SIZE(blk_sector_sizes), blk_sector_sizes,
|
|
Jeff Moyer |
2c91dc |
-};
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static struct namespace namespace3_blk1 = {
|
|
Jeff Moyer |
2c91dc |
- 1, "namespace_blk", NULL, NULL, NULL, SZ_11M,
|
|
Jeff Moyer |
2c91dc |
- { 6, 6, 6, 6,
|
|
Jeff Moyer |
2c91dc |
- 6, 6, 6, 6,
|
|
Jeff Moyer |
2c91dc |
- 6, 6, 6, 6,
|
|
Jeff Moyer |
2c91dc |
- 6, 6, 6, 6, }, 1, 1, 0,
|
|
Jeff Moyer |
2c91dc |
- ARRAY_SIZE(blk_sector_sizes), blk_sector_sizes,
|
|
Jeff Moyer |
2c91dc |
-};
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static struct namespace namespace4_blk0 = {
|
|
Jeff Moyer |
2c91dc |
- 0, "namespace_blk", &btt_settings, NULL, NULL, SZ_27M,
|
|
Jeff Moyer |
2c91dc |
- { 7, 7, 7, 7,
|
|
Jeff Moyer |
2c91dc |
- 7, 7, 7, 7,
|
|
Jeff Moyer |
2c91dc |
- 7, 7, 7, 7,
|
|
Jeff Moyer |
2c91dc |
- 7, 7, 7, 7, }, 1, 1, 0,
|
|
Jeff Moyer |
2c91dc |
- ARRAY_SIZE(blk_sector_sizes), blk_sector_sizes,
|
|
Jeff Moyer |
2c91dc |
-};
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static struct namespace namespace5_blk0 = {
|
|
Jeff Moyer |
2c91dc |
- 0, "namespace_blk", &btt_settings, NULL, NULL, SZ_27M,
|
|
Jeff Moyer |
2c91dc |
- { 8, 8, 8, 8,
|
|
Jeff Moyer |
2c91dc |
- 8, 8, 8, 8,
|
|
Jeff Moyer |
2c91dc |
- 8, 8, 8, 8,
|
|
Jeff Moyer |
2c91dc |
- 8, 8, 8, 8, }, 1, 1, 0,
|
|
Jeff Moyer |
2c91dc |
- ARRAY_SIZE(blk_sector_sizes), blk_sector_sizes,
|
|
Jeff Moyer |
2c91dc |
-};
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
static struct region regions0[] = {
|
|
Jeff Moyer |
2c91dc |
{ { 1 }, 2, 1, "pmem", SZ_32M, SZ_32M, { 1 },
|
|
Jeff Moyer |
2c91dc |
.namespaces = {
|
|
Jeff Moyer |
2c91dc |
@@ -339,40 +273,6 @@ static struct region regions0[] = {
|
|
Jeff Moyer |
2c91dc |
[0] = &default_pfn,
|
|
Jeff Moyer |
2c91dc |
},
|
|
Jeff Moyer |
2c91dc |
},
|
|
Jeff Moyer |
2c91dc |
- { { DIMM_HANDLE(0, 0, 0, 0, 0) }, 1, 1, "blk", SZ_18M, SZ_32M,
|
|
Jeff Moyer |
2c91dc |
- .namespaces = {
|
|
Jeff Moyer |
2c91dc |
- [0] = &namespace2_blk0,
|
|
Jeff Moyer |
2c91dc |
- [1] = &namespace2_blk1,
|
|
Jeff Moyer |
2c91dc |
- },
|
|
Jeff Moyer |
2c91dc |
- .btts = {
|
|
Jeff Moyer |
2c91dc |
- [0] = &default_btt,
|
|
Jeff Moyer |
2c91dc |
- },
|
|
Jeff Moyer |
2c91dc |
- },
|
|
Jeff Moyer |
2c91dc |
- { { DIMM_HANDLE(0, 0, 0, 0, 1) }, 1, 1, "blk", SZ_18M, SZ_32M,
|
|
Jeff Moyer |
2c91dc |
- .namespaces = {
|
|
Jeff Moyer |
2c91dc |
- [0] = &namespace3_blk0,
|
|
Jeff Moyer |
2c91dc |
- [1] = &namespace3_blk1,
|
|
Jeff Moyer |
2c91dc |
- },
|
|
Jeff Moyer |
2c91dc |
- .btts = {
|
|
Jeff Moyer |
2c91dc |
- [0] = &default_btt,
|
|
Jeff Moyer |
2c91dc |
- },
|
|
Jeff Moyer |
2c91dc |
- },
|
|
Jeff Moyer |
2c91dc |
- { { DIMM_HANDLE(0, 0, 1, 0, 0) }, 1, 1, "blk", SZ_27M, SZ_32M,
|
|
Jeff Moyer |
2c91dc |
- .namespaces = {
|
|
Jeff Moyer |
2c91dc |
- [0] = &namespace4_blk0,
|
|
Jeff Moyer |
2c91dc |
- },
|
|
Jeff Moyer |
2c91dc |
- .btts = {
|
|
Jeff Moyer |
2c91dc |
- [0] = &default_btt,
|
|
Jeff Moyer |
2c91dc |
- },
|
|
Jeff Moyer |
2c91dc |
- },
|
|
Jeff Moyer |
2c91dc |
- { { DIMM_HANDLE(0, 0, 1, 0, 1) }, 1, 1, "blk", SZ_27M, SZ_32M,
|
|
Jeff Moyer |
2c91dc |
- .namespaces = {
|
|
Jeff Moyer |
2c91dc |
- [0] = &namespace5_blk0,
|
|
Jeff Moyer |
2c91dc |
- },
|
|
Jeff Moyer |
2c91dc |
- .btts = {
|
|
Jeff Moyer |
2c91dc |
- [0] = &default_btt,
|
|
Jeff Moyer |
2c91dc |
- },
|
|
Jeff Moyer |
2c91dc |
- },
|
|
Jeff Moyer |
2c91dc |
};
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
static struct namespace namespace1 = {
|
|
Jeff Moyer |
2c91dc |
@@ -485,26 +385,6 @@ static struct ndctl_region *get_pmem_region_by_range_index(struct ndctl_bus *bus
|
|
Jeff Moyer |
2c91dc |
return NULL;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
-static struct ndctl_region *get_blk_region_by_dimm_handle(struct ndctl_bus *bus,
|
|
Jeff Moyer |
2c91dc |
- unsigned int handle)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_region *region;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region) {
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_mapping *map;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_region_get_type(region) != ND_DEVICE_REGION_BLK)
|
|
Jeff Moyer |
2c91dc |
- continue;
|
|
Jeff Moyer |
2c91dc |
- ndctl_mapping_foreach(region, map) {
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_dimm *dimm = ndctl_mapping_get_dimm(map);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_dimm_get_handle(dimm) == handle)
|
|
Jeff Moyer |
2c91dc |
- return region;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- return NULL;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
enum ns_mode {
|
|
Jeff Moyer |
2c91dc |
BTT, PFN, DAX,
|
|
Jeff Moyer |
2c91dc |
};
|
|
Jeff Moyer |
2c91dc |
@@ -522,11 +402,8 @@ static int check_regions(struct ndctl_bus *bus, struct region *regions, int n,
|
|
Jeff Moyer |
2c91dc |
struct ndctl_interleave_set *iset;
|
|
Jeff Moyer |
2c91dc |
char devname[50];
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
- if (strcmp(regions[i].type, "pmem") == 0)
|
|
Jeff Moyer |
2c91dc |
- region = get_pmem_region_by_range_index(bus, regions[i].range_index);
|
|
Jeff Moyer |
2c91dc |
- else
|
|
Jeff Moyer |
2c91dc |
- region = get_blk_region_by_dimm_handle(bus, regions[i].handle);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
+ region = get_pmem_region_by_range_index(bus,
|
|
Jeff Moyer |
2c91dc |
+ regions[i].range_index);
|
|
Jeff Moyer |
2c91dc |
if (!region) {
|
|
Jeff Moyer |
2c91dc |
fprintf(stderr, "failed to find region type: %s ident: %x\n",
|
|
Jeff Moyer |
2c91dc |
regions[i].type, regions[i].handle);
|
|
Jeff Moyer |
2c91dc |
@@ -1065,7 +942,6 @@ static int check_btt_create(struct ndctl_region *region, struct ndctl_namespace
|
|
Jeff Moyer |
2c91dc |
return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
for (i = 0; i < btt_s->num_sector_sizes; i++) {
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_namespace *ns_seed = ndctl_region_get_namespace_seed(region);
|
|
Jeff Moyer |
2c91dc |
struct ndctl_btt *btt_seed = ndctl_region_get_btt_seed(region);
|
|
Jeff Moyer |
2c91dc |
enum ndctl_namespace_mode mode;
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
@@ -1115,16 +991,6 @@ static int check_btt_create(struct ndctl_region *region, struct ndctl_namespace
|
|
Jeff Moyer |
2c91dc |
goto err;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
- /* check new seed creation for BLK regions */
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_region_get_type(region) == ND_DEVICE_REGION_BLK) {
|
|
Jeff Moyer |
2c91dc |
- if (ns_seed == ndctl_region_get_namespace_seed(region)
|
|
Jeff Moyer |
2c91dc |
- && ndns == ns_seed) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s: failed to advance namespace seed\n",
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_get_devname(region));
|
|
Jeff Moyer |
2c91dc |
- goto err;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
if (namespace->ro) {
|
|
Jeff Moyer |
2c91dc |
ndctl_region_set_ro(region, 0);
|
|
Jeff Moyer |
2c91dc |
rc = ndctl_btt_enable(btt);
|
|
Jeff Moyer |
2c91dc |
diff --git a/test/multi-pmem.c b/test/multi-pmem.c
|
|
Jeff Moyer |
2c91dc |
deleted file mode 100644
|
|
Jeff Moyer |
2c91dc |
index 3ea08cc..0000000
|
|
Jeff Moyer |
2c91dc |
--- a/test/multi-pmem.c
|
|
Jeff Moyer |
2c91dc |
+++ /dev/null
|
|
Jeff Moyer |
2c91dc |
@@ -1,285 +0,0 @@
|
|
Jeff Moyer |
2c91dc |
-// SPDX-License-Identifier: GPL-2.0
|
|
Jeff Moyer |
2c91dc |
-// Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
|
|
Jeff Moyer |
2c91dc |
-#include <stdio.h>
|
|
Jeff Moyer |
2c91dc |
-#include <errno.h>
|
|
Jeff Moyer |
2c91dc |
-#include <unistd.h>
|
|
Jeff Moyer |
2c91dc |
-#include <stdlib.h>
|
|
Jeff Moyer |
2c91dc |
-#include <syslog.h>
|
|
Jeff Moyer |
2c91dc |
-#include <string.h>
|
|
Jeff Moyer |
2c91dc |
-#include <sys/stat.h>
|
|
Jeff Moyer |
2c91dc |
-#include <sys/mman.h>
|
|
Jeff Moyer |
2c91dc |
-#include <sys/time.h>
|
|
Jeff Moyer |
2c91dc |
-#include <libkmod.h>
|
|
Jeff Moyer |
2c91dc |
-#include <uuid/uuid.h>
|
|
Jeff Moyer |
2c91dc |
-#include <sys/types.h>
|
|
Jeff Moyer |
2c91dc |
-#include <util/size.h>
|
|
Jeff Moyer |
2c91dc |
-#include <linux/falloc.h>
|
|
Jeff Moyer |
2c91dc |
-#include <linux/version.h>
|
|
Jeff Moyer |
2c91dc |
-#include <ndctl/libndctl.h>
|
|
Jeff Moyer |
2c91dc |
-#include <ccan/array_size/array_size.h>
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-#include <ndctl.h>
|
|
Jeff Moyer |
2c91dc |
-#include <builtin.h>
|
|
Jeff Moyer |
2c91dc |
-#include <test.h>
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-#define NUM_NAMESPACES 4
|
|
Jeff Moyer |
2c91dc |
-#define SZ_NAMESPACE SZ_16M
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static int setup_namespace(struct ndctl_region *region)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_ctx *ctx = ndctl_region_get_ctx(region);
|
|
Jeff Moyer |
2c91dc |
- const char *argv[] = {
|
|
Jeff Moyer |
2c91dc |
- "__func__", "-v", "-m", "raw", "-s", "16M", "-r", "",
|
|
Jeff Moyer |
2c91dc |
- };
|
|
Jeff Moyer |
2c91dc |
- int argc = ARRAY_SIZE(argv);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- argv[argc - 1] = ndctl_region_get_devname(region);
|
|
Jeff Moyer |
2c91dc |
- builtin_xaction_namespace_reset();
|
|
Jeff Moyer |
2c91dc |
- return cmd_create_namespace(argc, argv, ctx);
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static void destroy_namespace(struct ndctl_namespace *ndns)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_ctx *ctx = ndctl_namespace_get_ctx(ndns);
|
|
Jeff Moyer |
2c91dc |
- const char *argv[] = {
|
|
Jeff Moyer |
2c91dc |
- "__func__", "-v", "-f", "",
|
|
Jeff Moyer |
2c91dc |
- };
|
|
Jeff Moyer |
2c91dc |
- int argc = ARRAY_SIZE(argv);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- argv[argc - 1] = ndctl_namespace_get_devname(ndns);
|
|
Jeff Moyer |
2c91dc |
- builtin_xaction_namespace_reset();
|
|
Jeff Moyer |
2c91dc |
- cmd_destroy_namespace(argc, argv, ctx);
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-/* Check that the namespace device is gone (if it wasn't the seed) */
|
|
Jeff Moyer |
2c91dc |
-static int check_deleted(struct ndctl_region *region, const char *devname,
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_test *test)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_namespace *ndns;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 10, 0)))
|
|
Jeff Moyer |
2c91dc |
- return 0;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_foreach(region, ndns) {
|
|
Jeff Moyer |
2c91dc |
- if (strcmp(devname, ndctl_namespace_get_devname(ndns)))
|
|
Jeff Moyer |
2c91dc |
- continue;
|
|
Jeff Moyer |
2c91dc |
- if (ndns == ndctl_region_get_namespace_seed(region))
|
|
Jeff Moyer |
2c91dc |
- continue;
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "multi-pmem: expected %s to be deleted\n",
|
|
Jeff Moyer |
2c91dc |
- devname);
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- return 0;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static int do_multi_pmem(struct ndctl_ctx *ctx, struct ndctl_test *test)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- int i;
|
|
Jeff Moyer |
2c91dc |
- char devname[100];
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_bus *bus;
|
|
Jeff Moyer |
2c91dc |
- uuid_t uuid[NUM_NAMESPACES];
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_namespace *ndns;
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_dimm *dimm_target, *dimm;
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_region *region, *target = NULL;
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_namespace *namespaces[NUM_NAMESPACES];
|
|
Jeff Moyer |
2c91dc |
- unsigned long long blk_avail, blk_avail_orig, expect;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 9, 0))) {
|
|
Jeff Moyer |
2c91dc |
- ndctl_test_skip(test);
|
|
Jeff Moyer |
2c91dc |
- return 77;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
|
|
Jeff Moyer |
2c91dc |
- if (!bus)
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* disable all regions so that set_config_data commands are permitted */
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region)
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_disable_invalidate(region);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_dimm_foreach(bus, dimm) {
|
|
Jeff Moyer |
2c91dc |
- int rc = ndctl_dimm_zero_labels(dimm);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to zero %s\n",
|
|
Jeff Moyer |
2c91dc |
- ndctl_dimm_get_devname(dimm));
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /*
|
|
Jeff Moyer |
2c91dc |
- * Set regions back to their default state and find our target
|
|
Jeff Moyer |
2c91dc |
- * region.
|
|
Jeff Moyer |
2c91dc |
- */
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region) {
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_enable(region);
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_region_get_available_size(region)
|
|
Jeff Moyer |
2c91dc |
- == SZ_NAMESPACE * NUM_NAMESPACES)
|
|
Jeff Moyer |
2c91dc |
- target = region;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!target) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "multi-pmem: failed to find target region\n");
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- region = target;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- for (i = 0; i < (int) ARRAY_SIZE(uuid); i++) {
|
|
Jeff Moyer |
2c91dc |
- if (setup_namespace(region) != 0) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "multi-pmem: failed to setup namespace: %d\n", i);
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- sprintf(devname, "namespace%d.%d",
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_get_id(region), i);
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_foreach(region, ndns)
|
|
Jeff Moyer |
2c91dc |
- if (strcmp(ndctl_namespace_get_devname(ndns), devname) == 0
|
|
Jeff Moyer |
2c91dc |
- && ndctl_namespace_is_enabled(ndns))
|
|
Jeff Moyer |
2c91dc |
- break;
|
|
Jeff Moyer |
2c91dc |
- if (!ndns) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "multi-pmem: failed to find namespace: %s\n",
|
|
Jeff Moyer |
2c91dc |
- devname);
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_get_uuid(ndns, uuid[i]);
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* bounce the region and verify everything came back as expected */
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_disable_invalidate(region);
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_enable(region);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- for (i = 0; i < (int) ARRAY_SIZE(uuid); i++) {
|
|
Jeff Moyer |
2c91dc |
- char uuid_str1[40], uuid_str2[40];
|
|
Jeff Moyer |
2c91dc |
- uuid_t uuid_check;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- sprintf(devname, "namespace%d.%d",
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_get_id(region), i);
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_foreach(region, ndns)
|
|
Jeff Moyer |
2c91dc |
- if (strcmp(ndctl_namespace_get_devname(ndns), devname) == 0
|
|
Jeff Moyer |
2c91dc |
- && ndctl_namespace_is_enabled(ndns))
|
|
Jeff Moyer |
2c91dc |
- break;
|
|
Jeff Moyer |
2c91dc |
- if (!ndns) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "multi-pmem: failed to restore namespace: %s\n",
|
|
Jeff Moyer |
2c91dc |
- devname);
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_get_uuid(ndns, uuid_check);
|
|
Jeff Moyer |
2c91dc |
- uuid_unparse(uuid_check, uuid_str2);
|
|
Jeff Moyer |
2c91dc |
- uuid_unparse(uuid[i], uuid_str1);
|
|
Jeff Moyer |
2c91dc |
- if (uuid_compare(uuid_check, uuid[i]) != 0) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "multi-pmem: expected uuid[%d]: %s, got %s\n",
|
|
Jeff Moyer |
2c91dc |
- i, uuid_str1, uuid_str2);
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- namespaces[i] = ndns;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /*
|
|
Jeff Moyer |
2c91dc |
- * Check that aliased blk capacity does not increase until the
|
|
Jeff Moyer |
2c91dc |
- * highest dpa pmem-namespace is deleted.
|
|
Jeff Moyer |
2c91dc |
- */
|
|
Jeff Moyer |
2c91dc |
- dimm_target = ndctl_region_get_first_dimm(region);
|
|
Jeff Moyer |
2c91dc |
- if (!dimm_target) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "multi-pmem: failed to retrieve dimm from %s\n",
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_get_devname(region));
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- dimm = NULL;
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region) {
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_region_get_type(region) != ND_DEVICE_REGION_BLK)
|
|
Jeff Moyer |
2c91dc |
- continue;
|
|
Jeff Moyer |
2c91dc |
- ndctl_dimm_foreach_in_region(region, dimm)
|
|
Jeff Moyer |
2c91dc |
- if (dimm == dimm_target)
|
|
Jeff Moyer |
2c91dc |
- break;
|
|
Jeff Moyer |
2c91dc |
- if (dimm)
|
|
Jeff Moyer |
2c91dc |
- break;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- blk_avail_orig = ndctl_region_get_available_size(region);
|
|
Jeff Moyer |
2c91dc |
- for (i = 1; i < NUM_NAMESPACES - 1; i++) {
|
|
Jeff Moyer |
2c91dc |
- ndns = namespaces[i];
|
|
Jeff Moyer |
2c91dc |
- sprintf(devname, "%s", ndctl_namespace_get_devname(ndns));
|
|
Jeff Moyer |
2c91dc |
- destroy_namespace(ndns);
|
|
Jeff Moyer |
2c91dc |
- blk_avail = ndctl_region_get_available_size(region);
|
|
Jeff Moyer |
2c91dc |
- if (blk_avail != blk_avail_orig) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "multi-pmem: destroy %s %llx avail, expect %llx\n",
|
|
Jeff Moyer |
2c91dc |
- devname, blk_avail, blk_avail_orig);
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (check_deleted(target, devname, test) != 0)
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndns = namespaces[NUM_NAMESPACES - 1];
|
|
Jeff Moyer |
2c91dc |
- sprintf(devname, "%s", ndctl_namespace_get_devname(ndns));
|
|
Jeff Moyer |
2c91dc |
- destroy_namespace(ndns);
|
|
Jeff Moyer |
2c91dc |
- blk_avail = ndctl_region_get_available_size(region);
|
|
Jeff Moyer |
2c91dc |
- expect = (SZ_NAMESPACE / ndctl_region_get_interleave_ways(target))
|
|
Jeff Moyer |
2c91dc |
- * (NUM_NAMESPACES - 1) + blk_avail_orig;
|
|
Jeff Moyer |
2c91dc |
- if (blk_avail != expect) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "multi-pmem: destroy %s %llx avail, expect %llx\n",
|
|
Jeff Moyer |
2c91dc |
- devname, blk_avail, expect);
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (check_deleted(target, devname, test) != 0)
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_bus_foreach(ctx, bus) {
|
|
Jeff Moyer |
2c91dc |
- if (strncmp(ndctl_bus_get_provider(bus), "nfit_test", 9) != 0)
|
|
Jeff Moyer |
2c91dc |
- continue;
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region)
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_disable_invalidate(region);
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- return 0;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-int test_multi_pmem(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct kmod_module *mod;
|
|
Jeff Moyer |
2c91dc |
- struct kmod_ctx *kmod_ctx;
|
|
Jeff Moyer |
2c91dc |
- int err, result = EXIT_FAILURE;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 2, 0)))
|
|
Jeff Moyer |
2c91dc |
- return 77;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_set_log_priority(ctx, loglevel);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
|
|
Jeff Moyer |
2c91dc |
- if (err < 0) {
|
|
Jeff Moyer |
2c91dc |
- result = 77;
|
|
Jeff Moyer |
2c91dc |
- ndctl_test_skip(test);
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "%s unavailable skipping tests\n",
|
|
Jeff Moyer |
2c91dc |
- "nfit_test");
|
|
Jeff Moyer |
2c91dc |
- return result;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- result = do_multi_pmem(ctx, test);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- kmod_module_remove_module(mod, 0);
|
|
Jeff Moyer |
2c91dc |
- kmod_unref(kmod_ctx);
|
|
Jeff Moyer |
2c91dc |
- return result;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-int __attribute__((weak)) main(int argc, char *argv[])
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_test *test = ndctl_test_new(0);
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_ctx *ctx;
|
|
Jeff Moyer |
2c91dc |
- int rc;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!test) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to initialize test\n");
|
|
Jeff Moyer |
2c91dc |
- return EXIT_FAILURE;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_new(&ctx;;
|
|
Jeff Moyer |
2c91dc |
- if (rc)
|
|
Jeff Moyer |
2c91dc |
- return ndctl_test_result(test, rc);
|
|
Jeff Moyer |
2c91dc |
- rc = test_multi_pmem(LOG_DEBUG, test, ctx);
|
|
Jeff Moyer |
2c91dc |
- ndctl_unref(ctx);
|
|
Jeff Moyer |
2c91dc |
- return ndctl_test_result(test, rc);
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
diff --git a/test/parent-uuid.c b/test/parent-uuid.c
|
|
Jeff Moyer |
2c91dc |
deleted file mode 100644
|
|
Jeff Moyer |
2c91dc |
index bded33a..0000000
|
|
Jeff Moyer |
2c91dc |
--- a/test/parent-uuid.c
|
|
Jeff Moyer |
2c91dc |
+++ /dev/null
|
|
Jeff Moyer |
2c91dc |
@@ -1,254 +0,0 @@
|
|
Jeff Moyer |
2c91dc |
-// SPDX-License-Identifier: LGPL-2.1
|
|
Jeff Moyer |
2c91dc |
-// Copyright (C) 2015-2020, Intel Corporation. All rights reserved.
|
|
Jeff Moyer |
2c91dc |
-#include <stdio.h>
|
|
Jeff Moyer |
2c91dc |
-#include <stddef.h>
|
|
Jeff Moyer |
2c91dc |
-#include <stdlib.h>
|
|
Jeff Moyer |
2c91dc |
-#include <string.h>
|
|
Jeff Moyer |
2c91dc |
-#include <fcntl.h>
|
|
Jeff Moyer |
2c91dc |
-#include <ctype.h>
|
|
Jeff Moyer |
2c91dc |
-#include <errno.h>
|
|
Jeff Moyer |
2c91dc |
-#include <unistd.h>
|
|
Jeff Moyer |
2c91dc |
-#include <limits.h>
|
|
Jeff Moyer |
2c91dc |
-#include <syslog.h>
|
|
Jeff Moyer |
2c91dc |
-#include <libkmod.h>
|
|
Jeff Moyer |
2c91dc |
-#include <uuid/uuid.h>
|
|
Jeff Moyer |
2c91dc |
-#include <linux/version.h>
|
|
Jeff Moyer |
2c91dc |
-#include <test.h>
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-#include <ndctl/libndctl.h>
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static const char *PROVIDER = "nfit_test.0";
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static struct ndctl_bus *get_bus_by_provider(struct ndctl_ctx *ctx,
|
|
Jeff Moyer |
2c91dc |
- const char *provider)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_bus *bus;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_bus_foreach(ctx, bus)
|
|
Jeff Moyer |
2c91dc |
- if (strcmp(provider, ndctl_bus_get_provider(bus)) == 0)
|
|
Jeff Moyer |
2c91dc |
- return bus;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- return NULL;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static struct ndctl_btt *get_idle_btt(struct ndctl_region *region)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_btt *btt;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_btt_foreach(region, btt)
|
|
Jeff Moyer |
2c91dc |
- if (!ndctl_btt_is_enabled(btt)
|
|
Jeff Moyer |
2c91dc |
- && !ndctl_btt_is_configured(btt))
|
|
Jeff Moyer |
2c91dc |
- return btt;
|
|
Jeff Moyer |
2c91dc |
- return NULL;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static struct ndctl_namespace *create_blk_namespace(int region_fraction,
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_region *region, unsigned long long req_size,
|
|
Jeff Moyer |
2c91dc |
- uuid_t uuid)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_namespace *ndns, *seed_ns = NULL;
|
|
Jeff Moyer |
2c91dc |
- unsigned long long size;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_set_align(region, sysconf(_SC_PAGESIZE));
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_foreach(region, ndns)
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_get_size(ndns) == 0) {
|
|
Jeff Moyer |
2c91dc |
- seed_ns = ndns;
|
|
Jeff Moyer |
2c91dc |
- break;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!seed_ns)
|
|
Jeff Moyer |
2c91dc |
- return NULL;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- size = ndctl_region_get_size(region)/region_fraction;
|
|
Jeff Moyer |
2c91dc |
- if (req_size)
|
|
Jeff Moyer |
2c91dc |
- size = req_size;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_set_uuid(seed_ns, uuid) < 0)
|
|
Jeff Moyer |
2c91dc |
- return NULL;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_set_size(seed_ns, size) < 0)
|
|
Jeff Moyer |
2c91dc |
- return NULL;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_set_sector_size(seed_ns, 512) < 0)
|
|
Jeff Moyer |
2c91dc |
- return NULL;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_enable(seed_ns) < 0)
|
|
Jeff Moyer |
2c91dc |
- return NULL;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- return seed_ns;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static int disable_blk_namespace(struct ndctl_namespace *ndns)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_disable_invalidate(ndns) < 0)
|
|
Jeff Moyer |
2c91dc |
- return -ENODEV;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_delete(ndns) < 0)
|
|
Jeff Moyer |
2c91dc |
- return -ENODEV;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- return 0;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static struct ndctl_btt *check_valid_btt(struct ndctl_region *region,
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_namespace *ndns, uuid_t btt_uuid)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_btt *btt = NULL;
|
|
Jeff Moyer |
2c91dc |
- ndctl_btt_foreach(region, btt) {
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_namespace *btt_ndns;
|
|
Jeff Moyer |
2c91dc |
- uuid_t uu;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_btt_get_uuid(btt, uu);
|
|
Jeff Moyer |
2c91dc |
- if (uuid_compare(uu, btt_uuid) != 0)
|
|
Jeff Moyer |
2c91dc |
- continue;
|
|
Jeff Moyer |
2c91dc |
- if (!ndctl_btt_is_enabled(btt))
|
|
Jeff Moyer |
2c91dc |
- continue;
|
|
Jeff Moyer |
2c91dc |
- btt_ndns = ndctl_btt_get_namespace(btt);
|
|
Jeff Moyer |
2c91dc |
- if (!btt_ndns || strcmp(ndctl_namespace_get_devname(btt_ndns),
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_get_devname(ndns)) != 0)
|
|
Jeff Moyer |
2c91dc |
- continue;
|
|
Jeff Moyer |
2c91dc |
- return btt;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
- return NULL;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-static int do_test(struct ndctl_ctx *ctx)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- int rc;
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_bus *bus;
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_btt *btt, *found = NULL, *_btt;
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_region *region, *blk_region = NULL;
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_namespace *ndns, *_ndns;
|
|
Jeff Moyer |
2c91dc |
- unsigned long long ns_size = 18874368;
|
|
Jeff Moyer |
2c91dc |
- uuid_t uuid = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16};
|
|
Jeff Moyer |
2c91dc |
- uuid_t btt_uuid;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- bus = get_bus_by_provider(ctx, PROVIDER);
|
|
Jeff Moyer |
2c91dc |
- if (!bus) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to find NFIT-provider: %s\n", PROVIDER);
|
|
Jeff Moyer |
2c91dc |
- return -ENODEV;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region)
|
|
Jeff Moyer |
2c91dc |
- if (strcmp(ndctl_region_get_type_name(region), "blk") == 0) {
|
|
Jeff Moyer |
2c91dc |
- blk_region = region;
|
|
Jeff Moyer |
2c91dc |
- break;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!blk_region) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to find block region\n");
|
|
Jeff Moyer |
2c91dc |
- return -ENODEV;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* create a blk namespace */
|
|
Jeff Moyer |
2c91dc |
- ndns = create_blk_namespace(1, blk_region, ns_size, uuid);
|
|
Jeff Moyer |
2c91dc |
- if (!ndns) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to create block namespace\n");
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* create a btt for this namespace */
|
|
Jeff Moyer |
2c91dc |
- uuid_generate(btt_uuid);
|
|
Jeff Moyer |
2c91dc |
- btt = get_idle_btt(region);
|
|
Jeff Moyer |
2c91dc |
- if (!btt)
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_disable_invalidate(ndns);
|
|
Jeff Moyer |
2c91dc |
- ndctl_btt_set_uuid(btt, btt_uuid);
|
|
Jeff Moyer |
2c91dc |
- ndctl_btt_set_sector_size(btt, 512);
|
|
Jeff Moyer |
2c91dc |
- ndctl_btt_set_namespace(btt, ndns);
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_btt_enable(btt);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to create btt 0\n");
|
|
Jeff Moyer |
2c91dc |
- return rc;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* re-create the namespace - this should auto-enable the btt */
|
|
Jeff Moyer |
2c91dc |
- disable_blk_namespace(ndns);
|
|
Jeff Moyer |
2c91dc |
- ndns = create_blk_namespace(1, blk_region, ns_size, uuid);
|
|
Jeff Moyer |
2c91dc |
- if (!ndns) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to re-create block namespace\n");
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* Verify btt was auto-created */
|
|
Jeff Moyer |
2c91dc |
- found = check_valid_btt(blk_region, ndns, btt_uuid);
|
|
Jeff Moyer |
2c91dc |
- if (!found)
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- btt = found;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /*disable the btt and namespace again */
|
|
Jeff Moyer |
2c91dc |
- ndctl_btt_delete(btt);
|
|
Jeff Moyer |
2c91dc |
- disable_blk_namespace(ndns);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* recreate the namespace with a different uuid */
|
|
Jeff Moyer |
2c91dc |
- uuid_generate(uuid);
|
|
Jeff Moyer |
2c91dc |
- ndns = create_blk_namespace(1, blk_region, ns_size, uuid);
|
|
Jeff Moyer |
2c91dc |
- if (!ndns) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to re-create block namespace\n");
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- /* make sure there is no btt on this namespace */
|
|
Jeff Moyer |
2c91dc |
- found = check_valid_btt(blk_region, ndns, btt_uuid);
|
|
Jeff Moyer |
2c91dc |
- if (found) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "found a stale btt\n");
|
|
Jeff Moyer |
2c91dc |
- return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_btt_foreach_safe(blk_region, btt, _btt)
|
|
Jeff Moyer |
2c91dc |
- ndctl_btt_delete(btt);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_foreach_safe(blk_region, ndns, _ndns)
|
|
Jeff Moyer |
2c91dc |
- if (ndctl_namespace_get_size(ndns) != 0)
|
|
Jeff Moyer |
2c91dc |
- disable_blk_namespace(ndns);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_foreach(bus, region)
|
|
Jeff Moyer |
2c91dc |
- ndctl_region_disable_invalidate(region);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- return 0;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-int test_parent_uuid(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct kmod_module *mod;
|
|
Jeff Moyer |
2c91dc |
- struct kmod_ctx *kmod_ctx;
|
|
Jeff Moyer |
2c91dc |
- int err, result = EXIT_FAILURE;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 3, 0)))
|
|
Jeff Moyer |
2c91dc |
- return 77;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- ndctl_set_log_priority(ctx, loglevel);
|
|
Jeff Moyer |
2c91dc |
- err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
|
|
Jeff Moyer |
2c91dc |
- if (err < 0) {
|
|
Jeff Moyer |
2c91dc |
- ndctl_test_skip(test);
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "nfit_test unavailable skipping tests\n");
|
|
Jeff Moyer |
2c91dc |
- return 77;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- err = do_test(ctx);
|
|
Jeff Moyer |
2c91dc |
- if (err == 0)
|
|
Jeff Moyer |
2c91dc |
- result = EXIT_SUCCESS;
|
|
Jeff Moyer |
2c91dc |
- kmod_module_remove_module(mod, 0);
|
|
Jeff Moyer |
2c91dc |
- kmod_unref(kmod_ctx);
|
|
Jeff Moyer |
2c91dc |
- return result;
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
-int __attribute__((weak)) main(int argc, char *argv[])
|
|
Jeff Moyer |
2c91dc |
-{
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_test *test = ndctl_test_new(0);
|
|
Jeff Moyer |
2c91dc |
- struct ndctl_ctx *ctx;
|
|
Jeff Moyer |
2c91dc |
- int rc;
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- if (!test) {
|
|
Jeff Moyer |
2c91dc |
- fprintf(stderr, "failed to initialize test\n");
|
|
Jeff Moyer |
2c91dc |
- return EXIT_FAILURE;
|
|
Jeff Moyer |
2c91dc |
- }
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = ndctl_new(&ctx;;
|
|
Jeff Moyer |
2c91dc |
- if (rc)
|
|
Jeff Moyer |
2c91dc |
- return ndctl_test_result(test, rc);
|
|
Jeff Moyer |
2c91dc |
-
|
|
Jeff Moyer |
2c91dc |
- rc = test_parent_uuid(LOG_DEBUG, test, ctx);
|
|
Jeff Moyer |
2c91dc |
- ndctl_unref(ctx);
|
|
Jeff Moyer |
2c91dc |
- return ndctl_test_result(test, rc);
|
|
Jeff Moyer |
2c91dc |
-}
|
|
Jeff Moyer |
2c91dc |
--
|
|
Jeff Moyer |
2c91dc |
2.27.0
|
|
Jeff Moyer |
2c91dc |
|