[ndctl PATCH v2 00/10] ndctl: automatically initialize labels
by Dan Williams
Changes since v1 [1]:
* Reflect the new region type when it is next enabled (Ryon)
* Spelling and whitespace (Vishal)
* Fix support for the v1.2 labels case where we were miscalculating the
size of the index block area. This bug has been hiding behind the
order of operations in which we do the calculation. The kernel needs the
same fixup.
[1]: https://lists.01.org/pipermail/linux-nvdimm/2017-August/012152.html
---
The QEMU-KVM enabling for a virtual NVDIMM is an example of a
configuration where label-less namespaces are created by default. I.e.
the ACPI NFIT produced by SeaBIOS publishes un-aliased pmem regions. The
first operation an administrator is likely to perform is to reconfigure
the namespace into "memory" mode to enable full-featured DAX support.
The reconfiguration of the label-less namespace into "memory" mode is an
opportunity to also enable labels. This series effectively runs the
following sequence:
ndctl disable-region all
ndctl init-labels
ndctl enabled-region all
...in 'create-namespace' whenever a label-less namespace is encountered.
The implementation is careful to try v1.2 labels and validate that the
kernel supports that scheme. Otherwise, it falls back to v1.1 labels.
For other utilities built on top of libndctl, the following new helpers
are provided to enable a similar flow:
ndctl_dimm_read_labels()
ndctl_dimm_validate_labels()
ndctl_dimm_init_labels()
...where 'read_labels' enables the other apis, 'validate_labels' checks
whether the data retrieved from the read corresponds to a valid set of
namespace label index blocks, and 'init_labels' writes namespace index
blocks to the dimm. In order to check that the kernel supports a given
index block version / format the result from
ndctl_dimm_get_available_labels() can be compared to the result from
ndctl_dimm_init_labels() to make sure the kernel sees the same number of
available slots as userspace.
---
Dan Williams (10):
ndctl, init-labels: fix '--label-version' option
ndctl: drop the "libndctl-" prefix on library source files
ndctl: move label manipulation routines to their own file
ndctl: consolidate namespace definitions in namespace.h
ndctl: refactor read_labels() helper into a library call
ndctl: refactor region type setting
ndctl: introduce ndctl_dimm_{validate_labels,init_labels}
ndctl: refresh region type after init_labels
ndctl: fix namespace index block size calculation
ndctl: auto initialize labels
Makefile.am | 1
ndctl/check.c | 52 ++++
ndctl/check.h | 130 ---------
ndctl/dimm.c | 547 ++--------------------------------------
ndctl/lib/Makefile.am | 11 -
ndctl/lib/ars.c | 2
ndctl/lib/dimm.c | 580 ++++++++++++++++++++++++++++++++++++++++++
ndctl/lib/hpe1.c | 4
ndctl/lib/hpe1.h | 0
ndctl/lib/libndctl.c | 209 +++------------
ndctl/lib/libndctl.sym | 4
ndctl/lib/msft.c | 4
ndctl/lib/msft.h | 0
ndctl/lib/private.h | 150 +++++------
ndctl/lib/smart.c | 2
ndctl/libndctl.h.in | 9 +
ndctl/namespace.c | 111 +++++++-
ndctl/namespace.h | 163 ++++++++++++
util/fletcher.c | 35 ---
util/fletcher.h | 19 +
20 files changed, 1080 insertions(+), 953 deletions(-)
delete mode 100644 ndctl/check.h
rename ndctl/lib/{libndctl-ars.c => ars.c} (99%)
create mode 100644 ndctl/lib/dimm.c
rename ndctl/lib/{libndctl-hpe1.c => hpe1.c} (99%)
rename ndctl/lib/{ndctl-hpe1.h => hpe1.h} (100%)
rename ndctl/lib/{libndctl-msft.c => msft.c} (98%)
rename ndctl/lib/{ndctl-msft.h => msft.h} (100%)
rename ndctl/lib/{libndctl-private.h => private.h} (69%)
rename ndctl/lib/{libndctl-smart.c => smart.c} (99%)
create mode 100644 ndctl/namespace.h
delete mode 100644 util/fletcher.c
3 years, 4 months
[PATCH] libnvdimm: clean up command definitions
by Dan Williams
Remove the command payloads that do not have an associated libnvdimm
ioctl. I.e. remove the payloads that would only ever be carried in the
ND_CMD_CALL envelope. This prevents userspace from growing unnecessary
dependencies on this kernel header when userspace already has everything
it needs to craft and send these commands.
Cc: Jerry Hoemann <jerry.hoemann(a)hpe.com>
Reported-by: Yasunori Goto <y-goto(a)jp.fujitsu.com>
Signed-off-by: Dan Williams <dan.j.williams(a)intel.com>
---
include/uapi/linux/ndctl.h | 37 -------------------------------------
1 file changed, 37 deletions(-)
diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
index 6d3c54264d8e..3f03567631cb 100644
--- a/include/uapi/linux/ndctl.h
+++ b/include/uapi/linux/ndctl.h
@@ -145,43 +145,6 @@ struct nd_cmd_clear_error {
__u64 cleared;
} __packed;
-struct nd_cmd_trans_spa {
- __u64 spa;
- __u32 status;
- __u8 flags;
- __u8 _reserved[3];
- __u64 trans_length;
- __u32 num_nvdimms;
- struct nd_nvdimm_device {
- __u32 nfit_device_handle;
- __u32 _reserved;
- __u64 dpa;
- } __packed devices[0];
-
-} __packed;
-
-struct nd_cmd_ars_err_inj {
- __u64 err_inj_spa_range_base;
- __u64 err_inj_spa_range_length;
- __u8 err_inj_options;
- __u32 status;
-} __packed;
-
-struct nd_cmd_ars_err_inj_clr {
- __u64 err_inj_clr_spa_range_base;
- __u64 err_inj_clr_spa_range_length;
- __u32 status;
-} __packed;
-
-struct nd_cmd_ars_err_inj_stat {
- __u32 status;
- __u32 inj_err_rec_count;
- struct nd_error_stat_query_record {
- __u64 err_inj_stat_spa_range_base;
- __u64 err_inj_stat_spa_range_length;
- } __packed record[0];
-} __packed;
-
enum {
ND_CMD_IMPLEMENTED = 0,
3 years, 4 months
[ndctl PATCH] ndctl, bash-completion: add completion for --label-version
by Vishal Verma
We were missing completion for label-version, add it.
Cc: Dan Williams <dan.j.williams(a)intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma(a)intel.com>
---
contrib/ndctl | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/contrib/ndctl b/contrib/ndctl
index c7e3e7d..1874763 100755
--- a/contrib/ndctl
+++ b/contrib/ndctl
@@ -91,7 +91,7 @@ __ndctlcomp()
COMPREPLY=( $( compgen -W "$1" -- "$2" ) )
for cword in "${COMPREPLY[@]}"; do
- if [[ "$cword" == @(--bus|--region|--type|--mode|--size|--dimm|--reconfig|--uuid|--name|--sector-size|--map|--namespace|--input|--output) ]]; then
+ if [[ "$cword" == @(--bus|--region|--type|--mode|--size|--dimm|--reconfig|--uuid|--name|--sector-size|--map|--namespace|--input|--output|--label-version) ]]; then
COMPREPLY[$i]="${cword}="
else
COMPREPLY[$i]="${cword} "
@@ -205,6 +205,9 @@ __ndctl_comp_options()
__ndctl_file_comp "${cur##*=}"
return
;;
+ --label-version)
+ opts="1.1 1.2"
+ ;;
*)
return
;;
--
2.9.5
3 years, 4 months
[PATCH] libnvdimm, btt: check memory allocation failure
by Christophe JAILLET
Check memory allocation failures and return -ENOMEM in such cases, as
already done few lines below for another memory allocation.
This avoids NULL pointers dereference.
Fixes: 14e494542636 ("libnvdimm, btt: BTT updates for UEFI 2.7 format")
Signed-off-by: Christophe JAILLET <christophe.jaillet(a)wanadoo.fr>
---
drivers/nvdimm/btt.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 60491641a8d6..607184ebcfbf 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1431,6 +1431,8 @@ int nvdimm_namespace_attach_btt(struct nd_namespace_common *ndns)
}
btt_sb = devm_kzalloc(&nd_btt->dev, sizeof(*btt_sb), GFP_KERNEL);
+ if (!btt_sb)
+ return -ENOMEM;
/*
* If this returns < 0, that is ok as it just means there wasn't
--
2.11.0
3 years, 4 months
[ndctl PATCH 0/7] ndctl: automatically initialize labels
by Dan Williams
The QEMU-KVM enabling for a virtual NVDIMM is an example of a
configuration where label-less namespaces are created by default. I.e.
the ACPI NFIT produced by SeaBIOS publishes un-aliased pmem regions. The
first operation an administrator is likely to perform is to reconfigure
the namespace into "memory" mode to enable full-featured DAX support.
The reconfiguration of the label-less namespace into "memory" mode is an
opportunity to also enable labels. This series effectively runs the
following sequence:
ndctl disable-region all
ndctl init-labels
ndctl enabled-region all
...in 'create-namespace' whenever a label-less namespace is encountered.
The implementation is careful to try v1.2 labels and validate that the
kernel supports that scheme. Otherwise, it falls back to v1.1 labels.
For other utilities built on top of libndctl, the following new helpers
are provided to enable a similar flow:
ndctl_dimm_read_labels()
ndctl_dimm_validate_labels()
ndctl_dimm_init_labels()
...where 'read_labels' enables the other apis, 'validate_labels' checks
whether the data retrieved from the read corresponds to a valid set of
namespace label index blocks, and 'init_labels' writes namespace index
blocks to the dimm. In order to check that the kernel supports a given
index block version / format the result from
ndctl_dimm_get_available_labels() can be compared to the result from
ndctl_dimm_init_labels() to make sure the kernel sees the same number of
available slots as userspace.
---
Dan Williams (7):
ndctl, init-labels: fix '--label-version' option
ndctl: drop the "libndctl-" prefix on library source files
ndctl: move label manipulation routines to their own file
ndctl: consolidate namespace definitions in namespace.h
ndctl: refactor read_labels() helper into a library call
ndctl: introduce ndctl_dimm_{validate_labels,init_labels}
ndctl: auto initialize labels
Documentation/ndctl/ndctl-create-namespace.txt | 7
Makefile.am | 1
ndctl/check.c | 52 ++
ndctl/check.h | 130 ------
ndctl/dimm.c | 547 +----------------------
ndctl/lib/Makefile.am | 11
ndctl/lib/ars.c | 2
ndctl/lib/dimm.c | 565 ++++++++++++++++++++++++
ndctl/lib/hpe1.c | 4
ndctl/lib/hpe1.h | 0
ndctl/lib/libndctl.c | 154 -------
ndctl/lib/libndctl.sym | 4
ndctl/lib/msft.c | 4
ndctl/lib/msft.h | 0
ndctl/lib/private.h | 151 +++---
ndctl/lib/smart.c | 2
ndctl/libndctl.h.in | 9
ndctl/namespace.c | 101 ++++
ndctl/namespace.h | 163 +++++++
util/fletcher.c | 35 -
util/fletcher.h | 19 +
21 files changed, 1021 insertions(+), 940 deletions(-)
delete mode 100644 ndctl/check.h
rename ndctl/lib/{libndctl-ars.c => ars.c} (99%)
create mode 100644 ndctl/lib/dimm.c
rename ndctl/lib/{libndctl-hpe1.c => hpe1.c} (99%)
rename ndctl/lib/{ndctl-hpe1.h => hpe1.h} (100%)
rename ndctl/lib/{libndctl-msft.c => msft.c} (98%)
rename ndctl/lib/{ndctl-msft.h => msft.h} (100%)
rename ndctl/lib/{libndctl-private.h => private.h} (69%)
rename ndctl/lib/{libndctl-smart.c => smart.c} (99%)
create mode 100644 ndctl/namespace.h
delete mode 100644 util/fletcher.c
3 years, 4 months