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