ndctl: fix definition of conditional functionality
PATCH 1/1 ndctl: fix definition of conditional functionality
Resolve HAVE_NDCTL_ARS and HAVE_NDCTL_CLEAR_ERROR in libndctl.h from the results of configure.
---
configure.ac | 21 +++++++++++++++++++++
lib/ndctl/libndctl.h.in | 20 +++++++++++---------
2 files changed, 32 insertions(+), 9 deletions(-)
rename lib/ndctl/{libndctl.h => libndctl.h.in} (98%)configure.ac +21 -0
@@ -144,6 +144,27 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ) AM_CONDITIONAL([ENABLE_CLEAR_ERROR], [test "x$enable_clear_err" = "xyes"]) +AC_CONFIG_COMMANDS([gen-libndctl.h], + [[ + if test "x$enable_ars" = "xyes"; then + enable_ars=1 + else + enable_ars=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_CLEAR_ERROR/$enable_clear_err/ \ + < lib/ndctl/libndctl.h.in > lib/ndctl/libndctl.h + ]], + [[ + enable_ars=$enable_ars + enable_clear_err=$enable_clear_err + ]]) + AC_CHECK_HEADERS_ONCE([linux/version.h]) AC_CHECK_FUNCS([ \
lib/ndctl/libndctl.h.in renamed from lib/ndctl/libndctl.h +11 -9
@@ -148,7 +148,8 @@ int ndctl_dimm_disable(struct ndctl_dimm *dimm); int ndctl_dimm_enable(struct ndctl_dimm *dimm); struct ndctl_cmd; -#ifdef HAVE_NDCTL_ARS +#define HAS_ARS HAVE_NDCTL_ARS +#if HAS_ARS == 1 struct ndctl_cmd *ndctl_bus_cmd_new_ars_cap(struct ndctl_bus *bus, unsigned long long address, unsigned long long len); struct ndctl_cmd *ndctl_bus_cmd_new_ars_start(struct ndctl_cmd *ars_cap, int type);
@@ -167,18 +168,18 @@ unsigned long long ndctl_cmd_ars_get_record_addr(struct ndctl_cmd *ars_stat, unsigned long long ndctl_cmd_ars_get_record_len(struct ndctl_cmd *ars_stat, unsigned int rec_index); -#ifdef HAVE_NDCTL_CLEAR_ERROR +#define HAS_CLEAR_ERROR HAVE_NDCTL_CLEAR_ERROR +#if HAS_CLEAR_ERROR == 1 /* - * clear_error requires ars_cap, so we require HAVE_NDCTL_ARS to export the - * clear_error capability + * clear_error requires ars_cap, so we require HAS_CLEAR_ERROR to export + * the clear_error capability */ struct ndctl_cmd *ndctl_bus_cmd_new_clear_error(unsigned long long address, unsigned long long len, struct ndctl_cmd *ars_cap); unsigned long long ndctl_cmd_clear_error_get_cleared( struct ndctl_cmd *clear_err); -#define HAS_CLEAR_ERROR 1 #endif -#else /* HAVE_NDCTL_ARS */ +#else /* HAS_ARS == 0 */ static inline struct ndctl_cmd *ndctl_bus_cmd_new_ars_cap(struct ndctl_bus *bus, unsigned long long address, unsigned long long len) {
@@ -202,7 +203,7 @@ static inline unsigned int ndctl_cmd_ars_cap_get_size(struct ndctl_cmd *ars_cap) return 0; } - +struct ndctl_range; static inline int ndctl_cmd_ars_cap_get_range(struct ndctl_cmd *ars_cap, struct ndctl_range *range) {
@@ -230,9 +231,10 @@ static inline unsigned long long ndctl_cmd_ars_get_record_len( { return 0; } -#endif /* HAVE_NDCTL_ARS */ +#define HAS_CLEAR_ERROR 0 +#endif /* HAS_ARS */ -#ifndef HAS_CLEAR_ERROR +#if HAS_CLEAR_ERROR == 0 static inline struct ndctl_cmd *ndctl_bus_cmd_new_clear_error( unsigned long long address, unsigned long long len, struct ndctl_cmd *ars_cap)
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 106 lines · Dan Williams
Resolve
HAVE_NDCTL_ARSandHAVE_NDCTL_CLEAR_ERRORinlibndctl.hfrom the results of configure.Signed-off-by Dan Williams <[email protected]>--- configure.ac | 21 +++++++++++++++++++++ lib/ndctl/libndctl.h.in | 20 +++++++++++--------- 2 files changed, 32 insertions(+), 9 deletions(-) rename lib/ndctl/{libndctl.h => libndctl.h.in} (98%)configure.ac +21
-0@@ -144,6 +144,27 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ) AM_CONDITIONAL([ENABLE_CLEAR_ERROR], [test "x$enable_clear_err" = "xyes"]) +AC_CONFIG_COMMANDS([gen-libndctl.h], + [[ + if test "x$enable_ars" = "xyes"; then + enable_ars=1 + else + enable_ars=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_CLEAR_ERROR/$enable_clear_err/ \ + < lib/ndctl/libndctl.h.in > lib/ndctl/libndctl.h + ]], + [[ + enable_ars=$enable_ars + enable_clear_err=$enable_clear_err + ]]) + AC_CHECK_HEADERS_ONCE([linux/version.h]) AC_CHECK_FUNCS([ \lib/ndctl/libndctl.h.in renamed from lib/ndctl/libndctl.h +11
-9@@ -148,7 +148,8 @@ int ndctl_dimm_disable(struct ndctl_dimm *dimm); int ndctl_dimm_enable(struct ndctl_dimm *dimm); struct ndctl_cmd; -#ifdef HAVE_NDCTL_ARS +#define HAS_ARS HAVE_NDCTL_ARS +#if HAS_ARS == 1 struct ndctl_cmd *ndctl_bus_cmd_new_ars_cap(struct ndctl_bus *bus, unsigned long long address, unsigned long long len); struct ndctl_cmd *ndctl_bus_cmd_new_ars_start(struct ndctl_cmd *ars_cap, int type);@@ -167,18 +168,18 @@ unsigned long long ndctl_cmd_ars_get_record_addr(struct ndctl_cmd *ars_stat, unsigned long long ndctl_cmd_ars_get_record_len(struct ndctl_cmd *ars_stat, unsigned int rec_index); -#ifdef HAVE_NDCTL_CLEAR_ERROR +#define HAS_CLEAR_ERROR HAVE_NDCTL_CLEAR_ERROR +#if HAS_CLEAR_ERROR == 1 /* - * clear_error requires ars_cap, so we require HAVE_NDCTL_ARS to export the - * clear_error capability + * clear_error requires ars_cap, so we require HAS_CLEAR_ERROR to export + * the clear_error capability */ struct ndctl_cmd *ndctl_bus_cmd_new_clear_error(unsigned long long address, unsigned long long len, struct ndctl_cmd *ars_cap); unsigned long long ndctl_cmd_clear_error_get_cleared( struct ndctl_cmd *clear_err); -#define HAS_CLEAR_ERROR 1 #endif -#else /* HAVE_NDCTL_ARS */ +#else /* HAS_ARS == 0 */ static inline struct ndctl_cmd *ndctl_bus_cmd_new_ars_cap(struct ndctl_bus *bus, unsigned long long address, unsigned long long len) {@@ -202,7 +203,7 @@ static inline unsigned int ndctl_cmd_ars_cap_get_size(struct ndctl_cmd *ars_cap) return 0; } - +struct ndctl_range; static inline int ndctl_cmd_ars_cap_get_range(struct ndctl_cmd *ars_cap, struct ndctl_range *range) {@@ -230,9 +231,10 @@ static inline unsigned long long ndctl_cmd_ars_get_record_len( { return 0; } -#endif /* HAVE_NDCTL_ARS */ +#define HAS_CLEAR_ERROR 0 +#endif /* HAS_ARS */ -#ifndef HAS_CLEAR_ERROR +#if HAS_CLEAR_ERROR == 0 static inline struct ndctl_cmd *ndctl_bus_cmd_new_clear_error( unsigned long long address, unsigned long long len, struct ndctl_cmd *ars_cap)
Quoted 4 lines
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
I know I'm repeating myself here, but isn't there a way to dynamically figure out if we can use ARS or the clear error stuff? The build host's kernel version doesn't necessarily reflect the capabilities of the target host's kernel.
Thanks,
Johannes
Signature · 10 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
Quoted 107 lines · Johannes Thumshirn
Quoted 106 lines · Dan Williams
Resolve
HAVE_NDCTL_ARSandHAVE_NDCTL_CLEAR_ERRORinlibndctl.hfrom the results of configure.Signed-off-by Dan Williams <[email protected]>--- configure.ac | 21 +++++++++++++++++++++ lib/ndctl/libndctl.h.in | 20 +++++++++++--------- 2 files changed, 32 insertions(+), 9 deletions(-) rename lib/ndctl/{libndctl.h => libndctl.h.in} (98%)configure.ac +21
-0@@ -144,6 +144,27 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ) AM_CONDITIONAL([ENABLE_CLEAR_ERROR], [test "x$enable_clear_err" = "xyes"]) +AC_CONFIG_COMMANDS([gen-libndctl.h], + [[ + if test "x$enable_ars" = "xyes"; then + enable_ars=1 + else + enable_ars=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_CLEAR_ERROR/$enable_clear_err/ \ + < lib/ndctl/libndctl.h.in > lib/ndctl/libndctl.h + ]], + [[ + enable_ars=$enable_ars + enable_clear_err=$enable_clear_err + ]]) + AC_CHECK_HEADERS_ONCE([linux/version.h]) AC_CHECK_FUNCS([ \lib/ndctl/libndctl.h.in renamed from lib/ndctl/libndctl.h +11
-9@@ -148,7 +148,8 @@ int ndctl_dimm_disable(struct ndctl_dimm *dimm); int ndctl_dimm_enable(struct ndctl_dimm *dimm); struct ndctl_cmd; -#ifdef HAVE_NDCTL_ARS +#define HAS_ARS HAVE_NDCTL_ARS +#if HAS_ARS == 1 struct ndctl_cmd *ndctl_bus_cmd_new_ars_cap(struct ndctl_bus *bus, unsigned long long address, unsigned long long len); struct ndctl_cmd *ndctl_bus_cmd_new_ars_start(struct ndctl_cmd *ars_cap, int type);@@ -167,18 +168,18 @@ unsigned long long ndctl_cmd_ars_get_record_addr(struct ndctl_cmd *ars_stat, unsigned long long ndctl_cmd_ars_get_record_len(struct ndctl_cmd *ars_stat, unsigned int rec_index); -#ifdef HAVE_NDCTL_CLEAR_ERROR +#define HAS_CLEAR_ERROR HAVE_NDCTL_CLEAR_ERROR +#if HAS_CLEAR_ERROR == 1 /* - * clear_error requires ars_cap, so we require HAVE_NDCTL_ARS to export the - * clear_error capability + * clear_error requires ars_cap, so we require HAS_CLEAR_ERROR to export + * the clear_error capability */ struct ndctl_cmd *ndctl_bus_cmd_new_clear_error(unsigned long long address, unsigned long long len, struct ndctl_cmd *ars_cap); unsigned long long ndctl_cmd_clear_error_get_cleared( struct ndctl_cmd *clear_err); -#define HAS_CLEAR_ERROR 1 #endif -#else /* HAVE_NDCTL_ARS */ +#else /* HAS_ARS == 0 */ static inline struct ndctl_cmd *ndctl_bus_cmd_new_ars_cap(struct ndctl_bus *bus, unsigned long long address, unsigned long long len) {@@ -202,7 +203,7 @@ static inline unsigned int ndctl_cmd_ars_cap_get_size(struct ndctl_cmd *ars_cap) return 0; } - +struct ndctl_range; static inline int ndctl_cmd_ars_cap_get_range(struct ndctl_cmd *ars_cap, struct ndctl_range *range) {@@ -230,9 +231,10 @@ static inline unsigned long long ndctl_cmd_ars_get_record_len( { return 0; } -#endif /* HAVE_NDCTL_ARS */ +#define HAS_CLEAR_ERROR 0 +#endif /* HAS_ARS */ -#ifndef HAS_CLEAR_ERROR +#if HAS_CLEAR_ERROR == 0 static inline struct ndctl_cmd *ndctl_bus_cmd_new_clear_error( unsigned long long address, unsigned long long len, struct ndctl_cmd *ars_cap)
Quoted 9 lines
Quoted 4 lines
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimmI know I'm repeating myself here, but isn't there a way to dynamically figure out if we can use ARS or the clear error stuff? The build host's kernel version doesn't necessarily reflect the capabilities of the target host's kernel.
Indeed, this is the default. The only way these definitions will disabled* is by specifying --disable-local to configure and use an old kernel header from before these commands were defined.
Jerry is also working on some patches to provide a more generic command passing mechanism for DIMM devices. That also might cut down on some of the compile-time thrash.
* Note that --enable-local is the default since this patch:
https://patchwork.kernel.org/patch/8538321/
_______________________________________________
Linux-nvdimm mailing list [email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm