|
|
5a1f83 |
ndctl: Revert "ndctl: Create ndctl udev rules for dirty shutdown"
|
|
|
5a1f83 |
|
|
|
5a1f83 |
BZ: 1637624
|
|
|
5a1f83 |
|
|
|
5a1f83 |
commit 5c67ce4d0b6a678c52f35a6a1e2dd14983076a19
|
|
|
5a1f83 |
Author: Dan Williams <dan.j.williams@intel.com>
|
|
|
5a1f83 |
Date: Thu Sep 27 17:41:53 2018 -0700
|
|
|
5a1f83 |
|
|
|
5a1f83 |
ndctl: Revert "ndctl: Create ndctl udev rules for dirty shutdown"
|
|
|
5a1f83 |
|
|
|
5a1f83 |
Environments that choose to implement dirty-shutdown mitigation can use
|
|
|
5a1f83 |
'list --dimm --health nmemX' to retrieve the dirty-shutdown count, or
|
|
|
5a1f83 |
the new 'nmemX/nfit/dirty_shutdown' attribute in sysfs. The kernel
|
|
|
5a1f83 |
otherwise takes no default action on that counter rolling. If the
|
|
|
5a1f83 |
platform advertises support for "Memory Controller Flush to NVDIMM
|
|
|
5a1f83 |
Durability on Power Loss Capable" then the default Linux policy is to
|
|
|
5a1f83 |
trust that designation.
|
|
|
5a1f83 |
|
|
|
5a1f83 |
Otherwise this usage of libndctl enumeration apis in the udev path
|
|
|
5a1f83 |
causes the entire udev queue to backup behind libnvdimm sub-system
|
|
|
5a1f83 |
initialization:
|
|
|
5a1f83 |
|
|
|
5a1f83 |
INFO: task systemd-udevd:1554 blocked for more than 120 seconds.
|
|
|
5a1f83 |
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
|
|
|
5a1f83 |
systemd-udevd D 0 1554 1544 0x80000004
|
|
|
5a1f83 |
Call Trace:
|
|
|
5a1f83 |
? __schedule+0x25d/0x870
|
|
|
5a1f83 |
schedule+0x28/0x80
|
|
|
5a1f83 |
async_synchronize_cookie_domain+0x96/0x140
|
|
|
5a1f83 |
? finish_wait+0x80/0x80
|
|
|
5a1f83 |
nvdimm_bus_check_dimm_count+0x31/0xa0 [libnvdimm]
|
|
|
5a1f83 |
acpi_nfit_register_dimms+0x4b5/0x800 [nfit]
|
|
|
5a1f83 |
acpi_nfit_init+0xca6/0x1300 [nfit]
|
|
|
5a1f83 |
? acpi_nfit_add+0x197/0x210 [nfit]
|
|
|
5a1f83 |
acpi_nfit_add+0x197/0x210 [nfit]
|
|
|
5a1f83 |
acpi_device_probe+0x48/0x110
|
|
|
5a1f83 |
|
|
|
5a1f83 |
Cc: Keith Busch <keith.busch@intel.com>
|
|
|
5a1f83 |
Cc: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
5a1f83 |
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
|
|
|
5a1f83 |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
5a1f83 |
|
|
|
5a1f83 |
diff -uprN ndctl-62/.gitignore ndctl-62.new/.gitignore
|
|
|
5a1f83 |
--- ndctl-62/.gitignore 2018-08-13 20:06:33.000000000 -0400
|
|
|
5a1f83 |
+++ ndctl-62.new/.gitignore 2018-10-09 11:55:10.410374923 -0400
|
|
|
5a1f83 |
@@ -25,7 +25,6 @@ daxctl/lib/libdaxctl.pc
|
|
|
5a1f83 |
*.a
|
|
|
5a1f83 |
ndctl/lib/libndctl.pc
|
|
|
5a1f83 |
ndctl/ndctl
|
|
|
5a1f83 |
-ndctl/ndctl-udev
|
|
|
5a1f83 |
rhel/
|
|
|
5a1f83 |
sles/ndctl.spec
|
|
|
5a1f83 |
util/log.lo
|
|
|
5a1f83 |
diff -uprN ndctl-62/Makefile.am ndctl-62.new/Makefile.am
|
|
|
5a1f83 |
--- ndctl-62/Makefile.am 2018-08-13 20:06:33.000000000 -0400
|
|
|
5a1f83 |
+++ ndctl-62.new/Makefile.am 2018-10-09 11:55:10.410374923 -0400
|
|
|
5a1f83 |
@@ -42,9 +42,6 @@ bashcompletiondir = $(BASH_COMPLETION_DI
|
|
|
5a1f83 |
dist_bashcompletion_DATA = contrib/ndctl
|
|
|
5a1f83 |
endif
|
|
|
5a1f83 |
|
|
|
5a1f83 |
-udevrulesdir = $(UDEVDIR)/rules.d
|
|
|
5a1f83 |
-dist_udevrules_DATA = contrib/80-ndctl.rules
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
noinst_LIBRARIES = libccan.a
|
|
|
5a1f83 |
libccan_a_SOURCES = \
|
|
|
5a1f83 |
ccan/str/str.h \
|
|
|
5a1f83 |
diff -uprN ndctl-62/configure.ac ndctl-62.new/configure.ac
|
|
|
5a1f83 |
--- ndctl-62/configure.ac 2018-08-13 20:06:33.000000000 -0400
|
|
|
5a1f83 |
+++ ndctl-62.new/configure.ac 2018-10-09 11:58:18.412932195 -0400
|
|
|
5a1f83 |
@@ -169,9 +169,6 @@ AC_ARG_WITH([tmpfilesdir],
|
|
|
5a1f83 |
[tmpfilesdir=$withval],
|
|
|
5a1f83 |
[tmpfilesdir="/run"])
|
|
|
5a1f83 |
|
|
|
5a1f83 |
-UDEVDIR="$(pkg-config udev --variable=udevdir)"
|
|
|
5a1f83 |
-AC_SUBST([UDEVDIR])
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
my_CFLAGS="\
|
|
|
5a1f83 |
-D DEF_CONF_FILE='\"${sysconfdir}/ndctl/monitor.conf\"' \
|
|
|
5a1f83 |
-D DEF_TMPFS_DIR='\"${tmpfilesdir}/ndctl\"' \
|
|
|
5a1f83 |
diff -uprN ndctl-62/configure.ac.orig ndctl-62.new/configure.ac.orig
|
|
|
5a1f83 |
--- ndctl-62/configure.ac.orig 1969-12-31 19:00:00.000000000 -0500
|
|
|
5a1f83 |
+++ ndctl-62.new/configure.ac.orig 2018-10-09 11:54:00.000000000 -0400
|
|
|
5a1f83 |
@@ -0,0 +1,223 @@
|
|
|
5a1f83 |
+AC_PREREQ(2.60)
|
|
|
5a1f83 |
+m4_include([version.m4])
|
|
|
5a1f83 |
+AC_INIT([ndctl],
|
|
|
5a1f83 |
+ GIT_VERSION,
|
|
|
5a1f83 |
+ [linux-nvdimm@lists.01.org],
|
|
|
5a1f83 |
+ [ndctl],
|
|
|
5a1f83 |
+ [https://github.com/pmem/ndctl])
|
|
|
5a1f83 |
+AC_CONFIG_SRCDIR([ndctl/lib/libndctl.c])
|
|
|
5a1f83 |
+AC_CONFIG_AUX_DIR([build-aux])
|
|
|
5a1f83 |
+AM_INIT_AUTOMAKE([
|
|
|
5a1f83 |
+ check-news
|
|
|
5a1f83 |
+ foreign
|
|
|
5a1f83 |
+ 1.11
|
|
|
5a1f83 |
+ -Wall
|
|
|
5a1f83 |
+ -Wno-portability
|
|
|
5a1f83 |
+ silent-rules
|
|
|
5a1f83 |
+ tar-pax
|
|
|
5a1f83 |
+ no-dist-gzip
|
|
|
5a1f83 |
+ dist-xz
|
|
|
5a1f83 |
+ subdir-objects
|
|
|
5a1f83 |
+])
|
|
|
5a1f83 |
+AC_PROG_CC_STDC
|
|
|
5a1f83 |
+AC_USE_SYSTEM_EXTENSIONS
|
|
|
5a1f83 |
+AC_SYS_LARGEFILE
|
|
|
5a1f83 |
+AC_CONFIG_MACRO_DIR([m4])
|
|
|
5a1f83 |
+AM_SILENT_RULES([yes])
|
|
|
5a1f83 |
+LT_INIT([
|
|
|
5a1f83 |
+ disable-static
|
|
|
5a1f83 |
+ pic-only
|
|
|
5a1f83 |
+])
|
|
|
5a1f83 |
+AC_PREFIX_DEFAULT([/usr])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_PROG_SED
|
|
|
5a1f83 |
+AC_PROG_MKDIR_P
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_ARG_ENABLE([docs],
|
|
|
5a1f83 |
+ AS_HELP_STRING([--disable-docs],
|
|
|
5a1f83 |
+ [disable documentation build @<:@default=enabled@:>@]),
|
|
|
5a1f83 |
+ [], enable_docs=yes)
|
|
|
5a1f83 |
+AS_IF([test "x$enable_docs" = "xyes"], [
|
|
|
5a1f83 |
+ AC_DEFINE(ENABLE_DOCS, [1], [Documentation / man pages.])
|
|
|
5a1f83 |
+])
|
|
|
5a1f83 |
+AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" = "xyes"])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_ARG_ENABLE([asciidoctor],
|
|
|
5a1f83 |
+ AS_HELP_STRING([--enable-asciidoctor],
|
|
|
5a1f83 |
+ [use asciidoctor for documentation build]),
|
|
|
5a1f83 |
+ [], enable_asciidoctor=no)
|
|
|
5a1f83 |
+AM_CONDITIONAL([USE_ASCIIDOCTOR], [test "x$enable_asciidoctor" = "xyes"])
|
|
|
5a1f83 |
+if test "x$enable_asciidoctor" = "xyes"; then
|
|
|
5a1f83 |
+ asciidoc="asciidoctor"
|
|
|
5a1f83 |
+else
|
|
|
5a1f83 |
+ asciidoc="asciidoc"
|
|
|
5a1f83 |
+fi
|
|
|
5a1f83 |
+AC_CHECK_PROG(ASCIIDOC, [$asciidoc], [$(which $asciidoc)], [missing])
|
|
|
5a1f83 |
+if test "x$ASCIIDOC" = xmissing -a "x$enable_docs" = "xyes"; then
|
|
|
5a1f83 |
+ AC_MSG_ERROR([$asciidoc needed to build documentation])
|
|
|
5a1f83 |
+fi
|
|
|
5a1f83 |
+AC_SUBST([ASCIIDOC])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+if test x"$asciidoc" = x"asciidoc"; then
|
|
|
5a1f83 |
+AC_CHECK_PROG(XMLTO, [xmlto], [$(which xmlto)], [missing])
|
|
|
5a1f83 |
+if test "x$XMLTO" = xmissing -a "x$enable_docs" = "xyes"; then
|
|
|
5a1f83 |
+ AC_MSG_ERROR([xmlto needed to build documentation])
|
|
|
5a1f83 |
+fi
|
|
|
5a1f83 |
+AC_SUBST([XMLTO])
|
|
|
5a1f83 |
+fi
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_C_TYPEOF
|
|
|
5a1f83 |
+AC_DEFINE([HAVE_STATEMENT_EXPR], 1, [Define to 1 if you have statement expressions.])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_C_BIGENDIAN(
|
|
|
5a1f83 |
+ AC_DEFINE(HAVE_BIG_ENDIAN, 1, [Define to 1 if big-endian-arch]),
|
|
|
5a1f83 |
+ AC_DEFINE(HAVE_LITTLE_ENDIAN, 1, [Define to 1 if little-endian-arch]),
|
|
|
5a1f83 |
+ [], [])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_ARG_ENABLE([logging],
|
|
|
5a1f83 |
+ AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
|
|
|
5a1f83 |
+ [], enable_logging=yes)
|
|
|
5a1f83 |
+AS_IF([test "x$enable_logging" = "xyes"], [
|
|
|
5a1f83 |
+ AC_DEFINE(ENABLE_LOGGING, [1], [System logging.])
|
|
|
5a1f83 |
+])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_ARG_ENABLE([debug],
|
|
|
5a1f83 |
+ AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
|
|
|
5a1f83 |
+ [], [enable_debug=no])
|
|
|
5a1f83 |
+AS_IF([test "x$enable_debug" = "xyes"], [
|
|
|
5a1f83 |
+ AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
|
|
|
5a1f83 |
+])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_ARG_ENABLE([destructive],
|
|
|
5a1f83 |
+ AS_HELP_STRING([--enable-destructive], [enable destructive functional tests @<:@default=disabled@:>@]),
|
|
|
5a1f83 |
+ [], [enable_destructive=no])
|
|
|
5a1f83 |
+AS_IF([test "x$enable_destructive" = "xyes"],
|
|
|
5a1f83 |
+ [AC_DEFINE([ENABLE_DESTRUCTIVE], [1], [destructive functional tests support])])
|
|
|
5a1f83 |
+AM_CONDITIONAL([ENABLE_DESTRUCTIVE], [test "x$enable_destructive" = "xyes"])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_ARG_ENABLE([test],
|
|
|
5a1f83 |
+ AS_HELP_STRING([--enable-test], [enable ndctl test command @<:@default=disabled@:>@]),
|
|
|
5a1f83 |
+ [], [enable_test=$enable_destructive])
|
|
|
5a1f83 |
+AS_IF([test "x$enable_test" = "xyes"],
|
|
|
5a1f83 |
+ [AC_DEFINE([ENABLE_TEST], [1], [ndctl test support])])
|
|
|
5a1f83 |
+AM_CONDITIONAL([ENABLE_TEST], [test "x$enable_test" = "xyes"])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_CHECK_DECLS([BUS_MCEERR_AR], [enable_bus_mc_err=yes], [], [[#include <signal.h>]])
|
|
|
5a1f83 |
+AC_CHECK_DECLS([MAP_SYNC], [enable_map_sync=yes], [], [[#include <linux/mman.h>]])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AS_IF([test "x$enable_bus_mc_err" = "xyes" -a "x$enable_map_sync" = "xyes"],
|
|
|
5a1f83 |
+ [AC_DEFINE([ENABLE_POISON], [1], [ndctl test poison support])])
|
|
|
5a1f83 |
+AM_CONDITIONAL([ENABLE_POISON],
|
|
|
5a1f83 |
+ [test "x$enable_bus_mc_err" = "xyes" -a "x$enable_map_sync" = "xyes"])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+PKG_CHECK_MODULES([KMOD], [libkmod])
|
|
|
5a1f83 |
+PKG_CHECK_MODULES([UUID], [uuid])
|
|
|
5a1f83 |
+PKG_CHECK_MODULES([JSON], [json-c])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_ARG_WITH([bash-completion-dir],
|
|
|
5a1f83 |
+ AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
|
|
|
5a1f83 |
+ [Install the bash auto-completion script in this directory. @<:@default=yes@:>@]),
|
|
|
5a1f83 |
+ [],
|
|
|
5a1f83 |
+ [with_bash_completion_dir=yes])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+if test "x$with_bash_completion_dir" = "xyes"; then
|
|
|
5a1f83 |
+ PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0],
|
|
|
5a1f83 |
+ [BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"],
|
|
|
5a1f83 |
+ [BASH_COMPLETION_DIR="$datadir/bash-completion/completions"])
|
|
|
5a1f83 |
+else
|
|
|
5a1f83 |
+ BASH_COMPLETION_DIR="$with_bash_completion_dir"
|
|
|
5a1f83 |
+fi
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_SUBST([BASH_COMPLETION_DIR])
|
|
|
5a1f83 |
+AM_CONDITIONAL([ENABLE_BASH_COMPLETION],[test "x$with_bash_completion_dir" != "xno"])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_ARG_ENABLE([local],
|
|
|
5a1f83 |
+ AS_HELP_STRING([--disable-local], [build against kernel ndctl.h @<:@default=system@:>@]),
|
|
|
5a1f83 |
+ [], [enable_local=yes])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_CHECK_HEADERS_ONCE([linux/version.h])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_CHECK_FUNCS([ \
|
|
|
5a1f83 |
+ __secure_getenv \
|
|
|
5a1f83 |
+ secure_getenv\
|
|
|
5a1f83 |
+])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+PKG_PROG_PKG_CONFIG
|
|
|
5a1f83 |
+AC_ARG_WITH([systemd-unit-dir],
|
|
|
5a1f83 |
+ AS_HELP_STRING([--with-systemd-unit-dir[=DIR]],
|
|
|
5a1f83 |
+ [Directory for systemd service files]),
|
|
|
5a1f83 |
+ [],
|
|
|
5a1f83 |
+ [with_systemd_unit_dir=yes])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+if test "x$with_systemd_unit_dir" = "xyes"; then
|
|
|
5a1f83 |
+ def_systemd_unit_dir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
|
|
|
5a1f83 |
+ if test "x$def_systemd_unit_dir" = "x"; then
|
|
|
5a1f83 |
+ AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])
|
|
|
5a1f83 |
+ with_systemd_unit_dir=no
|
|
|
5a1f83 |
+ else
|
|
|
5a1f83 |
+ with_systemd_unit_dir="$def_systemd_unit_dir"
|
|
|
5a1f83 |
+ fi
|
|
|
5a1f83 |
+fi
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AS_IF([test "x$with_systemd_unit_dir" != "xno"],
|
|
|
5a1f83 |
+ [AC_SUBST([systemd_unitdir], [$with_systemd_unit_dir])])
|
|
|
5a1f83 |
+AM_CONDITIONAL([ENABLE_SYSTEMD_UNIT_DIR], [test "x$with_systemd_unit_dir" != "xno"])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_ARG_WITH([tmpfilesdir],
|
|
|
5a1f83 |
+ [AS_HELP_STRING([--with-tmpfilesdir=DIR], [Directory for temporary runtime files])],
|
|
|
5a1f83 |
+ [tmpfilesdir=$withval],
|
|
|
5a1f83 |
+ [tmpfilesdir="/run"])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+my_CFLAGS="\
|
|
|
5a1f83 |
+-D DEF_CONF_FILE='\"${sysconfdir}/ndctl/monitor.conf\"' \
|
|
|
5a1f83 |
+-D DEF_TMPFS_DIR='\"${tmpfilesdir}/ndctl\"' \
|
|
|
5a1f83 |
+-Wall \
|
|
|
5a1f83 |
+-Wchar-subscripts \
|
|
|
5a1f83 |
+-Wformat-security \
|
|
|
5a1f83 |
+-Wmissing-declarations \
|
|
|
5a1f83 |
+-Wmissing-prototypes \
|
|
|
5a1f83 |
+-Wnested-externs \
|
|
|
5a1f83 |
+-Wpointer-arith \
|
|
|
5a1f83 |
+-Wshadow \
|
|
|
5a1f83 |
+-Wsign-compare \
|
|
|
5a1f83 |
+-Wstrict-prototypes \
|
|
|
5a1f83 |
+-Wtype-limits \
|
|
|
5a1f83 |
+-Wmaybe-uninitialized \
|
|
|
5a1f83 |
+-Wdeclaration-after-statement \
|
|
|
5a1f83 |
+-Wunused-result \
|
|
|
5a1f83 |
+-D_FORTIFY_SOURCE=2 \
|
|
|
5a1f83 |
+-O2
|
|
|
5a1f83 |
+"
|
|
|
5a1f83 |
+AC_SUBST([my_CFLAGS])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_CONFIG_HEADERS(config.h)
|
|
|
5a1f83 |
+AC_CONFIG_FILES([
|
|
|
5a1f83 |
+ Makefile
|
|
|
5a1f83 |
+ daxctl/lib/Makefile
|
|
|
5a1f83 |
+ ndctl/lib/Makefile
|
|
|
5a1f83 |
+ ndctl/Makefile
|
|
|
5a1f83 |
+ daxctl/Makefile
|
|
|
5a1f83 |
+ test/Makefile
|
|
|
5a1f83 |
+ Documentation/ndctl/Makefile
|
|
|
5a1f83 |
+ Documentation/daxctl/Makefile
|
|
|
5a1f83 |
+])
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+AC_OUTPUT
|
|
|
5a1f83 |
+AC_MSG_RESULT([
|
|
|
5a1f83 |
+ $PACKAGE $VERSION
|
|
|
5a1f83 |
+ =====
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+ prefix: ${prefix}
|
|
|
5a1f83 |
+ sysconfdir: ${sysconfdir}
|
|
|
5a1f83 |
+ libdir: ${libdir}
|
|
|
5a1f83 |
+ includedir: ${includedir}
|
|
|
5a1f83 |
+ systemd-unit-dir: ${systemd_unitdir}
|
|
|
5a1f83 |
+ tmpfilesdir: ${tmpfilesdir}
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+ compiler: ${CC}
|
|
|
5a1f83 |
+ cflags: ${CFLAGS}
|
|
|
5a1f83 |
+ ldflags: ${LDFLAGS}
|
|
|
5a1f83 |
+
|
|
|
5a1f83 |
+ logging: ${enable_logging}
|
|
|
5a1f83 |
+ debug: ${enable_debug}
|
|
|
5a1f83 |
+])
|
|
|
5a1f83 |
diff -uprN ndctl-62/contrib/80-ndctl.rules ndctl-62.new/contrib/80-ndctl.rules
|
|
|
5a1f83 |
--- ndctl-62/contrib/80-ndctl.rules 2018-08-13 20:06:33.000000000 -0400
|
|
|
5a1f83 |
+++ ndctl-62.new/contrib/80-ndctl.rules 1969-12-31 19:00:00.000000000 -0500
|
|
|
5a1f83 |
@@ -1,3 +0,0 @@
|
|
|
5a1f83 |
-# do not edit this file, it will be overwritten on update
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
-ACTION=="add", KERNEL=="nmem*", RUN+="ndctl-udev $kernel"
|
|
|
5a1f83 |
diff -uprN ndctl-62/ndctl/Makefile.am ndctl-62.new/ndctl/Makefile.am
|
|
|
5a1f83 |
--- ndctl-62/ndctl/Makefile.am 2018-08-13 20:06:33.000000000 -0400
|
|
|
5a1f83 |
+++ ndctl-62.new/ndctl/Makefile.am 2018-10-09 11:55:10.411374926 -0400
|
|
|
5a1f83 |
@@ -51,8 +51,3 @@ EXTRA_DIST += $(monitor_config_file)
|
|
|
5a1f83 |
if ENABLE_SYSTEMD_UNIT_DIR
|
|
|
5a1f83 |
systemd_unit_DATA = ndctl-monitor.service
|
|
|
5a1f83 |
endif
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
-ndctl_udevdir = $(UDEVDIR)
|
|
|
5a1f83 |
-ndctl_udev_PROGRAMS = ndctl-udev
|
|
|
5a1f83 |
-ndctl_udev_SOURCES = ndctl-udev.c
|
|
|
5a1f83 |
-ndctl_udev_LDADD = lib/libndctl.la
|
|
|
5a1f83 |
diff -uprN ndctl-62/ndctl/ndctl-udev.c ndctl-62.new/ndctl/ndctl-udev.c
|
|
|
5a1f83 |
--- ndctl-62/ndctl/ndctl-udev.c 2018-08-13 20:06:33.000000000 -0400
|
|
|
5a1f83 |
+++ ndctl-62.new/ndctl/ndctl-udev.c 1969-12-31 19:00:00.000000000 -0500
|
|
|
5a1f83 |
@@ -1,150 +0,0 @@
|
|
|
5a1f83 |
-/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
5a1f83 |
-/* Copyright(c) 2018 Intel Corporation. All rights reserved. */
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
-#include <ctype.h>
|
|
|
5a1f83 |
-#include <errno.h>
|
|
|
5a1f83 |
-#include <fcntl.h>
|
|
|
5a1f83 |
-#include <stddef.h>
|
|
|
5a1f83 |
-#include <stdio.h>
|
|
|
5a1f83 |
-#include <stdlib.h>
|
|
|
5a1f83 |
-#include <string.h>
|
|
|
5a1f83 |
-#include <sys/stat.h>
|
|
|
5a1f83 |
-#include <sys/types.h>
|
|
|
5a1f83 |
-#include <ndctl/libndctl.h>
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
-/**
|
|
|
5a1f83 |
- * mkdir_p
|
|
|
5a1f83 |
- *
|
|
|
5a1f83 |
- * Copied from util-linux lib/fileutils.c
|
|
|
5a1f83 |
- */
|
|
|
5a1f83 |
-static int mkdir_p(const char *path, mode_t mode)
|
|
|
5a1f83 |
-{
|
|
|
5a1f83 |
- char *p, *dir;
|
|
|
5a1f83 |
- int rc = 0;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- if (!path || !*path)
|
|
|
5a1f83 |
- return -EINVAL;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- dir = p = strdup(path);
|
|
|
5a1f83 |
- if (!dir)
|
|
|
5a1f83 |
- return -ENOMEM;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- if (*p == '/')
|
|
|
5a1f83 |
- p++;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- while (p && *p) {
|
|
|
5a1f83 |
- char *e = strchr(p, '/');
|
|
|
5a1f83 |
- if (e)
|
|
|
5a1f83 |
- *e = '\0';
|
|
|
5a1f83 |
- if (*p) {
|
|
|
5a1f83 |
- rc = mkdir(dir, mode);
|
|
|
5a1f83 |
- if (rc && errno != EEXIST)
|
|
|
5a1f83 |
- break;
|
|
|
5a1f83 |
- rc = 0;
|
|
|
5a1f83 |
- }
|
|
|
5a1f83 |
- if (!e)
|
|
|
5a1f83 |
- break;
|
|
|
5a1f83 |
- *e = '/';
|
|
|
5a1f83 |
- p = e + 1;
|
|
|
5a1f83 |
- }
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- free(dir);
|
|
|
5a1f83 |
- return rc;
|
|
|
5a1f83 |
-}
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
-static struct ndctl_dimm *find_dimm(struct ndctl_ctx *ctx, const char *devname)
|
|
|
5a1f83 |
-{
|
|
|
5a1f83 |
- struct ndctl_bus *bus;
|
|
|
5a1f83 |
- struct ndctl_dimm *dimm;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- ndctl_bus_foreach(ctx, bus) {
|
|
|
5a1f83 |
- ndctl_dimm_foreach(bus, dimm) {
|
|
|
5a1f83 |
- if (strcmp(ndctl_dimm_get_devname(dimm), devname) == 0)
|
|
|
5a1f83 |
- return dimm;
|
|
|
5a1f83 |
- }
|
|
|
5a1f83 |
- }
|
|
|
5a1f83 |
- return NULL;
|
|
|
5a1f83 |
-}
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
-static void ack_shutdown(struct ndctl_dimm *dimm)
|
|
|
5a1f83 |
-{
|
|
|
5a1f83 |
- struct ndctl_cmd *cmd;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- cmd = ndctl_dimm_cmd_new_ack_shutdown_count(dimm);
|
|
|
5a1f83 |
- if (!cmd)
|
|
|
5a1f83 |
- return;
|
|
|
5a1f83 |
- ndctl_cmd_submit(cmd);
|
|
|
5a1f83 |
- ndctl_cmd_unref(cmd);
|
|
|
5a1f83 |
-}
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
-static void save_unsafe_shutdown_count(struct ndctl_dimm *dimm,
|
|
|
5a1f83 |
- const char *devname)
|
|
|
5a1f83 |
-{
|
|
|
5a1f83 |
- char *path, *usc, count[16];
|
|
|
5a1f83 |
- unsigned int shutdown;
|
|
|
5a1f83 |
- struct ndctl_cmd *cmd;
|
|
|
5a1f83 |
- int fd;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- cmd = ndctl_dimm_cmd_new_smart(dimm);
|
|
|
5a1f83 |
- if (!cmd)
|
|
|
5a1f83 |
- return;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- if (ndctl_cmd_submit(cmd))
|
|
|
5a1f83 |
- goto unref_cmd;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- shutdown = ndctl_cmd_smart_get_shutdown_count(cmd);
|
|
|
5a1f83 |
- if (shutdown == UINT_MAX)
|
|
|
5a1f83 |
- goto unref_cmd;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- if (asprintf(&path, DEF_TMPFS_DIR "/%s", devname) < 0)
|
|
|
5a1f83 |
- goto unref_cmd;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- if (mkdir_p(path, 0755))
|
|
|
5a1f83 |
- goto free_path;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- if (asprintf(&usc, "%s/usc", path) < 0)
|
|
|
5a1f83 |
- goto free_path;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- fd = open(usc, O_WRONLY | O_CREAT, 0644);
|
|
|
5a1f83 |
- if (fd < 0)
|
|
|
5a1f83 |
- goto free_usc;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- if (snprintf(count, sizeof(count), "%u\n", shutdown) < 0)
|
|
|
5a1f83 |
- goto close_fd;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- if (write(fd, count, strlen(count)) < 0)
|
|
|
5a1f83 |
- goto close_fd;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- close_fd:
|
|
|
5a1f83 |
- close(fd);
|
|
|
5a1f83 |
- free_usc:
|
|
|
5a1f83 |
- free(usc);
|
|
|
5a1f83 |
- free_path:
|
|
|
5a1f83 |
- free(path);
|
|
|
5a1f83 |
- unref_cmd:
|
|
|
5a1f83 |
- ndctl_cmd_unref(cmd);
|
|
|
5a1f83 |
-}
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
-int main(int argc, char *argv[])
|
|
|
5a1f83 |
-{
|
|
|
5a1f83 |
- struct ndctl_ctx *ctx;
|
|
|
5a1f83 |
- struct ndctl_dimm *dimm = NULL;
|
|
|
5a1f83 |
- const char *devname;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- if (argc < 2)
|
|
|
5a1f83 |
- return EINVAL;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- devname = argv[1];
|
|
|
5a1f83 |
- if (ndctl_new(&ctx))
|
|
|
5a1f83 |
- return ENOMEM;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- dimm = find_dimm(ctx, devname);
|
|
|
5a1f83 |
- if (!dimm)
|
|
|
5a1f83 |
- return ENODEV;
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- ack_shutdown(dimm);
|
|
|
5a1f83 |
- save_unsafe_shutdown_count(dimm, devname);
|
|
|
5a1f83 |
-
|
|
|
5a1f83 |
- ndctl_unref(ctx);
|
|
|
5a1f83 |
- return 0;
|
|
|
5a1f83 |
-}
|
|
|
5a1f83 |
diff -uprN ndctl-62/ndctl.spec.in ndctl-62.new/ndctl.spec.in
|
|
|
5a1f83 |
--- ndctl-62/ndctl.spec.in 2018-08-13 20:06:33.000000000 -0400
|
|
|
5a1f83 |
+++ ndctl-62.new/ndctl.spec.in 2018-10-09 11:55:10.411374926 -0400
|
|
|
5a1f83 |
@@ -110,7 +110,6 @@ make check
|
|
|
5a1f83 |
%postun -n DAX_LNAME -p /sbin/ldconfig
|
|
|
5a1f83 |
|
|
|
5a1f83 |
%define bashcompdir %(pkg-config --variable=completionsdir bash-completion)
|
|
|
5a1f83 |
-%define udevdir %(pkg-config --variable=udevdir udev)
|
|
|
5a1f83 |
|
|
|
5a1f83 |
%files
|
|
|
5a1f83 |
%defattr(-,root,root)
|
|
|
5a1f83 |
@@ -120,8 +119,6 @@ make check
|
|
|
5a1f83 |
%{bashcompdir}/
|
|
|
5a1f83 |
%{_sysconfdir}/ndctl/monitor.conf
|
|
|
5a1f83 |
%{_unitdir}/ndctl-monitor.service
|
|
|
5a1f83 |
-%{_udevrulesdir}/80-ndctl.rules
|
|
|
5a1f83 |
-%{udevdir}/ndctl-udev
|
|
|
5a1f83 |
|
|
|
5a1f83 |
%files -n daxctl
|
|
|
5a1f83 |
%defattr(-,root,root)
|