Skip to contentSkip to conversation

smart support and 'list' enhancements

PATCH In review Dan Williams 2 participants 16 messages Apr 7, 2016 – Apr 8, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover smart support and 'list' enhancements

1/ Provide helper routines for higher level management software to issue
SMART data retrieval commands.

2/ Add a reference implementation of SMART data retrieval by extending
the 'list' command to emit json with SMART key/value data.

3/ With health information available it is useful to know which
namespaces are impacted by a dimm that reports a bad health status, so a 'filter by dimm' mechanism is added to the 'list' command.

---

Dan Williams (5):
ndctl: rebuild libndctl.h when libndctl.h.in changes
ndctl: helper for S.M.A.R.T. data retrieval ndctl, list: clean up default behavior ndctl, list: add a '--health' option
ndctl, list: add 'filter by dimm' capability

 Documentation/ndctl-list.txt |   29 ++++++++++++-
 Makefile.am                  |    8 +++
 builtin-list.c               |   31 +++++++++++--
 configure.ac                 |   26 +++++++++++
 lib/libndctl-private.h       |    1 
 lib/libndctl-smart.c         |   81 +++++++++++++++++++++++++++++++++++
 lib/libndctl.c               |    1 
 lib/libndctl.sym             |   10 ++++
 lib/ndctl/libndctl.h.in      |   55 ++++++++++++++++++++++++
 ndctl.h                      |   29 +++++++++++++
 test/libndctl.c              |   68 +++++++++++++++++++++++++++++
 util/filter.c                |   83 ++++++++++++++++++++++++++++++++++++
 util/filter.h                |    5 ++
 util/json.c                  |   97 ++++++++++++++++++++++++++++++++++++++++++
 util/json.h                  |    1 
 15 files changed, 516 insertions(+), 9 deletions(-)
 create mode 100644 lib/libndctl-smart.c

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#1 lore raw

PATCH 1/5 ndctl: rebuild libndctl.h when libndctl.h.in changes

Since libnctl.h is build via an AC_CONFIG_COMMANDS() statement we want configure to re-run if libndctl.h.in is changed.

---
 Makefile.am |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile.am +3 -1
index 7de3d3c3c9eb..379f6404671f 100644
@@ -29,7 +29,9 @@ AM_LDFLAGS = \
 	-Wl,--gc-sections \
 	-Wl,--as-needed
 
-BUILT_SOURCES = $(top_srcdir)/version.m4
+BUILT_SOURCES = $(top_srcdir)/version.m4 $(top_srcdir)/lib/ndctl/libndctl.h
+$(top_srcdir)/lib/ndctl/libndctl.h: $(top_srcdir)/lib/ndctl/libndctl.h.in
+	touch $(top_srcdir)/version.m4
 $(top_srcdir)/version.m4: FORCE
 	$(AM_V_GEN)$(top_srcdir)/git-version-gen
 

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reviewed-by on v1 1/5
#2 lore raw

Re: [ndctl PATCH 1/5] ndctl: rebuild libndctl.h when libndctl.h.in changes

Quoted 5 lines · On Mittwoch, 6. April 2016 18:07:04 CEST Dan Williams wrote:

Since libnctl.h is build via an AC_CONFIG_COMMANDS() statement we want configure to re-run if libndctl.h.in is changed.

---

Looks good,

Signature · 11 lines
Johannes Thumshirn                                          Storage
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#3 lore raw

PATCH 2/5 ndctl: helper for S.M.A.R.T. data retrieval

In reply to Dan Williams

Helper functions to issue the "SMART and Health Info (Function Index 1)" DSM and parse its results.

http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf

---
 Makefile.am             |    4 ++
 configure.ac            |   26 +++++++++++++++
 lib/libndctl-private.h  |    1 +
 lib/libndctl-smart.c    |   81 +++++++++++++++++++++++++++++++++++++++++++++++
 lib/libndctl.c          |    1 +
 lib/libndctl.sym        |   10 ++++++
 lib/ndctl/libndctl.h.in |   55 ++++++++++++++++++++++++++++++++
 ndctl.h                 |   29 +++++++++++++++++
 test/libndctl.c         |   68 +++++++++++++++++++++++++++++++++++++++
 9 files changed, 274 insertions(+), 1 deletion(-)
 create mode 100644 lib/libndctl-smart.c
Makefile.am +4 -0
index 379f6404671f..9c6b37410642 100644
@@ -85,6 +85,10 @@ if ENABLE_ARS
 lib_libndctl_la_SOURCES += lib/libndctl-ars.c
 endif
 
+if ENABLE_SMART
+lib_libndctl_la_SOURCES += lib/libndctl-smart.c
+endif
+
 bin_PROGRAMS = ndctl
 
 ndctl_SOURCES = ndctl.c \
