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