From ab4840850d5fa210016c30843e5d50cbc3efc347 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 01 2017 03:28:50 +0000 Subject: import ndctl-56-2.el7 --- diff --git a/.gitignore b/.gitignore index f8f7b1e..c28ab3f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/ndctl-54.tar.gz +SOURCES/ndctl-56.tar.gz diff --git a/.ndctl.metadata b/.ndctl.metadata index 9050a1c..2986c08 100644 --- a/.ndctl.metadata +++ b/.ndctl.metadata @@ -1 +1 @@ -4378cd364f58621f6de1121cf03af2876261053f SOURCES/ndctl-54.tar.gz +99dbdae3609c85270dae0530aec0206e6ad36e88 SOURCES/ndctl-56.tar.gz diff --git a/SOURCES/22bffbe-daxctl-add-libuuid-to-the-build.patch b/SOURCES/22bffbe-daxctl-add-libuuid-to-the-build.patch new file mode 100644 index 0000000..4e6543a --- /dev/null +++ b/SOURCES/22bffbe-daxctl-add-libuuid-to-the-build.patch @@ -0,0 +1,26 @@ +daxctl: add libuuid to the build + +BZ: + +commit 22bffbecb16d2aa7ed072fb55a18445977ee16b8 +Author: Dan Williams +Date: Mon Feb 13 21:01:25 2017 -0800 + + daxctl: add libuuid to the build + + daxctl does have dependencies on the uuid library via util/json.c, but + the build only seems to fail in a Debian build environment. Fix this up. + + Reported-by: Yilong Ren + Signed-off-by: Dan Williams + +diff --git a/daxctl/Makefile.am b/daxctl/Makefile.am +index 9153c41..fe467d0 100644 +--- a/daxctl/Makefile.am ++++ b/daxctl/Makefile.am +@@ -10,4 +10,5 @@ daxctl_SOURCES =\ + daxctl_LDADD =\ + lib/libdaxctl.la \ + ../libutil.a \ ++ $(UUID_LIBS) \ + $(JSON_LIBS) diff --git a/SOURCES/2cf2acc-libndctl-add-support-for-the-MSFT-family-of-DSM-functions.patch b/SOURCES/2cf2acc-libndctl-add-support-for-the-MSFT-family-of-DSM-functions.patch new file mode 100644 index 0000000..7b2c9db --- /dev/null +++ b/SOURCES/2cf2acc-libndctl-add-support-for-the-MSFT-family-of-DSM-functions.patch @@ -0,0 +1,301 @@ +libndctl: add support for the MSFT family of DSM functions + +BZ: + +commit 2cf2acca0288389a39ac823a42a5e048575d52db +Author: Lijun Pan +Date: Thu Apr 6 12:17:38 2017 -0500 + + libndctl: add support for the MSFT family of DSM functions + + This patch retrieves the health data from NVDIMM-N via + the MSFT _DSM function[1], following JESD245A[2] standards. + Now 'ndctl list --dimms --health --idle' could work + on MSFT type NVDIMM-N, but limited to health_state, + temperature_celsius, and life_used_percentage. + + Sample output of 'ndclt list --dimms --health --idle' + { + "dev":"nmem0", + "id":"802c-0f-1711-1648dd20", + "state":"disabled", + "health":{ + "health_state":"ok", + "temperature_celsius":27.000000, + "life_used_percentage":3 + } + } + + [1]. https://msdn.microsoft.com/library/windows/hardware/mt604741 + [2]. https://www.jedec.org/sites/default/files/docs/JESD245A.pdf + + Cc: Stuart Hayes + Signed-off-by: Lijun Pan + Tested-by: Linda Knippers + Signed-off-by: Dan Williams + +diff -up ndctl-56/ndctl/lib/Makefile.am.orig ndctl-56/ndctl/lib/Makefile.am +--- ndctl-56/ndctl/lib/Makefile.am.orig 2017-02-07 16:16:07.000000000 -0500 ++++ ndctl-56/ndctl/lib/Makefile.am 2017-05-24 15:41:41.203723211 -0400 +@@ -32,6 +32,7 @@ endif + if ENABLE_SMART + libndctl_la_SOURCES += libndctl-smart.c + libndctl_la_SOURCES += libndctl-hpe1.c ++libndctl_la_SOURCES += libndctl-msft.c + endif + + EXTRA_DIST += libndctl.sym +diff -up ndctl-56/ndctl/lib/libndctl-msft.c.orig ndctl-56/ndctl/lib/libndctl-msft.c +--- ndctl-56/ndctl/lib/libndctl-msft.c.orig 2017-05-24 15:41:41.205723213 -0400 ++++ ndctl-56/ndctl/lib/libndctl-msft.c 2017-05-24 15:41:41.204723212 -0400 +@@ -0,0 +1,140 @@ ++/* ++ * Copyright (C) 2016-2017 Dell, Inc. ++ * Copyright (C) 2016 Hewlett Packard Enterprise Development LP ++ * Copyright (c) 2016, Intel Corporation. ++ * ++ * This program is free software; you can redistribute it and/or modify it ++ * under the terms and conditions of the GNU Lesser General Public License, ++ * version 2.1, as published by the Free Software Foundation. ++ * ++ * This program is distributed in the hope it will be useful, but WITHOUT ANY ++ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ++ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ++ * more details. ++ */ ++#include ++#include ++#include ++#include ++#include "libndctl-private.h" ++#include "ndctl-msft.h" ++ ++#define CMD_MSFT(_c) ((_c)->msft) ++#define CMD_MSFT_SMART(_c) (CMD_MSFT(_c)->u.smart.data) ++ ++static struct ndctl_cmd *msft_dimm_cmd_new_smart(struct ndctl_dimm *dimm) ++{ ++ struct ndctl_bus *bus = ndctl_dimm_get_bus(dimm); ++ struct ndctl_ctx *ctx = ndctl_bus_get_ctx(bus); ++ struct ndctl_cmd *cmd; ++ size_t size; ++ struct ndn_pkg_msft *msft; ++ ++ if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_CALL)) { ++ dbg(ctx, "unsupported cmd\n"); ++ return NULL; ++ } ++ ++ size = sizeof(*cmd) + sizeof(struct ndn_pkg_msft); ++ cmd = calloc(1, size); ++ if (!cmd) ++ return NULL; ++ ++ cmd->dimm = dimm; ++ ndctl_cmd_ref(cmd); ++ cmd->type = ND_CMD_CALL; ++ cmd->size = size; ++ cmd->status = 1; ++ ++ msft = CMD_MSFT(cmd); ++ msft->gen.nd_family = NVDIMM_FAMILY_MSFT; ++ msft->gen.nd_command = NDN_MSFT_CMD_SMART; ++ msft->gen.nd_fw_size = 0; ++ msft->gen.nd_size_in = offsetof(struct ndn_msft_smart, status); ++ msft->gen.nd_size_out = sizeof(msft->u.smart); ++ msft->u.smart.status = 0; ++ ++ cmd->firmware_status = &msft->u.smart.status; ++ ++ return cmd; ++} ++ ++static int msft_smart_valid(struct ndctl_cmd *cmd) ++{ ++ if (cmd->type != ND_CMD_CALL || ++ cmd->size != sizeof(*cmd) + sizeof(struct ndn_pkg_msft) || ++ CMD_MSFT(cmd)->gen.nd_family != NVDIMM_FAMILY_MSFT || ++ CMD_MSFT(cmd)->gen.nd_command != NDN_MSFT_CMD_SMART || ++ cmd->status != 0) ++ return cmd->status < 0 ? cmd->status : -EINVAL; ++ return 0; ++} ++ ++static unsigned int msft_cmd_smart_get_flags(struct ndctl_cmd *cmd) ++{ ++ if (msft_smart_valid(cmd) < 0) ++ return UINT_MAX; ++ ++ /* below health data can be retrieved via MSFT _DSM function 11 */ ++ return NDN_MSFT_SMART_HEALTH_VALID | ++ NDN_MSFT_SMART_TEMP_VALID | ++ NDN_MSFT_SMART_USED_VALID; ++} ++ ++static unsigned int num_set_bit_health(__u16 num) ++{ ++ int i; ++ __u16 n = num & 0x7FFF; ++ unsigned int count = 0; ++ ++ for (i = 0; i < 15; i++) ++ if (!!(n & (1 << i))) ++ count++; ++ ++ return count; ++} ++ ++static unsigned int msft_cmd_smart_get_health(struct ndctl_cmd *cmd) ++{ ++ unsigned int health; ++ unsigned int num; ++ ++ if (msft_smart_valid(cmd) < 0) ++ return UINT_MAX; ++ ++ num = num_set_bit_health(CMD_MSFT_SMART(cmd)->health); ++ if (num == 0) ++ health = 0; ++ else if (num < 2) ++ health = ND_SMART_NON_CRITICAL_HEALTH; ++ else if (num < 3) ++ health = ND_SMART_CRITICAL_HEALTH; ++ else ++ health = ND_SMART_FATAL_HEALTH; ++ ++ return health; ++} ++ ++static unsigned int msft_cmd_smart_get_temperature(struct ndctl_cmd *cmd) ++{ ++ if (msft_smart_valid(cmd) < 0) ++ return UINT_MAX; ++ ++ return CMD_MSFT_SMART(cmd)->temp * 16; ++} ++ ++static unsigned int msft_cmd_smart_get_life_used(struct ndctl_cmd *cmd) ++{ ++ if (msft_smart_valid(cmd) < 0) ++ return UINT_MAX; ++ ++ return 100 - CMD_MSFT_SMART(cmd)->nvm_lifetime; ++} ++ ++struct ndctl_smart_ops * const msft_smart_ops = &(struct ndctl_smart_ops) { ++ .new_smart = msft_dimm_cmd_new_smart, ++ .smart_get_flags = msft_cmd_smart_get_flags, ++ .smart_get_health = msft_cmd_smart_get_health, ++ .smart_get_temperature = msft_cmd_smart_get_temperature, ++ .smart_get_life_used = msft_cmd_smart_get_life_used, ++}; +diff -up ndctl-56/ndctl/lib/libndctl-private.h.orig ndctl-56/ndctl/lib/libndctl-private.h +--- ndctl-56/ndctl/lib/libndctl-private.h.orig 2017-02-07 16:16:07.000000000 -0500 ++++ ndctl-56/ndctl/lib/libndctl-private.h 2017-05-24 15:41:41.206723214 -0400 +@@ -32,6 +32,7 @@ + #include + #include + #include "ndctl-hpe1.h" ++#include "ndctl-msft.h" + + #define SZ_16M 0x01000000 + +@@ -196,6 +197,7 @@ struct ndctl_cmd { + struct nd_cmd_clear_error clear_err[0]; + #endif + struct ndn_pkg_hpe1 hpe1[0]; ++ struct ndn_pkg_msft msft[0]; + struct nd_cmd_smart smart[0]; + struct nd_cmd_smart_threshold smart_t[0]; + struct nd_cmd_get_config_size get_size[0]; +@@ -226,9 +228,11 @@ struct ndctl_smart_ops { + #if HAS_SMART == 1 + struct ndctl_smart_ops * const intel_smart_ops; + struct ndctl_smart_ops * const hpe1_smart_ops; ++struct ndctl_smart_ops * const msft_smart_ops; + #else + static struct ndctl_smart_ops * const intel_smart_ops = NULL; + static struct ndctl_smart_ops * const hpe1_smart_ops = NULL; ++static struct ndctl_smart_ops * const msft_smart_ops = NULL; + #endif + + /* internal library helpers for conditionally defined command numbers */ +diff -up ndctl-56/ndctl/lib/libndctl.c.orig ndctl-56/ndctl/lib/libndctl.c +--- ndctl-56/ndctl/lib/libndctl.c.orig 2017-02-07 16:16:07.000000000 -0500 ++++ ndctl-56/ndctl/lib/libndctl.c 2017-05-24 15:41:41.208723216 -0400 +@@ -1254,6 +1254,8 @@ static void *add_dimm(void *parent, int + dimm->dsm_family = strtoul(buf, NULL, 0); + if (dimm->dsm_family == NVDIMM_FAMILY_HPE1) + dimm->smart_ops = hpe1_smart_ops; ++ if (dimm->dsm_family == NVDIMM_FAMILY_MSFT) ++ dimm->smart_ops = msft_smart_ops; + + dimm->formats = formats; + sprintf(path, "%s/nfit/format", dimm_base); +diff -up ndctl-56/ndctl/lib/ndctl-msft.h.orig ndctl-56/ndctl/lib/ndctl-msft.h +--- ndctl-56/ndctl/lib/ndctl-msft.h.orig 2017-05-24 15:41:41.210723218 -0400 ++++ ndctl-56/ndctl/lib/ndctl-msft.h 2017-05-24 15:41:41.209723217 -0400 +@@ -0,0 +1,63 @@ ++/* ++ * Copyright (C) 2016-2017 Dell, Inc. ++ * Copyright (C) 2016 Hewlett Packard Enterprise Development LP ++ * Copyright (c) 2014-2015, Intel Corporation. ++ * ++ * This program is free software; you can redistribute it and/or modify it ++ * under the terms and conditions of the GNU Lesser General Public License, ++ * version 2.1, as published by the Free Software Foundation. ++ * ++ * This program is distributed in the hope it will be useful, but WITHOUT ANY ++ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ++ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ++ * more details. ++ */ ++#ifndef __NDCTL_MSFT_H__ ++#define __NDCTL_MSFT_H__ ++ ++enum { ++ NDN_MSFT_CMD_QUERY = 0, ++ ++ /* non-root commands */ ++ NDN_MSFT_CMD_SMART = 11, ++}; ++ ++/* NDN_MSFT_CMD_SMART */ ++#define NDN_MSFT_SMART_HEALTH_VALID ND_SMART_HEALTH_VALID ++#define NDN_MSFT_SMART_TEMP_VALID ND_SMART_TEMP_VALID ++#define NDN_MSFT_SMART_USED_VALID ND_SMART_USED_VALID ++ ++/* ++ * This is actually function 11 data, ++ * This is the closest I can find to match smart ++ * Microsoft _DSM does not have smart function ++ */ ++struct ndn_msft_smart_data { ++ __u16 health; ++ __u16 temp; ++ __u8 err_thresh_stat; ++ __u8 warn_thresh_stat; ++ __u8 nvm_lifetime; ++ __u8 count_dram_uncorr_err; ++ __u8 count_dram_corr_err; ++} __attribute__((packed)); ++ ++struct ndn_msft_smart { ++ __u32 status; ++ union { ++ __u8 buf[9]; ++ struct ndn_msft_smart_data data[0]; ++ }; ++} __attribute__((packed)); ++ ++union ndn_msft_cmd { ++ __u32 query; ++ struct ndn_msft_smart smart; ++} __attribute__((packed)); ++ ++struct ndn_pkg_msft { ++ struct nd_cmd_pkg gen; ++ union ndn_msft_cmd u; ++} __attribute__((packed)); ++ ++#endif /* __NDCTL_MSFT_H__ */ diff --git a/SOURCES/77d84b2-ndctl-create-namespace-include-dax-info-in-operation-result.patch b/SOURCES/77d84b2-ndctl-create-namespace-include-dax-info-in-operation-result.patch new file mode 100644 index 0000000..7b962e7 --- /dev/null +++ b/SOURCES/77d84b2-ndctl-create-namespace-include-dax-info-in-operation-result.patch @@ -0,0 +1,59 @@ +ndctl, create-namespace: include dax info in operation result + +BZ: + +commit 77d84b249ef51b6dbccd988e42ce2ab2962a9b36 +Author: Dan Williams +Date: Thu Mar 2 14:10:11 2017 -0800 + + ndctl, create-namespace: include dax info in operation result + + When modifying or creating a namespace in "dax" mode, include the + device-dax information so that resulting character device is included in + the output. + + Before: + # ndctl create-namespace --reconfig=namespace1.0 --mode=dax --force + { + "dev":"namespace1.0", + "mode":"dax", + "size":4225761280, + "uuid":"55082055-70f8-40eb-b131-d59f6f537df5" + } + + After: + # ndctl create-namespace --reconfig=namespace1.0 --mode=dax --force + { + "dev":"namespace1.0", + "mode":"dax", + "size":4225761280, + "uuid":"1ccc310a-04af-4a57-88a4-6011c2825b95", + "daxregion":{ + "id":1, + "size":4225761280, + "align":2097152, + "devices":[ + { + "chardev":"dax1.0", + "size":4225761280 + } + ] + } + } + + Reported-by: Dave Jiang + Signed-off-by: Dan Williams + +diff --git a/ndctl/builtin-xaction-namespace.c b/ndctl/builtin-xaction-namespace.c +index 46d651e..05575c5 100644 +--- a/ndctl/builtin-xaction-namespace.c ++++ b/ndctl/builtin-xaction-namespace.c +@@ -361,7 +361,7 @@ static int setup_namespace(struct ndctl_region *region, + error("%s: failed to enable\n", + ndctl_namespace_get_devname(ndns)); + } else { +- struct json_object *jndns = util_namespace_to_json(ndns, 0, 0); ++ struct json_object *jndns = util_namespace_to_json(ndns, 0, 1); + + if (jndns) + printf("%s\n", json_object_to_json_string_ext(jndns, diff --git a/SOURCES/rhel-ndctl-document-4k-alignment-default.patch b/SOURCES/rhel-ndctl-document-4k-alignment-default.patch new file mode 100644 index 0000000..a837974 --- /dev/null +++ b/SOURCES/rhel-ndctl-document-4k-alignment-default.patch @@ -0,0 +1,11 @@ +--- ndctl-56.vanilla/Documentation/ndctl-create-namespace.txt 2017-03-26 16:15:46.619381006 -0400 ++++ ndctl-56/Documentation/ndctl-create-namespace.txt 2017-05-24 15:03:41.711314927 -0400 +@@ -93,7 +93,7 @@ OPTIONS + Applications that want to establish DAX memory mappings + with page table entries greater than 4K in size need a + persistent memory namespace that is sufficiently aligned. For +- "memory" and "dax" mode this defaults to 2M. Note that "dax" ++ "memory" and "dax" mode this defaults to 4K. Note that "dax" + mode enforces all mappings to be aligned to this value, + i.e. fails unaligned mapping attempts. + diff --git a/SOURCES/rhel-ndctl-limit-device-dax-to-4k-by-default.patch b/SOURCES/rhel-ndctl-limit-device-dax-to-4k-by-default.patch new file mode 100644 index 0000000..4339ccb --- /dev/null +++ b/SOURCES/rhel-ndctl-limit-device-dax-to-4k-by-default.patch @@ -0,0 +1,13 @@ +diff -upr ndctl-56.vanilla/ndctl/builtin-xaction-namespace.c ndctl-56/ndctl/builtin-xaction-namespace.c +--- ndctl-56.vanilla/ndctl/builtin-xaction-namespace.c 2017-03-26 16:15:54.957274589 -0400 ++++ ndctl-56/ndctl/builtin-xaction-namespace.c 2017-03-26 16:16:32.671793238 -0400 +@@ -213,7 +213,7 @@ static int set_defaults(enum namespace_a + param.align); + rc = -EINVAL; + } else if (!param.align) { +- param.align = "2M"; ++ param.align = "4K"; + param.align_default = true; + } + +Only in ndctl-56/ndctl: builtin-xaction-namespace.c.orig diff --git a/SPECS/ndctl.spec b/SPECS/ndctl.spec index 7ce06d9..e3b1795 100644 --- a/SPECS/ndctl.spec +++ b/SPECS/ndctl.spec @@ -1,11 +1,16 @@ Name: ndctl -Version: 54 -Release: 1%{?dist} +Version: 56 +Release: 2%{?dist} Summary: Manage "libnvdimm" subsystem devices (Non-volatile Memory) License: GPLv2 Group: System Environment/Base Url: https://github.com/pmem/ndctl Source0: https://github.com/pmem/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz +Patch0: 22bffbe-daxctl-add-libuuid-to-the-build.patch +Patch1: 77d84b2-ndctl-create-namespace-include-dax-info-in-operation-result.patch +Patch2: rhel-ndctl-limit-device-dax-to-4k-by-default.patch +Patch3: rhel-ndctl-document-4k-alignment-default.patch +Patch4: 2cf2acc-libndctl-add-support-for-the-MSFT-family-of-DSM-functions.patch Requires: ndctl-libs%{?_isa} = %{version}-%{release} Requires: daxctl-libs%{?_isa} = %{version}-%{release} @@ -38,6 +43,18 @@ Requires: ndctl-libs%{?_isa} = %{version}-%{release} The %{name}-devel package contains libraries and header files for developing applications that use %{name}. +%package -n daxctl +Summary: Manage Device-DAX instances +License: GPLv2 +Group: System Environment/Base +Requires: daxctl-libs%{?_isa} = %{version}-%{release} + +%description -n daxctl +The daxctl utility provides enumeration and provisioning commands for +the Linux kernel Device-DAX facility. This facility enables DAX mappings +of performance / feature differentiated memory without need of a +filesystem. + %package -n daxctl-devel Summary: Development files for libdaxctl License: LGPLv2 @@ -74,6 +91,11 @@ control API for these devices. %prep %setup -q ndctl-%{version} +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 %build echo %{version} > version @@ -99,35 +121,54 @@ make check %define bashcompdir %(pkg-config --variable=completionsdir bash-completion) %files -%license licenses/GPLv2 licenses/BSD-MIT licenses/CC0 +%license util/COPYING licenses/BSD-MIT licenses/CC0 %{_bindir}/ndctl -%{_mandir}/man1/* +%{_mandir}/man1/ndctl* %{bashcompdir}/ +%files -n daxctl +%license util/COPYING licenses/BSD-MIT licenses/CC0 +%{_bindir}/daxctl +%{_mandir}/man1/daxctl* + %files -n ndctl-libs %doc README.md -%license COPYING licenses/BSD-MIT licenses/CC0 +%license util/COPYING licenses/BSD-MIT licenses/CC0 %{_libdir}/libndctl.so.* %files -n daxctl-libs %doc README.md -%license COPYING licenses/BSD-MIT licenses/CC0 +%license util/COPYING licenses/BSD-MIT licenses/CC0 %{_libdir}/libdaxctl.so.* %files -n ndctl-devel -%license COPYING +%license util/COPYING %{_includedir}/ndctl/ %{_libdir}/libndctl.so %{_libdir}/pkgconfig/libndctl.pc %files -n daxctl-devel -%license COPYING +%license util/COPYING %{_includedir}/daxctl/ %{_libdir}/libdaxctl.so %{_libdir}/pkgconfig/libdaxctl.pc %changelog +* Tue May 30 2017 Jeff Moyer - 56-2 +- bump release +- Related: bz#1440902 bz#1446689 + +* Wed May 24 2017 Jeff Moyer - 56-2 +- Update documentation to reflect 4k alignment +- Add support for the MSFT family of DSM functions +- Resolves: bz#1440902 bz#1446689 + +* Sun Mar 26 2017 Jeff Moyer - 56-1 +- Rebase to upstream version 56 +- Default to 4k alignment for device dax +- Resolves: bz#1384873 bz#1384642 bz#1349233 bz#1357451 + * Mon Aug 29 2016 Dave Anderson - 54.1 - Update to 54.1 to address ixpdimm_sw requirements - Resolves bz#1271425