configure.ac +26 -0
index 1ab376885215..01f347a7f137 100644
@@ -144,6 +144,25 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 )
 AM_CONDITIONAL([ENABLE_CLEAR_ERROR], [test "x$enable_clear_err" = "xyes"])
 
+AC_MSG_CHECKING([for SMART support])
+AC_LANG(C)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+			#ifdef HAVE_NDCTL_H
+			#include <linux/ndctl.h>
+			#else
+			#include "ndctl.h"
+			#endif
+			]], [[
+			int x = ND_SMART_HEALTH_VALID;
+			]]
+		)], [AC_MSG_RESULT([yes])
+		     enable_smart=yes
+		     AC_DEFINE([HAVE_NDCTL_SMART], [1],
+				[Define to 1 if ndctl.h has SMART support.])
+		], [AC_MSG_RESULT([no])]
+)
+AM_CONDITIONAL([ENABLE_SMART], [test "x$enable_smart" = "xyes"])
+
 AC_CONFIG_COMMANDS([gen-libndctl.h],
 		[[
 		if test "x$enable_ars" = "xyes"; then
@@ -151,17 +170,24 @@ AC_CONFIG_COMMANDS([gen-libndctl.h],
 		else
 			enable_ars=0
 		fi
+		if test "x$enable_smart" = "xyes"; then
+			enable_smart=1
+		else
+			enable_smart=0
+		fi
 		if test "x$enable_clear_err" = "xyes"; then
 			enable_clear_err=1
 		else
 			enable_clear_err=0
 		fi
 		sed -e s/HAVE_NDCTL_ARS/$enable_ars/ \
+		    -e s/HAVE_NDCTL_SMART/$enable_smart/ \
 		    -e s/HAVE_NDCTL_CLEAR_ERROR/$enable_clear_err/ \
 		< lib/ndctl/libndctl.h.in > lib/ndctl/libndctl.h
 		]],
 		[[
 		enable_ars=$enable_ars
+		enable_smart=$enable_smart
 		enable_clear_err=$enable_clear_err
 		]])
 
lib/libndctl-private.h +1 -0
index 50b03743751f..37aed296a571 100644
@@ -167,6 +167,7 @@ struct ndctl_cmd {
 #ifdef HAVE_NDCTL_CLEAR_ERROR
 		struct nd_cmd_clear_error clear_err[0];
 #endif
+		struct nd_cmd_smart smart[0];
 		struct nd_cmd_get_config_size get_size[0];
 		struct nd_cmd_get_config_data_hdr get_data[0];
 		struct nd_cmd_set_config_hdr set_data[0];
lib/libndctl-smart.c new file +81 -0

81 lines not on this page · raw message

lib/libndctl.c +1 -0
index 26de91af8a63..c25107f3eba7 100644
@@ -26,6 +26,7 @@
 #include <ccan/list/list.h>
 #include <ccan/minmax/minmax.h>
 #include <ccan/array_size/array_size.h>
+#include <ccan/build_assert/build_assert.h>
 
 #ifdef HAVE_NDCTL_H
 #include <linux/ndctl.h>
lib/libndctl.sym +10 -0
index 5ff8848ee6d3..2a0d36d89f67 100644
@@ -86,6 +86,16 @@ global:
 	ndctl_dimm_cmd_new_cfg_size;
 	ndctl_dimm_cmd_new_cfg_read;
 	ndctl_dimm_cmd_new_cfg_write;
+	ndctl_dimm_cmd_new_smart;
+	ndctl_cmd_smart_get_flags;
+	ndctl_cmd_smart_get_health;
+	ndctl_cmd_smart_get_temperature;
+	ndctl_cmd_smart_get_spares;
+	ndctl_cmd_smart_get_alarm_flags;
+	ndctl_cmd_smart_get_life_used;
+	ndctl_cmd_smart_get_shutdown_state;
+	ndctl_cmd_smart_get_vendor_size;
+	ndctl_cmd_smart_get_vendor_data;
 	ndctl_dimm_zero_labels;
 	ndctl_dimm_get_available_labels;
 	ndctl_region_get_first;
lib/ndctl/libndctl.h.in +55 -0

61 lines not on this page · raw message

ndctl.h +29 -0
index 69b8e707fc49..445b4d6d4df0 100644
@@ -20,6 +20,35 @@ struct nd_cmd_smart {
 	__u8 data[128];
 } __attribute__((packed));
 
+enum {
+	ND_SMART_HEALTH_VALID	= 1 << 0,
+	ND_SMART_TEMP_VALID 	= 1 << 1,
+	ND_SMART_SPARES_VALID	= 1 << 2,
+	ND_SMART_ALARM_VALID	= 1 << 3,
+	ND_SMART_USED_VALID	= 1 << 4,
+	ND_SMART_SHUTDOWN_VALID	= 1 << 5,
+	ND_SMART_VENDOR_VALID	= 1 << 6,
+	ND_SMART_TEMP_TRIP	= 1 << 0,
+	ND_SMART_SPARE_TRIP	= 1 << 1,
+	ND_SMART_NON_CRITICAL_HEALTH	= 1 << 0,
+	ND_SMART_CRITICAL_HEALTH	= 1 << 1,
+	ND_SMART_FATAL_HEALTH		= 1 << 2,
+};
+
+struct nd_smart_payload {
+	__u32 flags;
+	__u8 reserved0[4];
+	__u8 health;
+	__u16 temperature;
+	__u8 spares;
+	__u8 alarm_flags;
+	__u8 life_used;
+	__u8 shutdown_state;
+	__u8 reserved1;
+	__u32 vendor_size;
+	__u8 vendor_data[108];
+} __attribute__((packed));
+
 struct nd_cmd_smart_threshold {
 	__u32 status;
 	__u8 data[8];
test/libndctl.c +67 -1

86 lines not on this page · raw message

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#4 lore raw

Re: [ndctl PATCH 2/5] ndctl: helper for S.M.A.R.T. data retrieval

Quoted 7 lines · On Mittwoch, 6. April 2016 18:07:09 CEST Dan Williams wrote:

Helper functions to issue the "SMART and Health Info (Function Index 1)" DSM and parse its results.

http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf

---

[...]

Quoted 5 lines
ndctl.h +4 -0
+enum {
+	ND_SMART_HEALTH_VALID	= 1 << 0,
+	ND_SMART_TEMP_VALID 	= 1 << 1,
+	ND_SMART_SPARES_VALID	= 1 << 2,

ndctl.h struct nd_cmd_smart { · line 36

Quoted 10 lines
ndctl.h +10 -0
+	ND_SMART_ALARM_VALID	= 1 << 3,
+	ND_SMART_USED_VALID	= 1 << 4,
+	ND_SMART_SHUTDOWN_VALID	= 1 << 5,
+	ND_SMART_VENDOR_VALID	= 1 << 6,
+	ND_SMART_TEMP_TRIP	= 1 << 0,
+	ND_SMART_SPARE_TRIP	= 1 << 1,
+	ND_SMART_NON_CRITICAL_HEALTH	= 1 << 0,
+	ND_SMART_CRITICAL_HEALTH	= 1 << 1,
+	ND_SMART_FATAL_HEALTH		= 1 << 2,
+};

Same applies here.

Signature · 11 lines
Johannes Thumshirn                                          Storage
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#5 lore raw

PATCH v2 1/1 ndctl: helper for S.M.A.R.T. data retrieval

In reply to Dan Williams

Helper functions to issue the "SMART and Health Info (Function Index 1)" DSM and parse its results.

http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf

---
Changes in v2:
* pull in the updated ndctl.h from the kernel (jth)
* add helper routines for issuing smart threshold commands
* extend the unit test to validate smart threshold data passthrough

 Makefile.am             |    4 +
 configure.ac            |   26 +++++++++
 lib/libndctl-private.h  |    2 +
 lib/libndctl-smart.c    |  134 +++++++++++++++++++++++++++++++++++++++++++++++
 lib/libndctl.c          |    1 
 lib/libndctl.sym        |   14 +++++
 lib/ndctl/libndctl.h.in |   75 ++++++++++++++++++++++++++
 ndctl.h                 |   34 ++++++++++++
 test/libndctl.c         |  122 ++++++++++++++++++++++++++++++++++++++++++-
 9 files changed, 410 insertions(+), 2 deletions(-)
 create mode 100644 lib/libndctl-smart.c
Makefile.am +4 -0
index 379f6404671f..9c6b37410642 100644
@@ -85,6 +85,10 @@ if ENABLE_ARS
 lib_libndctl_la_SOURCES += lib/libndctl-ars.c
 endif
 
+if ENABLE_SMART
+lib_libndctl_la_SOURCES += lib/libndctl-smart.c
+endif
+
 bin_PROGRAMS = ndctl
 
 ndctl_SOURCES = ndctl.c \
configure.ac +26 -0
index 1ab376885215..01f347a7f137 100644
@@ -144,6 +144,25 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 )
 AM_CONDITIONAL([ENABLE_CLEAR_ERROR], [test "x$enable_clear_err" = "xyes"])
 
+AC_MSG_CHECKING([for SMART support])
+AC_LANG(C)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+			#ifdef HAVE_NDCTL_H
+			#include <linux/ndctl.h>
+			#else
+			#include "ndctl.h"
+			#endif
+			]], [[
+			int x = ND_SMART_HEALTH_VALID;
+			]]
+		)], [AC_MSG_RESULT([yes])
+		     enable_smart=yes
+		     AC_DEFINE([HAVE_NDCTL_SMART], [1],
+				[Define to 1 if ndctl.h has SMART support.])
+		], [AC_MSG_RESULT([no])]
+)
+AM_CONDITIONAL([ENABLE_SMART], [test "x$enable_smart" = "xyes"])
+
 AC_CONFIG_COMMANDS([gen-libndctl.h],
 		[[
 		if test "x$enable_ars" = "xyes"; then
@@ -151,17 +170,24 @@ AC_CONFIG_COMMANDS([gen-libndctl.h],
 		else
 			enable_ars=0
 		fi
+		if test "x$enable_smart" = "xyes"; then
+			enable_smart=1
+		else
+			enable_smart=0
+		fi
 		if test "x$enable_clear_err" = "xyes"; then
 			enable_clear_err=1
 		else
 			enable_clear_err=0
 		fi
 		sed -e s/HAVE_NDCTL_ARS/$enable_ars/ \
+		    -e s/HAVE_NDCTL_SMART/$enable_smart/ \
 		    -e s/HAVE_NDCTL_CLEAR_ERROR/$enable_clear_err/ \
 		< lib/ndctl/libndctl.h.in > lib/ndctl/libndctl.h
 		]],
 		[[
 		enable_ars=$enable_ars
+		enable_smart=$enable_smart
 		enable_clear_err=$enable_clear_err
 		]])
 
lib/libndctl-private.h +2 -0
index 50b03743751f..cbb0ed9f76b5 100644
@@ -167,6 +167,8 @@ struct ndctl_cmd {
 #ifdef HAVE_NDCTL_CLEAR_ERROR
 		struct nd_cmd_clear_error clear_err[0];
 #endif
+		struct nd_cmd_smart smart[0];
+		struct nd_cmd_smart_threshold smart_t[0];
 		struct nd_cmd_get_config_size get_size[0];
 		struct nd_cmd_get_config_data_hdr get_data[0];
 		struct nd_cmd_set_config_hdr set_data[0];
lib/libndctl-smart.c new file +134 -0

134 lines not on this page · raw message

lib/libndctl.c +1 -0
index 26de91af8a63..c25107f3eba7 100644
@@ -26,6 +26,7 @@
 #include <ccan/list/list.h>
 #include <ccan/minmax/minmax.h>
 #include <ccan/array_size/array_size.h>
+#include <ccan/build_assert/build_assert.h>
 
 #ifdef HAVE_NDCTL_H
 #include <linux/ndctl.h>
lib/libndctl.sym +14 -0
index 5ff8848ee6d3..17a9085dd092 100644
@@ -86,6 +86,20 @@ global:
 	ndctl_dimm_cmd_new_cfg_size;
 	ndctl_dimm_cmd_new_cfg_read;
 	ndctl_dimm_cmd_new_cfg_write;
+	ndctl_dimm_cmd_new_smart;
+	ndctl_cmd_smart_get_flags;
+	ndctl_cmd_smart_get_health;
+	ndctl_cmd_smart_get_temperature;
+	ndctl_cmd_smart_get_spares;
+	ndctl_cmd_smart_get_alarm_flags;
+	ndctl_cmd_smart_get_life_used;
+	ndctl_cmd_smart_get_shutdown_state;
+	ndctl_cmd_smart_get_vendor_size;
+	ndctl_cmd_smart_get_vendor_data;
+	ndctl_dimm_cmd_new_smart_threshold;
+	ndctl_cmd_smart_threshold_get_alarm_control;
+	ndctl_cmd_smart_threshold_get_temperature;
+	ndctl_cmd_smart_threshold_get_spares;
 	ndctl_dimm_zero_labels;
 	ndctl_dimm_get_available_labels;
 	ndctl_region_get_first;
lib/ndctl/libndctl.h.in +75 -0

81 lines not on this page · raw message

ndctl.h +34 -0
index 69b8e707fc49..ef1cf722ba4d 100644
@@ -20,11 +20,45 @@ struct nd_cmd_smart {
 	__u8 data[128];
 } __attribute__((packed));
 
+#define ND_SMART_HEALTH_VALID	(1 << 0)
+#define ND_SMART_TEMP_VALID 	(1 << 1)
+#define ND_SMART_SPARES_VALID	(1 << 2)
+#define ND_SMART_ALARM_VALID	(1 << 3)
+#define ND_SMART_USED_VALID	(1 << 4)
+#define ND_SMART_SHUTDOWN_VALID	(1 << 5)
+#define ND_SMART_VENDOR_VALID	(1 << 6)
+#define ND_SMART_TEMP_TRIP	(1 << 0)
+#define ND_SMART_SPARE_TRIP	(1 << 1)
+#define ND_SMART_NON_CRITICAL_HEALTH	(1 << 0)
+#define ND_SMART_CRITICAL_HEALTH	(1 << 1)
+#define ND_SMART_FATAL_HEALTH		(1 << 2)
+
+struct nd_smart_payload {
+	__u32 flags;
+	__u8 reserved0[4];
+	__u8 health;
+	__u16 temperature;
+	__u8 spares;
+	__u8 alarm_flags;
+	__u8 life_used;
+	__u8 shutdown_state;
+	__u8 reserved1;
+	__u32 vendor_size;
+	__u8 vendor_data[108];
+} __attribute__((packed));
+
 struct nd_cmd_smart_threshold {
 	__u32 status;
 	__u8 data[8];
 } __attribute__((packed));
 
+struct nd_smart_threshold_payload {
+	__u16 alarm_control;
+	__u16 temperature;
+	__u8 spares;
+	__u8 reserved[3];
+} __attribute__((packed));
+
 struct nd_cmd_dimm_flags {
 	__u32 status;
 	__u32 flags;
test/libndctl.c +120 -2

140 lines not on this page · raw message

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reviewed-by on v2 1/1
#6 lore raw

Re: [ndctl PATCH v2] ndctl: helper for S.M.A.R.T. data retrieval

Quoted 11 lines · On Donnerstag, 7. April 2016 15:39:04 CEST Dan Williams wrote:

Helper functions to issue the "SMART and Health Info (Function Index 1)" DSM and parse its results.

http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf

---
Changes in v2:
* pull in the updated ndctl.h from the kernel (jth)
* add helper routines for issuing smart threshold commands
* extend the unit test to validate smart threshold data passthrough

Thanks,

Signature · 11 lines
Johannes Thumshirn                                          Storage
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#7 lore raw

PATCH 3/5 ndctl, list: clean up default behavior

In reply to Dan Williams

Only list namespaces by default when no other option is specified. Otherwise, to limit the listing to dimm info a user would need to run:

	ndctl list --dimms --no-namespaces

...with the change this is reduced to:

	ndctl list --dimms
---
 Documentation/ndctl-list.txt |    2 +-
 builtin-list.c               |    7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
Documentation/ndctl-list.txt +1 -1
index abf3ff07cfa9..806548196118 100644
@@ -79,7 +79,7 @@ include::xable-region-options.txt[]
 -N::
 --namespaces::
 	Include namespace info in the listing.  Namespace info is
-	included by default, specify '--no-namespaces' to omit.
+	listed by default if no other options are specified to the command.
 
 -i::
 --idle::
builtin-list.c +4 -3
index 413b36ac0208..df0871ab544a 100644
@@ -22,9 +22,7 @@ static struct {
 	bool regions;
 	bool namespaces;
 	bool idle;
-} list = {
-	.namespaces = true,
-};
+} list;
 
 static struct {
 	const char *bus;
@@ -222,6 +220,9 @@ int cmd_list(int argc, const char **argv)
 	unsigned int type = 0;
 	int i, rc;
 
+	if (argc == 1)
+		list.namespaces = true;
+
         argc = parse_options(argc, argv, options, u, 0);
 	for (i = 0; i < argc; i++)
 		error("unknown parameter \"%s\"\n", argv[i]);

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reviewed-by on v1 3/5
#8 lore raw

Re: [ndctl PATCH 3/5] ndctl, list: clean up default behavior

Quoted 11 lines · On Mittwoch, 6. April 2016 18:07:14 CEST Dan Williams wrote:

Only list namespaces by default when no other option is specified. Otherwise, to limit the listing to dimm info a user would need to run:

	ndctl list --dimms --no-namespaces

...with the change this is reduced to:

	ndctl list --dimms

---

Looks good,

Signature · 11 lines
Johannes Thumshirn                                          Storage
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#9 lore raw

PATCH 4/5 ndctl, list: add a '--health' option

In reply to Dan Williams

Dump dimm smart data in the dimm listing when '--health' is specified.

---
 Documentation/ndctl-list.txt |   19 ++++++++
 builtin-list.c               |   11 +++++
 util/json.c                  |   97 ++++++++++++++++++++++++++++++++++++++++++
 util/json.h                  |    1 
 4 files changed, 127 insertions(+), 1 deletion(-)
Documentation/ndctl-list.txt +18 -1
index 806548196118..36398aa34b42 100644
@@ -3,7 +3,7 @@ ndctl-list(1)
 
 NAME
 ----
-ndctl-list - dump the platform nvdimm device topology in json
+ndctl-list - dump the platform nvdimm device topology and attributes in json
 
 SYNOPSIS
 --------
@@ -72,6 +72,23 @@ include::xable-region-options.txt[]
 --dimms::
 	Include dimm info in the listing
 
+-H::
+--health::
+	Include dimm health info in the listing.  For example:
+[verse]
+{
+  "dev":"nmem0",
+  "health":{
+    "health_state":"non-critical",
+    "temperature_celsius":23,
+    "spares_percentage":75,
+    "alarm_temperature":true,
+    "alarm_spares":true,
+    "life_used_percentage":5,
+    "shutdown_state":"clean"
+  }
+}
+
 -R::
 --regions::
 	Include region info in the listing
builtin-list.c +11 -0
index df0871ab544a..8b65767c37be 100644
@@ -22,6 +22,7 @@ static struct {
 	bool regions;
 	bool namespaces;
 	bool idle;
+	bool health;
 } list;
 
 static struct {
@@ -200,6 +201,7 @@ int cmd_list(int argc, const char **argv)
 				"filter by region-type"),
 		OPT_BOOLEAN('B', "buses", &list.buses, "include bus info"),
 		OPT_BOOLEAN('D', "dimms", &list.dimms, "include dimm info"),
+		OPT_BOOLEAN('H', "health", &list.health, "include dimm health"),
 		OPT_BOOLEAN('R', "regions", &list.regions,
 				"include region info"),
 		OPT_BOOLEAN('N', "namespaces", &list.namespaces,
@@ -299,6 +301,15 @@ int cmd_list(int argc, const char **argv)
 				continue;
 			}
 
+			if (list.health) {
+				struct json_object *jhealth;
+
+				jhealth = util_dimm_health_to_json(dimm);
+				if (jhealth)
+					json_object_object_add(jdimm, "health",
+							jhealth);
+			}
+
 			/*
 			 * Without a bus we are collecting dimms anonymously
 			 * across the platform.
util/json.c +97 -0

103 lines not on this page · raw message

util/json.h +1 -0
index 653bbd9beef1..79962cacc35c 100644
@@ -6,6 +6,7 @@
 bool util_namespace_active(struct ndctl_namespace *ndns);
 struct json_object *util_bus_to_json(struct ndctl_bus *bus);
 struct json_object *util_dimm_to_json(struct ndctl_dimm *dimm);
+struct json_object *util_dimm_health_to_json(struct ndctl_dimm *dimm);
 struct json_object *util_mapping_to_json(struct ndctl_mapping *mapping);
 struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns);
 #endif /* __NDCTL_JSON_H__ */

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#10 lore raw

Re: [ndctl PATCH 4/5] ndctl, list: add a '--health' option

Quoted 4 lines · On Mittwoch, 6. April 2016 18:07:20 CEST Dan Williams wrote:

Dump dimm smart data in the dimm listing when '--health' is specified.

---

[...]

Quoted 9 lines
builtin-list.c +1 -0
@@ -200,6 +201,7 @@ int cmd_list(int argc, const char **argv)
 				"filter by region-type"),
 		OPT_BOOLEAN('B', "buses", &list.buses, "include bus info"),
 		OPT_BOOLEAN('D', "dimms", &list.dimms, "include dimm info"),
+		OPT_BOOLEAN('H', "health", &list.health, "include dimm health"),
 		OPT_BOOLEAN('R', "regions", &list.regions,
 				"include region info"),
 		OPT_BOOLEAN('N', "namespaces", &list.namespaces,

builtin-list.c int cmd_list(int argc, const char **argv) · line 310

Quoted 10 lines
builtin-list.c +7 -0
@@ -299,6 +301,15 @@ int cmd_list(int argc, const char **argv)
 				continue;
 			}
 
+			if (list.health) {
+				struct json_object *jhealth;
+
+				jhealth = util_dimm_health_to_json(dimm);
+				if (jhealth)
+					json_object_object_add(jdimm, "health",
+							jhealth);

Maybe some sort of error message for the else path? Either here or in util_dimm_health_to_json()?

Signature · 11 lines
Johannes Thumshirn                                          Storage
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#11 lore raw

Re: [ndctl PATCH 4/5] ndctl, list: add a '--health' option

Quoted 20 lines · Johannes Thumshirn
Quoted 4 lines · On Mittwoch, 6. April 2016 18:07:20 CEST Dan Williams wrote:

Dump dimm smart data in the dimm listing when '--health' is specified.

---

[...]

Quoted 12 lines
builtin-list.c +1 -0
@@ -200,6 +201,7 @@ int cmd_list(int argc, const char **argv)
                              "filter by region-type"),
              OPT_BOOLEAN('B', "buses", &list.buses, "include bus info"),
              OPT_BOOLEAN('D', "dimms", &list.dimms, "include dimm info"),
+             OPT_BOOLEAN('H', "health", &list.health, "include dimm health"),
              OPT_BOOLEAN('R', "regions", &list.regions,
                              "include region info"),
              OPT_BOOLEAN('N', "namespaces", &list.namespaces,
@@ -299,6 +301,15 @@ int cmd_list(int argc, const char **argv)
                              continue;
                      }
 
Quoted 10 lines

builtin-list.c int cmd_list(int argc, const char **argv) · line 310

Quoted 7 lines
builtin-list.c +7 -0
+                     if (list.health) {
+                             struct json_object *jhealth;
+
+                             jhealth = util_dimm_health_to_json(dimm);
+                             if (jhealth)
+                                     json_object_object_add(jdimm, "health",
+                                                     jhealth);

Maybe some sort of error message for the else path? Either here or in util_dimm_health_to_json()?

Yeah, I wasn't sure how to differentiate "dimm does not support smart" vs "dimm smart data retrieval failed" in this routine. However, you're right a debug message at a minimum is needed.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#12 lore raw

PATCH v2 1/1 ndctl, list: add a '--health' option

In reply to Dan Williams

Dump dimm smart data in the dimm listing when '--health' is specified.

---
Changes in v2:
* add an error message if health retrieval fails unexpectedly (jth)
* add threshold data to the health listing

 Documentation/ndctl-list.txt |   21 ++++++
 builtin-list.c               |   21 ++++++
 util/json.c                  |  150 ++++++++++++++++++++++++++++++++++++++++++
 util/json.h                  |    1 
 4 files changed, 192 insertions(+), 1 deletion(-)
Documentation/ndctl-list.txt +20 -1
index 806548196118..a5f209f99408 100644
@@ -3,7 +3,7 @@ ndctl-list(1)
 
 NAME
 ----
-ndctl-list - dump the platform nvdimm device topology in json
+ndctl-list - dump the platform nvdimm device topology and attributes in json
 
 SYNOPSIS
 --------
@@ -72,6 +72,25 @@ include::xable-region-options.txt[]
 --dimms::
 	Include dimm info in the listing
 
+-H::
+--health::
+	Include dimm health info in the listing.  For example:
+[verse]
+{
+  "dev":"nmem0",
+  "health":{
+    "health_state":"non-critical",
+    "temperature_celsius":23,
+    "spares_percentage":75,
+    "alarm_temperature":true,
+    "alarm_spares":true,
+    "temperature_threshold":40,
+    "spares_threshold":5,
+    "life_used_percentage":5,
+    "shutdown_state":"clean"
+  }
+}
+
 -R::
 --regions::
 	Include region info in the listing
builtin-list.c +21 -0
index df0871ab544a..f930b9e44c2c 100644
@@ -22,6 +22,7 @@ static struct {
 	bool regions;
 	bool namespaces;
 	bool idle;
+	bool health;
 } list;
 
 static struct {
@@ -200,6 +201,7 @@ int cmd_list(int argc, const char **argv)
 				"filter by region-type"),
 		OPT_BOOLEAN('B', "buses", &list.buses, "include bus info"),
 		OPT_BOOLEAN('D', "dimms", &list.dimms, "include dimm info"),
+		OPT_BOOLEAN('H', "health", &list.health, "include dimm health"),
 		OPT_BOOLEAN('R', "regions", &list.regions,
 				"include region info"),
 		OPT_BOOLEAN('N', "namespaces", &list.namespaces,
@@ -299,6 +301,25 @@ int cmd_list(int argc, const char **argv)
 				continue;
 			}
 
+			if (list.health) {
+				struct json_object *jhealth;
+
+				jhealth = util_dimm_health_to_json(dimm);
+				if (jhealth)
+					json_object_object_add(jdimm, "health",
+							jhealth);
+				else if (ndctl_dimm_is_cmd_supported(dimm,
+							ND_CMD_SMART)) {
+					/*
+					 * Failed to retrieve health data from
+					 * a dimm that otherwise supports smart
+					 * data retrieval commands.
+					 */
+					fail("\n");
+					continue;
+				}
+			}
+
 			/*
 			 * Without a bus we are collecting dimms anonymously
 			 * across the platform.
util/json.c +150 -0

156 lines not on this page · raw message

util/json.h +1 -0
index 653bbd9beef1..79962cacc35c 100644
@@ -6,6 +6,7 @@
 bool util_namespace_active(struct ndctl_namespace *ndns);
 struct json_object *util_bus_to_json(struct ndctl_bus *bus);
 struct json_object *util_dimm_to_json(struct ndctl_dimm *dimm);
+struct json_object *util_dimm_health_to_json(struct ndctl_dimm *dimm);
 struct json_object *util_mapping_to_json(struct ndctl_mapping *mapping);
 struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns);
 #endif /* __NDCTL_JSON_H__ */

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reviewed-by on v2 1/1
#13 lore raw

Re: [ndctl PATCH v2] ndctl, list: add a '--health' option

Quoted 7 lines · On Donnerstag, 7. April 2016 15:42:29 CEST Dan Williams wrote:

Dump dimm smart data in the dimm listing when '--health' is specified.

---
Changes in v2:
* add an error message if health retrieval fails unexpectedly (jth)
* add threshold data to the health listing

Thanks for working that in,

Signature · 11 lines
Johannes Thumshirn                                          Storage
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#14 lore raw

PATCH 5/5 ndctl, list: add 'filter by dimm' capability

In reply to Dan Williams

This is to support scenarios where the user is searching for information relative to a given dimm. For example if a dimm is faltering, this command can show all the namespaces impacted if the dimm failed:

ndctl list -d nmem0 -N

---
 Documentation/ndctl-list.txt |    8 ++++
 builtin-list.c               |   13 ++++++-
 util/filter.c                |   83 ++++++++++++++++++++++++++++++++++++++++++
 util/filter.h                |    5 +++
 4 files changed, 107 insertions(+), 2 deletions(-)
Documentation/ndctl-list.txt +8 -0
index 36398aa34b42..0a23ea130a1e 100644
@@ -60,6 +60,14 @@ OPTIONS
 --region=::
 include::xable-region-options.txt[]
 
+-d::
+--dimm=::
+	An 'nmemX' device name, or dimm id number. Filter listing by
+	devices that reference the given dimm. For example to see all
+	namespaces comprised of storage capacity on nmem0:
+[verse]
+# ndctl list --dimm=nmem0 --namespaces
+
 -t::
 --type=::
 	Filter listing by region type ('pmem' or 'blk')
builtin-list.c +11 -2
index 8b65767c37be..885f61297a3c 100644
@@ -29,6 +29,7 @@ static struct {
 	const char *bus;
 	const char *region;
 	const char *type;
+	const char *dimm;
 } param;
 
 static int did_fail;
@@ -197,6 +198,8 @@ int cmd_list(int argc, const char **argv)
 		OPT_STRING('b', "bus", &param.bus, "bus-id", "filter by bus"),
 		OPT_STRING('r', "region", &param.region, "region-id",
 				"filter by region"),
+		OPT_STRING('d', "dimm", &param.dimm, "dimm-id",
+				"filter by dimm"),
 		OPT_STRING('t', "type", &param.type, "region-type",
 				"filter by region-type"),
 		OPT_BOOLEAN('B', "buses", &list.buses, "include bus info"),
@@ -254,7 +257,8 @@ int cmd_list(int argc, const char **argv)
 		struct ndctl_region *region;
 		struct ndctl_dimm *dimm;
 
-		if (!util_bus_filter(bus, param.bus))
+		if (!util_bus_filter(bus, param.bus)
+				|| !util_bus_filter_by_dimm(bus, param.dimm))
 			continue;
 
 		if (list.buses) {
@@ -281,6 +285,9 @@ int cmd_list(int argc, const char **argv)
 			if (!list.dimms)
 				break;
 
+			if (!util_dimm_filter(dimm, param.dimm))
+				continue;
+
 			if (!list.idle && !ndctl_dimm_is_enabled(dimm))
 				continue;
 
@@ -320,7 +327,9 @@ int cmd_list(int argc, const char **argv)
 		ndctl_region_foreach(bus, region) {
 			struct json_object *jregion;
 
-			if (!util_region_filter(region, param.region))
+			if (!util_region_filter(region, param.region)
+					|| !util_region_filter_by_dimm(region,
+						param.dimm))
 				continue;
 
 			if (type && ndctl_region_get_type(region) != type)
util/filter.c +83 -0

86 lines not on this page · raw message

util/filter.h +5 -0
index bc5c2557a65c..17ce895425fb 100644
@@ -3,4 +3,9 @@
 struct ndctl_bus *util_bus_filter(struct ndctl_bus *bus, const char *ident);
 struct ndctl_region *util_region_filter(struct ndctl_region *region,
 		const char *ident);
+struct ndctl_dimm *util_dimm_filter(struct ndctl_dimm *dimm, const char *ident);
+struct ndctl_bus *util_bus_filter_by_dimm(struct ndctl_bus *bus,
+		const char *ident);
+struct ndctl_region *util_region_filter_by_dimm(struct ndctl_region *region,
+		const char *ident);
 #endif

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reviewed-by on v1 5/5
#15 lore raw

Re: [ndctl PATCH 5/5] ndctl, list: add 'filter by dimm' capability

Quoted 8 lines · On Mittwoch, 6. April 2016 18:07:25 CEST Dan Williams wrote:

This is to support scenarios where the user is searching for information relative to a given dimm. For example if a dimm is faltering, this command can show all the namespaces impacted if the dimm failed:

ndctl list -d nmem0 -N

---

Looks good,

Signature · 11 lines
Johannes Thumshirn                                          Storage
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm