san_path_err & multipath ANA support
v2 cover san_path_err & multipath ANA support
Hi Christophe,
this series consists of 3 parts. The first part improves the documentation on the current approaches to "shaky" or "marginal" path detection, and re-introduces the previously removed "san_path_err_xy" approach, which has been prematurely removed IMO. At the time, I thought that it was superseded by the "marginal path" algorithm, but I have my issues with latter (hopefully subject of a follow-up series), and I believe the "medium" complexity of the san_path_err code actually has its merits. But to be honest, my strongest reason to re-add it is that I have to continue to support it in SLES for some time to come.
The second part accumulates a few bug fixes.
The third part introduces NVMe ANA support to multipath-tools, based on the original patch from Li Jie of Huawei (#14). Instead of copy/pasting some code from nvme-cli, as Li Jie did, I decided to copy some nvme-cli code unmodified to our repo, and create a small wrapper around it. I took care not increase the generated binaries with code we don't need. I added detect_prio on top of it, and also added ANA support for the "foreign" code for native NVMe multipath. BTW: Instead of applying patch #12, it would probably be possible to simply add https://github.com/linux-nvme/nvme-cli as a submodule to multipath- tools. I haven't tried that yet.
One thing to note: in dm-multipath mode, multipathd can now read the ANA properties and derive prio values. But it can't react on updates from the storage so far, because the kernel doesn't generate events to user space if this happens. I haven't decided how to tackle this problem yet. Hints and comments are welcome. For now, I guess it's sufficient that multipathd makes prio updates in the checker loop.
Cheers,
Martin
Changes wrt v1:
- 15/20: Model ANA priorities after ALUA (Hannes)
- 15/20: Remove ana.h (Ben)
- 15/20: Remove check if device is NVMe (Ben)
- 20/20: Another minor fix for the NVMe foreign library
Kyle Mahlkuch (1):
libmultipath: Increase SERIAL_SIZE to 128 bytes
lijie (1):
multipath-tools: add ANA support for NVMe device
Martin Wilck (18):
multipath.conf.5: explain "shaky" path detection
libmultipath: propsel: don't print undefined values Revert "multipath-tools: discard san_path_err_XXX feature"
multipathd: marginal_path overrides san_path_err multipath.conf.5: man page fixes for san_path_err_xy
setup_map: wait for pending path checkers to finish
libmultipath: add ARRAY_SIZE helper
libmultipath: make close_fd() a common helper
libmultipath: restore PG prio in update_multipath_strings
multipathd: don't check foreign paths every tick
libmultipath: add files from nvme-cli for NVMe support
libmultipath: add wrapper library for nvme ioctls
libmultipath: ANA prioritzer: use nvme wrapper library
libmultipath: detect_prio: try ANA for NVMe libmultipath/foreign/nvme: use failover topology libmultipath/foreign/nvme: show ANA state libmultipath/foreign/nvme: indicate ANA support libmultipath/foreign/nvme: fix ouput for "%n" wildcard
libmultipath/Makefile | 18 +- libmultipath/config.c | 3 + libmultipath/config.h | 9 + libmultipath/configure.c | 86 +- libmultipath/dict.c | 39 + libmultipath/foreign/Makefile | 2 +- libmultipath/foreign/nvme.c | 187 ++-- libmultipath/nvme-lib.c | 49 + libmultipath/nvme-lib.h | 39 + libmultipath/nvme/argconfig.h | 99 ++ libmultipath/nvme/json.h | 87 ++ libmultipath/nvme/linux/nvme.h | 1450 ++++++++++++++++++++++++++++ libmultipath/nvme/nvme-ioctl.c | 869 +++++++++++++++++ libmultipath/nvme/nvme-ioctl.h | 139 +++ libmultipath/nvme/nvme.h | 163 ++++ libmultipath/nvme/plugin.h | 36 + libmultipath/prio.h | 1 + libmultipath/prioritizers/Makefile | 5 + libmultipath/prioritizers/ana.c | 232 +++++ libmultipath/propsel.c | 151 ++- libmultipath/propsel.h | 3 + libmultipath/structs.h | 30 +- libmultipath/structs_vec.c | 8 + libmultipath/sysfs.c | 5 - libmultipath/util.c | 5 + libmultipath/util.h | 3 + multipath/main.c | 4 - multipath/multipath.conf.5 | 141 ++- multipathd/main.c | 105 +- tests/hwtable.c | 2 +- 30 files changed, 3865 insertions(+), 105 deletions(-) create mode 100644 libmultipath/nvme-lib.c create mode 100644 libmultipath/nvme-lib.h create mode 100644 libmultipath/nvme/argconfig.h create mode 100644 libmultipath/nvme/json.h create mode 100644 libmultipath/nvme/linux/nvme.h create mode 100644 libmultipath/nvme/nvme-ioctl.c create mode 100644 libmultipath/nvme/nvme-ioctl.h create mode 100644 libmultipath/nvme/nvme.h create mode 100644 libmultipath/nvme/plugin.h create mode 100644 libmultipath/prioritizers/ana.c
Signature · 1 line
2.19.2
PATCH v2 1/20 libmultipath: Increase SERIAL_SIZE to 128 bytes
From: Kyle Mahlkuch <[email protected]>
Certain IBM FlashSystem LUNs can return up to 85 bytes of serial number in the Unit Serial Number VPD page, which is larger than the current SERIAL_SIZE definition of 65 bytes. Since the max size of this field does not appear to be defined in SPC, increasing to 128 bytes should hopefully prevent us from hitting this in future.
This is an example of a serial number from a FlashSystem:
Unit serial number VPD page:
Unit serial number: 3321360050764008101AB300000000000012204214503IBMfcp
Before this patch multipath returns the error:
Jul 17 11:24:58 | vpd pg80 overflow, 85/65 bytes required
After the patch is applied the error no longer occur.
--- libmultipath/structs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/structs.h +1 -1
@@ -9,7 +9,7 @@#include "generic.h" #define WWID_SIZE 128 -#define SERIAL_SIZE 65 +#define SERIAL_SIZE 128#define NODE_NAME_SIZE 224#define PATH_STR_SIZE 16#define PARAMS_SIZE 4096
Signature · 1 line
2.19.2
PATCH v2 2/20 multipath.conf.5: explain "shaky" path detection
In reply to Martin WilckExplain the "shaky path" detection algorithms, and how they relate to each other.
--- multipath/multipath.conf.5 | 59 ++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 6 deletions(-)
multipath/multipath.conf.5 +53 -6
@@ -898,7 +898,7 @@ error such as intermittent error. When a path failed event occurs twice in other three parameters are set, multipathd will fail the path and enqueue this path into a queue of which members are sent a couple of continuous direct reading asynchronous IOs at a fixed sample rate of 10HZ to start IO -error accounting process. +error accounting process. See "Shaky paths detection" below. .RS .TP The default is: \fBno\fR
@@ -920,7 +920,7 @@ If the rate of IO error on a particular path is greater than the \fImarginal_path_err_recheck_gap_time\fR seconds unless there is only one active path. After \fImarginal_path_err_recheck_gap_time\fR expires, the path will be requeueed for rechecking. If checking result is good enough, the -path will be reinstated. +path will be reinstated. See "Shaky paths detection" below. .RS .TP The default is: \fBno\fR
@@ -934,7 +934,7 @@ of supporting path check based on accounting IO error such as intermittent error. Refer to \fImarginal_path_err_sample_time\fR. If the rate of IO errors on a particular path is greater than this parameter, then the path will not reinstate for \fImarginal_path_err_recheck_gap_time\fR seconds unless there is -only one active path. +only one active path. See "Shaky paths detection" below. .RS .TP The default is: \fBno\fR
@@ -951,7 +951,7 @@ value, the failed path of which the IO error rate is larger than \fImarginal_path_err_recheck_gap_time\fR seconds. When \fImarginal_path_err_recheck_gap_time\fR seconds expires, the path will be requeueed for checking. If checking result is good enough, the path will be -reinstated, or else it will keep failed. +reinstated, or else it will keep failed. See "Shaky paths detection" below. .RS .TP The default is: \fBno\fR
@@ -963,7 +963,7 @@ The default is: \fBno\fR If set to a value greater than 0, multipathd will watch paths that have recently become valid for this many checks. If they fail again while they are being watched, when they next become valid, they will not be used until they -have stayed up for \fIdelay_wait_checks\fR checks. +have stayed up for \fIdelay_wait_checks\fR checks. See "Shaky paths detection" below. .RS .TP The default is: \fBno\fR
@@ -975,7 +975,7 @@ The default is: \fBno\fR If set to a value greater than 0, when a device that has recently come back online fails again within \fIdelay_watch_checks\fR checks, the next time it comes back online, it will marked and delayed, and not used until it has passed -\fIdelay_wait_checks\fR checks. +\fIdelay_wait_checks\fR checks. See "Shaky paths detection" below. .RS .TP The default is: \fBno\fR
@@ -1578,6 +1578,53 @@ are present multipath will try to use the sysfs attribute . . .\" ---------------------------------------------------------------------------- +.SH "Shaky paths detection" +.\" ---------------------------------------------------------------------------- +. +A common problem in SAN setups is the occurence of intermittent errors: a +path is unreachable, then reachable again for a short time, disappears again, +and so forth. This happens typically on unstable interconnects. It is +undesirable to switch pathgroups unnecessarily on such frequent, unreliable +events. \fImultipathd\fR supports two different methods for detecting this +situation and dealing with it. All methods share the same basic mode of +operation: If a path is found to be \(dqshaky\(dq or \(dqflipping\(dq, +and appears to be in healthy status, it is not reinstated (put back to use) +immediately. Instead, it is watched for some time, and only reinstated +if the healthy state appears to be stable. The logic of determining +\(dqshaky\(dq condition, as well as the logic when to reinstate, +differs between the methods. +.TP 8 +.B \(dqdelay_checks\(dq failure tracking +If a path fails again within a +\fIdelay_watch_checks\fR interval after a failure, don't +reinstate it until it passes a \fIdelay_wait_checks\fR interval +in always good status. +The intervals are measured in \(dqticks\(dq, i.e. the +time between path checks by multipathd, which is variable and controlled by the +\fIpolling_interval\fR and \fImax_polling_interval\fR parameters. +.TP +.B \(dqmarginal_path\(dq failure tracking +If a second failure event (good->bad transition) occurs within +\fImarginal_path_double_failed_time\fR seconds after a failure, high-frequency +monitoring is started for the affected path: I/O is sent at a rate of 10 per +second. This is done for \fImarginal_path_err_sample_time\fR seconds. During +this period, the path is not reinstated. If the +rate of errors remains below \fImarginal_path_err_rate_threshold\fR during the +monitoring period, the path is reinstated. Otherwise, it +is kept in failed state for \fImarginal_path_err_recheck_gap_time\fR, and +after that, it is monitored again. For this method, time intervals are measured +in seconds. +. +.RE +.LP +. +See the documentation of the individual options above for details. +It is \fBstrongly discouraged\fR to use more than one of these methods for any +given multipath map, because the two concurrent methods may interact in +unpredictable ways. +. +. +.\" ---------------------------------------------------------------------------- .SH "KNOWN ISSUES" .\" ---------------------------------------------------------------------------- .
Signature · 1 line
2.19.2
PATCH v2 3/20 libmultipath: propsel: don't print undefined values
In reply to Martin Wilckprint_off_int_undef() may return 0 if passed NU_UNDEF, in which case the buffer contents are undefined.
--- libmultipath/propsel.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-)
libmultipath/propsel.c +24 -18
@@ -855,8 +855,9 @@ int select_delay_watch_checks(struct config *conf, struct multipath *mp)mp_set_conf (delay_watch_checks);mp_set_default (delay_watch_checks,DEFAULT_DELAY_CHECKS ); out: -print_off_int_undef (buff,12 , mp->delay_watch_checks); -condlog (3 ,"%s: delay_watch_checks = %s %s" , mp->alias, buff, origin); +if (print_off_int_undef (buff,12 , mp->delay_watch_checks) !=0 ) +condlog (3 ,"%s: delay_watch_checks = %s %s" , + mp->alias, buff, origin);return 0 ; }
@@ -871,8 +872,9 @@ int select_delay_wait_checks(struct config *conf, struct multipath *mp)mp_set_conf (delay_wait_checks);mp_set_default (delay_wait_checks,DEFAULT_DELAY_CHECKS ); out: -print_off_int_undef (buff,12 , mp->delay_wait_checks); -condlog (3 ,"%s: delay_wait_checks = %s %s" , mp->alias, buff, origin); +if (print_off_int_undef (buff,12 , mp->delay_wait_checks) !=0 ) +condlog (3 ,"%s: delay_wait_checks = %s %s" , + mp->alias, buff, origin);return 0 ; }
@@ -888,9 +890,10 @@ int select_marginal_path_err_sample_time(struct config *conf, struct multipath *mp_set_conf (marginal_path_err_sample_time);mp_set_default (marginal_path_err_sample_time,DEFAULT_ERR_CHECKS ); out: -print_off_int_undef (buff,12 , mp->marginal_path_err_sample_time); -condlog (3 ,"%s: marginal_path_err_sample_time = %s %s" , mp->alias, buff, - origin); +if (print_off_int_undef (buff,12 , mp->marginal_path_err_sample_time) + !=0 ) +condlog (3 ,"%s: marginal_path_err_sample_time = %s %s" , + mp->alias, buff, origin);return 0 ; }
@@ -905,9 +908,10 @@ int select_marginal_path_err_rate_threshold(struct config *conf, struct multipatmp_set_conf (marginal_path_err_rate_threshold);mp_set_default (marginal_path_err_rate_threshold,DEFAULT_ERR_CHECKS ); out: -print_off_int_undef (buff,12 , mp->marginal_path_err_rate_threshold); -condlog (3 ,"%s: marginal_path_err_rate_threshold = %s %s" , mp->alias, buff, - origin); +if (print_off_int_undef (buff,12 , mp->marginal_path_err_rate_threshold) + !=0 ) +condlog (3 ,"%s: marginal_path_err_rate_threshold = %s %s" , + mp->alias, buff, origin);return 0 ; }
@@ -922,9 +926,10 @@ int select_marginal_path_err_recheck_gap_time(struct config *conf, struct multipmp_set_conf (marginal_path_err_recheck_gap_time);mp_set_default (marginal_path_err_recheck_gap_time,DEFAULT_ERR_CHECKS ); out: -print_off_int_undef (buff,12 , mp->marginal_path_err_recheck_gap_time); -condlog (3 ,"%s: marginal_path_err_recheck_gap_time = %s %s" , mp->alias, buff, - origin); +if (print_off_int_undef (buff,12 , + mp->marginal_path_err_recheck_gap_time) !=0 ) +condlog (3 ,"%s: marginal_path_err_recheck_gap_time = %s %s" , + mp->alias, buff, origin);return 0 ; }
@@ -939,9 +944,10 @@ int select_marginal_path_double_failed_time(struct config *conf, struct multipatmp_set_conf (marginal_path_double_failed_time);mp_set_default (marginal_path_double_failed_time,DEFAULT_ERR_CHECKS ); out: -print_off_int_undef (buff,12 , mp->marginal_path_double_failed_time); -condlog (3 ,"%s: marginal_path_double_failed_time = %s %s" , mp->alias, buff, - origin); +if (print_off_int_undef (buff,12 , mp->marginal_path_double_failed_time) + !=0 ) +condlog (3 ,"%s: marginal_path_double_failed_time = %s %s" , + mp->alias, buff, origin);return 0 ; }
@@ -993,8 +999,8 @@ int select_ghost_delay (struct config *conf, struct multipath * mp)mp_set_conf (ghost_delay);mp_set_default (ghost_delay,DEFAULT_GHOST_DELAY ); out: -print_off_int_undef (buff,12 , mp->ghost_delay); -condlog (3 ,"%s: ghost_delay = %s %s" , mp->alias, buff, origin); +if (print_off_int_undef (buff,12 , mp->ghost_delay) !=0 ) +condlog (3 ,"%s: ghost_delay = %s %s" , mp->alias, buff, origin);return 0 ; }
Signature · 1 line
2.19.2
PATCH v2 4/20 Revert "multipath-tools: discard san_path_err_XXX feature"
In reply to Martin WilckThis reverts commit 9cf6a48f18a291982af34b4fb0110654b94e591c. We removed this functionality prematurely. I am not convinced that the "marginal_path" code really replaces it. Let customers evaluate the different options, and vote with their feet.
--- libmultipath/config.c | 3 ++ libmultipath/config.h | 9 ++++ libmultipath/configure.c | 3 ++ libmultipath/dict.c | 39 ++++++++++++++++++ libmultipath/propsel.c | 53 ++++++++++++++++++++++++ libmultipath/propsel.h | 3 ++ libmultipath/structs.h | 7 ++++ multipath/multipath.conf.5 | 57 ++++++++++++++++++++++++++ multipathd/main.c | 84 ++++++++++++++++++++++++++++++++++++++ 9 files changed, 258 insertions(+)
libmultipath/config.c +3 -0
@@ -369,6 +369,9 @@ merge_hwe (struct hwentry * dst, struct hwentry * src)merge_num (max_sectors_kb);merge_num (ghost_delay);merge_num (all_tg_pt); +merge_num (san_path_err_threshold); +merge_num (san_path_err_forget_rate); +merge_num (san_path_err_recovery_time);snprintf (id,sizeof (id),"%s/%s" , dst->vendor, dst->product); reconcile_features_with_options(id, &dst->features,
libmultipath/config.h +9 -0
@@ -76,6 +76,9 @@ struct hwentry {int deferred_remove;int delay_watch_checks;int delay_wait_checks; +int san_path_err_threshold; +int san_path_err_forget_rate; +int san_path_err_recovery_time;int marginal_path_err_sample_time;int marginal_path_err_rate_threshold;int marginal_path_err_recheck_gap_time;
@@ -112,6 +115,9 @@ struct mpentry {int deferred_remove;int delay_watch_checks;int delay_wait_checks; +int san_path_err_threshold; +int san_path_err_forget_rate; +int san_path_err_recovery_time;int marginal_path_err_sample_time;int marginal_path_err_rate_threshold;int marginal_path_err_recheck_gap_time;
@@ -162,6 +168,9 @@ struct config {int processed_main_config;int delay_watch_checks;int delay_wait_checks; +int san_path_err_threshold; +int san_path_err_forget_rate; +int san_path_err_recovery_time;int marginal_path_err_sample_time;int marginal_path_err_rate_threshold;int marginal_path_err_recheck_gap_time;
libmultipath/configure.c +3 -0
@@ -309,6 +309,9 @@ int setup_map(struct multipath *mpp, char *params, int params_size,select_deferred_remove (conf, mpp);select_delay_watch_checks (conf, mpp);select_delay_wait_checks (conf, mpp); +select_san_path_err_threshold (conf, mpp); +select_san_path_err_forget_rate (conf, mpp); +select_san_path_err_recovery_time (conf, mpp);select_marginal_path_err_sample_time (conf, mpp);select_marginal_path_err_rate_threshold (conf, mpp);select_marginal_path_err_recheck_gap_time (conf, mpp);
libmultipath/dict.c +39 -0
@@ -1217,6 +1217,33 @@ declare_hw_handler(delay_wait_checks, set_off_int_undef) declare_hw_snprint(delay_wait_checks, print_off_int_undef) declare_mp_handler(delay_wait_checks, set_off_int_undef) declare_mp_snprint(delay_wait_checks, print_off_int_undef) +declare_def_handler(san_path_err_threshold, set_off_int_undef) +declare_def_snprint_defint (san_path_err_threshold, print_off_int_undef, + DEFAULT_ERR_CHECKS) +declare_ovr_handler(san_path_err_threshold, set_off_int_undef) +declare_ovr_snprint(san_path_err_threshold, print_off_int_undef) +declare_hw_handler(san_path_err_threshold, set_off_int_undef) +declare_hw_snprint(san_path_err_threshold, print_off_int_undef) +declare_mp_handler(san_path_err_threshold, set_off_int_undef) +declare_mp_snprint(san_path_err_threshold, print_off_int_undef) +declare_def_handler(san_path_err_forget_rate, set_off_int_undef) +declare_def_snprint_defint (san_path_err_forget_rate, print_off_int_undef, + DEFAULT_ERR_CHECKS) +declare_ovr_handler(san_path_err_forget_rate, set_off_int_undef) +declare_ovr_snprint(san_path_err_forget_rate, print_off_int_undef) +declare_hw_handler(san_path_err_forget_rate, set_off_int_undef) +declare_hw_snprint(san_path_err_forget_rate, print_off_int_undef) +declare_mp_handler(san_path_err_forget_rate, set_off_int_undef) +declare_mp_snprint(san_path_err_forget_rate, print_off_int_undef) +declare_def_handler(san_path_err_recovery_time, set_off_int_undef) +declare_def_snprint_defint (san_path_err_recovery_time, print_off_int_undef, + DEFAULT_ERR_CHECKS) +declare_ovr_handler(san_path_err_recovery_time, set_off_int_undef) +declare_ovr_snprint(san_path_err_recovery_time, print_off_int_undef) +declare_hw_handler(san_path_err_recovery_time, set_off_int_undef) +declare_hw_snprint(san_path_err_recovery_time, print_off_int_undef) +declare_mp_handler(san_path_err_recovery_time, set_off_int_undef) +declare_mp_snprint(san_path_err_recovery_time, print_off_int_undef) declare_def_handler(marginal_path_err_sample_time, set_off_int_undef)declare_def_snprint_defint (marginal_path_err_sample_time, print_off_int_undef,DEFAULT_ERR_CHECKS )
@@ -1620,6 +1647,9 @@ init_keywords(vector keywords)install_keyword ("config_dir" , &def_config_dir_handler, &snprint_def_config_dir);install_keyword ("delay_watch_checks" , &def_delay_watch_checks_handler, &snprint_def_delay_watch_checks);install_keyword ("delay_wait_checks" , &def_delay_wait_checks_handler, &snprint_def_delay_wait_checks); +install_keyword ("san_path_err_threshold" , &def_san_path_err_threshold_handler, &snprint_def_san_path_err_threshold); +install_keyword ("san_path_err_forget_rate" , &def_san_path_err_forget_rate_handler, &snprint_def_san_path_err_forget_rate); +install_keyword ("san_path_err_recovery_time" , &def_san_path_err_recovery_time_handler, &snprint_def_san_path_err_recovery_time);install_keyword ("marginal_path_err_sample_time" , &def_marginal_path_err_sample_time_handler, &snprint_def_marginal_path_err_sample_time);install_keyword ("marginal_path_err_rate_threshold" , &def_marginal_path_err_rate_threshold_handler, &snprint_def_marginal_path_err_rate_threshold);install_keyword ("marginal_path_err_recheck_gap_time" , &def_marginal_path_err_recheck_gap_time_handler, &snprint_def_marginal_path_err_recheck_gap_time);
@@ -1714,6 +1744,9 @@ init_keywords(vector keywords)install_keyword ("deferred_remove" , &hw_deferred_remove_handler, &snprint_hw_deferred_remove);install_keyword ("delay_watch_checks" , &hw_delay_watch_checks_handler, &snprint_hw_delay_watch_checks);install_keyword ("delay_wait_checks" , &hw_delay_wait_checks_handler, &snprint_hw_delay_wait_checks); +install_keyword ("san_path_err_threshold" , &hw_san_path_err_threshold_handler, &snprint_hw_san_path_err_threshold); +install_keyword ("san_path_err_forget_rate" , &hw_san_path_err_forget_rate_handler, &snprint_hw_san_path_err_forget_rate); +install_keyword ("san_path_err_recovery_time" , &hw_san_path_err_recovery_time_handler, &snprint_hw_san_path_err_recovery_time);install_keyword ("marginal_path_err_sample_time" , &hw_marginal_path_err_sample_time_handler, &snprint_hw_marginal_path_err_sample_time);install_keyword ("marginal_path_err_rate_threshold" , &hw_marginal_path_err_rate_threshold_handler, &snprint_hw_marginal_path_err_rate_threshold);install_keyword ("marginal_path_err_recheck_gap_time" , &hw_marginal_path_err_recheck_gap_time_handler, &snprint_hw_marginal_path_err_recheck_gap_time);
@@ -1750,6 +1783,9 @@ init_keywords(vector keywords)install_keyword ("deferred_remove" , &ovr_deferred_remove_handler, &snprint_ovr_deferred_remove);install_keyword ("delay_watch_checks" , &ovr_delay_watch_checks_handler, &snprint_ovr_delay_watch_checks);install_keyword ("delay_wait_checks" , &ovr_delay_wait_checks_handler, &snprint_ovr_delay_wait_checks); +install_keyword ("san_path_err_threshold" , &ovr_san_path_err_threshold_handler, &snprint_ovr_san_path_err_threshold); +install_keyword ("san_path_err_forget_rate" , &ovr_san_path_err_forget_rate_handler, &snprint_ovr_san_path_err_forget_rate); +install_keyword ("san_path_err_recovery_time" , &ovr_san_path_err_recovery_time_handler, &snprint_ovr_san_path_err_recovery_time);install_keyword ("marginal_path_err_sample_time" , &ovr_marginal_path_err_sample_time_handler, &snprint_ovr_marginal_path_err_sample_time);install_keyword ("marginal_path_err_rate_threshold" , &ovr_marginal_path_err_rate_threshold_handler, &snprint_ovr_marginal_path_err_rate_threshold);install_keyword ("marginal_path_err_recheck_gap_time" , &ovr_marginal_path_err_recheck_gap_time_handler, &snprint_ovr_marginal_path_err_recheck_gap_time);
@@ -1785,6 +1821,9 @@ init_keywords(vector keywords)install_keyword ("deferred_remove" , &mp_deferred_remove_handler, &snprint_mp_deferred_remove);install_keyword ("delay_watch_checks" , &mp_delay_watch_checks_handler, &snprint_mp_delay_watch_checks);install_keyword ("delay_wait_checks" , &mp_delay_wait_checks_handler, &snprint_mp_delay_wait_checks); +install_keyword ("san_path_err_threshold" , &mp_san_path_err_threshold_handler, &snprint_mp_san_path_err_threshold); +install_keyword ("san_path_err_forget_rate" , &mp_san_path_err_forget_rate_handler, &snprint_mp_san_path_err_forget_rate); +install_keyword ("san_path_err_recovery_time" , &mp_san_path_err_recovery_time_handler, &snprint_mp_san_path_err_recovery_time);install_keyword ("marginal_path_err_sample_time" , &mp_marginal_path_err_sample_time_handler, &snprint_mp_marginal_path_err_sample_time);install_keyword ("marginal_path_err_rate_threshold" , &mp_marginal_path_err_rate_threshold_handler, &snprint_mp_marginal_path_err_rate_threshold);install_keyword ("marginal_path_err_recheck_gap_time" , &mp_marginal_path_err_recheck_gap_time_handler, &snprint_mp_marginal_path_err_recheck_gap_time);
libmultipath/propsel.c +53 -0
59 lines not on this page · raw message
libmultipath/propsel.h +3 -0
@@ -26,6 +26,9 @@ int select_delay_watch_checks (struct config *conf, struct multipath * mp);int select_delay_wait_checks (struct config *conf,struct multipath * mp);int select_skip_kpartx (struct config *conf,struct multipath * mp);int select_max_sectors_kb (struct config *conf,struct multipath * mp); +int select_san_path_err_forget_rate (struct config *conf,struct multipath *mp); +int select_san_path_err_threshold (struct config *conf,struct multipath *mp); +int select_san_path_err_recovery_time (struct config *conf,struct multipath *mp);int select_marginal_path_err_sample_time (struct config *conf,struct multipath *mp);int select_marginal_path_err_rate_threshold (struct config *conf,struct multipath *mp);int select_marginal_path_err_recheck_gap_time (struct config *conf,struct multipath *mp);
libmultipath/structs.h +7 -0
@@ -280,6 +280,10 @@ struct path {int initialized;int retriggers;int wwid_changed; +unsigned int path_failures; +time_t dis_reinstate_time; +int disable_reinstate; +int san_path_err_forget_rate;time_t io_err_dis_reinstate_time;int io_err_disable_reinstate;int io_err_pathfail_cnt;
@@ -318,6 +322,9 @@ struct multipath {int deferred_remove;int delay_watch_checks;int delay_wait_checks; +int san_path_err_threshold; +int san_path_err_forget_rate; +int san_path_err_recovery_time;int marginal_path_err_sample_time;int marginal_path_err_rate_threshold;int marginal_path_err_recheck_gap_time;
multipath/multipath.conf.5 +57 -0
81 lines not on this page · raw message
multipathd/main.c +84 -0
96 lines not on this page · raw message
Signature · 1 line
2.19.2
PATCH v2 5/20 multipathd: marginal_path overrides san_path_err
In reply to Martin Wilckdisable san_path_err_XY if marginal path checking is enabled. Also warn about san_path_err_XY being deprecated, and warn if any of the two is used in combination with delay_XY_checks.
Add some minor fixes to the san_path_err code, and a comment that explains a part of the code that was not immediately obvious to me.
--- libmultipath/configure.c | 24 ++++++++++++++------ libmultipath/propsel.c | 49 ++++++++++++++++++++++++++++++++-------- libmultipath/structs.h | 21 +++++++++++++++++ multipathd/main.c | 10 ++++++++ 4 files changed, 88 insertions(+), 16 deletions(-)
libmultipath/configure.c +17 -7
@@ -309,13 +309,13 @@ int setup_map(struct multipath *mpp, char *params, int params_size,select_deferred_remove (conf, mpp);select_delay_watch_checks (conf, mpp);select_delay_wait_checks (conf, mpp); -select_san_path_err_threshold (conf, mpp); -select_san_path_err_forget_rate (conf, mpp); -select_san_path_err_recovery_time (conf, mpp);select_marginal_path_err_sample_time (conf, mpp);select_marginal_path_err_rate_threshold (conf, mpp);select_marginal_path_err_recheck_gap_time (conf, mpp);select_marginal_path_double_failed_time (conf, mpp); +select_san_path_err_threshold (conf, mpp); +select_san_path_err_forget_rate (conf, mpp); +select_san_path_err_recovery_time (conf, mpp);select_skip_kpartx (conf, mpp);select_max_sectors_kb (conf, mpp);select_ghost_delay (conf, mpp);
@@ -324,11 +324,21 @@ int setup_map(struct multipath *mpp, char *params, int params_size,sysfs_set_scsi_tmo (mpp, conf->checkint);pthread_cleanup_pop (1 ); -if (mpp->marginal_path_double_failed_time >0 && - mpp->marginal_path_err_sample_time >0 && - mpp->marginal_path_err_recheck_gap_time >0 && - mpp->marginal_path_err_rate_threshold >=0 ) +if (marginal_path_check_enabled (mpp)) { +if (delay_check_enabled (mpp)) { +condlog (1 ,"%s: WARNING: both marginal_path and delay_checks error detection selected" , + mpp->alias); +condlog (0 ,"%s: unexpected behavior may occur!" , + mpp->alias); + }start_io_err_stat_thread (vecs); + } +if (san_path_check_enabled (mpp) &&delay_check_enabled (mpp)) { +condlog (1 ,"%s: WARNING: both san_path_err and delay_checks error detection selected" , + mpp->alias); +condlog (0 ,"%s: unexpected behavior may occur!" , + mpp->alias); + }/* * assign paths to path groups -- start with no groups and all paths * in mpp->paths
libmultipath/propsel.c +40 -9
96 lines not on this page · raw message
libmultipath/structs.h +21 -0
@@ -377,6 +377,27 @@ struct multipath {struct gen_multipath generic_mp; }; +static inline int marginal_path_check_enabled (const struct multipath *mpp) +{ +return mpp->marginal_path_double_failed_time >0 && + mpp->marginal_path_err_sample_time >0 && + mpp->marginal_path_err_recheck_gap_time >0 && + mpp->marginal_path_err_rate_threshold >=0 ; +} + +static inline int san_path_check_enabled (const struct multipath *mpp) +{ +return mpp->san_path_err_threshold >0 && + mpp->san_path_err_forget_rate >0 && + mpp->san_path_err_recovery_time >0 ; +} + +static inline int delay_check_enabled (const struct multipath *mpp) +{ +return mpp->delay_watch_checks !=NU_NO || + mpp->delay_wait_checks !=NU_NO ; +} +struct pathgroup {long id;int status;
multipathd/main.c +10 -0
@@ -1835,6 +1835,16 @@ int update_path_groups(struct multipath *mpp, struct vectors *vecs, int refresh)static int check_path_reinstate_state (struct path * pp) {struct timespec curr_time; + +/* +* This function is only called when the path state changes +* from "bad" to "good". pp->state reflects the *previous* state. +* If this was "bad", we know that a failure must have occured +* beforehand, and count that. +* Note that we count path state _changes_ this way. If a path +* remains in "bad" state, failure count is not increased. +*/ +if (!((pp->mpp->san_path_err_threshold >0 ) && (pp->mpp->san_path_err_forget_rate >0 ) && (pp->mpp->san_path_err_recovery_time >0 ))) {
Signature · 1 line
2.19.2
PATCH v2 6/20 multipath.conf.5: man page fixes for san_path_err_xy
In reply to Martin WilckThis adds a paragraph about the san_path_err algorithm to the "shaky paths" section of the man page.
--- multipath/multipath.conf.5 | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)
multipath/multipath.conf.5 +26 -9
@@ -894,10 +894,10 @@ The default is: \fB/etc/multipath/conf.d/\fR .B san_path_err_threshold If set to a value greater than 0, multipathd will watch paths and check how many times a path has been failed due to errors.If the number of failures on a particular -path is greater then the san_path_err_threshold then the path will not reinstante -till san_path_err_recovery_time.These path failures should occur within a +path is greater then the san_path_err_threshold, then the path will not reinstate +till san_path_err_recovery_time. These path failures should occur within a san_path_err_forget_rate checks, if not we will consider the path is good enough -to reinstantate. +to reinstantate. See "Shaky paths detection" below. .RS .TP The default is: \fBno\fR
@@ -909,7 +909,7 @@ The default is: \fBno\fR If set to a value greater than 0, multipathd will check whether the path failures has exceeded the san_path_err_threshold within this many checks i.e san_path_err_forget_rate . If so we will not reinstante the path till -san_path_err_recovery_time. +san_path_err_recovery_time. See "Shaky paths detection" below. .RS .TP The default is: \fBno\fR
@@ -923,6 +923,7 @@ has exceeded the san_path_err_threshold within san_path_err_forget_rate then the will be placed in failed state for san_path_err_recovery_time duration.Once san_path_err_recovery_time has timeout we will reinstante the failed path . san_path_err_recovery_time value should be in secs. +See "Shaky paths detection" below. .RS .TP The default is: \fBno\fR
@@ -1642,14 +1643,14 @@ A common problem in SAN setups is the occurence of intermittent errors: a path is unreachable, then reachable again for a short time, disappears again, and so forth. This happens typically on unstable interconnects. It is undesirable to switch pathgroups unnecessarily on such frequent, unreliable -events. \fImultipathd\fR supports two different methods for detecting this +events. \fImultipathd\fR supports three different methods for detecting this situation and dealing with it. All methods share the same basic mode of operation: If a path is found to be \(dqshaky\(dq or \(dqflipping\(dq, and appears to be in healthy status, it is not reinstated (put back to use) immediately. Instead, it is watched for some time, and only reinstated if the healthy state appears to be stable. The logic of determining \(dqshaky\(dq condition, as well as the logic when to reinstate, -differs between the methods. +differs between the three methods. .TP 8 .B \(dqdelay_checks\(dq failure tracking If a path fails again within a
@@ -1671,14 +1672,30 @@ monitoring period, the path is reinstated. Otherwise, it is kept in failed state for \fImarginal_path_err_recheck_gap_time\fR, and after that, it is monitored again. For this method, time intervals are measured in seconds. +.TP +.B \(dqsan_path_err\(dq failure tracking +multipathd counts path failures for each path. Once the number of failures +exceeds the value given by \fIsan_path_err_threshold\fR, the path is not +reinstated for \fIsan_path_err_recovery_time\fR ticks. While counting +failures, multipathd \(dqforgets\(dq one past failure every +\(dqsan_path_err_forget_rate\(dq ticks; thus if errors don't occur more +often then once in the forget rate interval, the failure count doesn't +increase and the threshold is never reached. As for the \fIdelay_xy\fR method, +intervals are measured in \(dqticks\(dq. +. +.RS 8 +.LP +This method is \fBdeprecated\fR in favor of the \(dqmarginal_path\(dq failure +tracking method, and only offered for backward compatibility. . .RE .LP -. -See the documentation of the individual options above for details. +See the documentation +of the individual options above for details. It is \fBstrongly discouraged\fR to use more than one of these methods for any given multipath map, because the two concurrent methods may interact in -unpredictable ways. +unpredictable ways. If the \(dqmarginal_path\(dq method is active, the +\(dqsan_path_err\(dq parameters are implicitly set to 0. . . .\" ----------------------------------------------------------------------------
Signature · 1 line
2.19.2
PATCH v2 7/20 setup_map: wait for pending path checkers to finish
In reply to Martin WilckThe timeout for synchronous checks is only 1ms when async path checking is used, which may easily be missed on busy systems. That's not a problem for the path checker, because it simply repeats the check one tick later. However, when maps are set up (e.g. when new paths are detected), it's desirable to get the number of active paths right. Therefore, wait a bit longer if path checkers are found pending in setup_map().
--- libmultipath/configure.c | 65 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-)
libmultipath/configure.c +63 -2
@@ -44,6 +44,10 @@#include "sysfs.h" #include "io_err_stat.h" +/* Time in ms to wait for pending checkers in setup_map() */ +#define WAIT_CHECKERS_PENDING_MS 10 +#define WAIT_ALL_CHECKERS_PENDING_MS 90 +/* group paths in pg by host adapter */ int group_by_host_adapter (struct pathgroup *pgp,vector adapters)
@@ -257,12 +261,43 @@ int rr_optimize_path_order(struct pathgroup *pgp)return 0 ; } +static int wait_for_pending_paths (struct multipath *mpp, +struct config *conf, +int n_pending,int goal,int wait_ms) +{ +static const struct timespec millisec = + { .tv_sec =0 , .tv_nsec =1000 *1000 }; +int i, j; +struct path *pp; +struct pathgroup *pgp; +struct timespec ts; + +do { + vector_foreach_slot(mpp->pg, pgp, i) { + vector_foreach_slot(pgp->paths, pp, j) { +if (pp->state !=PATH_PENDING ) +continue ; + pp->state =get_state (pp, conf, +0 ,PATH_PENDING ); +if (pp->state !=PATH_PENDING && + --n_pending <= goal) +return 0 ; + } + } + ts = millisec; +while (nanosleep (&ts, &ts) !=0 && errno ==EINTR ) +/* nothing */ ; + }while (--wait_ms >0 ); + +return n_pending; +} +int setup_map (struct multipath *mpp,char *params,int params_size,struct vectors *vecs) {struct pathgroup * pgp;struct config *conf; -int i; +int i, n_paths;/* * don't bother if devmap size is unknown
@@ -339,7 +374,9 @@ int setup_map(struct multipath *mpp, char *params, int params_size,condlog (0 ,"%s: unexpected behavior may occur!" , mpp->alias); } -/* + + n_paths =VECTOR_SIZE (mpp->paths); +/* * assign paths to path groups -- start with no groups and all paths * in mpp->paths */
@@ -353,6 +390,30 @@ int setup_map(struct multipath *mpp, char *params, int params_size,if (mpp->pgpolicyfn && mpp->pgpolicyfn (mpp))return 1 ; +/* +* If async state detection is used, see if pending state checks +* have finished, to get nr_active right. We can't wait until the +* checkers time out, as that may take 30s or more, and we are +* holding the vecs lock. +*/ +if (conf->force_sync ==0 && n_paths >0 ) { +int n_pending =pathcount (mpp,PATH_PENDING ); + +if (n_pending >0 ) + n_pending =wait_for_pending_paths ( + mpp, conf, n_pending,0 , +WAIT_CHECKERS_PENDING_MS ); +/* ALL paths pending - wait some more, but be satisfied +with only some paths finished */ +if (n_pending == n_paths) + n_pending =wait_for_pending_paths ( + mpp, conf, n_pending, + n_paths >=4 ?2 :1 , +WAIT_ALL_CHECKERS_PENDING_MS ); +if (n_pending >0 ) +condlog (2 ,"%s: setting up map with %d/%d path checkers pending" , + mpp->alias, n_pending, n_paths); + } mpp->nr_active =pathcount (mpp,PATH_UP ) +pathcount (mpp,PATH_GHOST );/*
Signature · 1 line
2.19.2
PATCH v2 8/20 libmultipath: add ARRAY_SIZE helper
In reply to Martin Wilck--- libmultipath/util.h | 1 + tests/hwtable.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
libmultipath/util.h +1 -0
@@ -25,6 +25,7 @@ int safe_write(int fd, const void *buf, size_t count);void set_max_fds (int max_fds);#define KERNEL_VERSION (maj, min, ptc) ((((maj) * 256) + (min)) * 256 + (ptc)) +#define ARRAY_SIZE (x) (sizeof(x)/sizeof((x)[0])) #define safe_sprintf(var, format, args...) \ snprintf(var, sizeof(var), format, ##args) >= sizeof(var)
tests/hwtable.c +1 -1
@@ -24,8 +24,8 @@#include "pgpolicies.h" #include "test-lib.h" #include "print.h" +#include "util.h" -#define ARRAY_SIZE (x) (sizeof(x)/sizeof((x)[0]))#define N_CONF_FILES 2static const char tmplate[] ="/tmp/hwtable-XXXXXX" ;
Signature · 1 line
2.19.2
PATCH v2 9/20 libmultipath: make close_fd() a common helper
In reply to Martin Wilckmove close_fd() into util.c.
--- libmultipath/sysfs.c | 5 ----- libmultipath/util.c | 5 +++++ libmultipath/util.h | 2 ++ multipath/main.c | 4 ---- 4 files changed, 7 insertions(+), 9 deletions(-)
libmultipath/sysfs.c +0 -5
@@ -295,11 +295,6 @@ static int select_dm_devs(const struct dirent *di)return fnmatch ("dm-*" , di->d_name,FNM_FILE_NAME ) ==0 ; } -static void close_fd (void *arg) -{ -close ((long )arg); -} -bool sysfs_is_multipathed (const struct path *pp) {char pathbuf[PATH_MAX ];
libmultipath/util.c +5 -0
@@ -506,3 +506,8 @@ void free_scandir_result(struct scandir_result *res)FREE (res->di[i]);FREE (res->di); } + +void close_fd (void *arg) +{ +close ((long )arg); +}
libmultipath/util.h +2 -0
@@ -35,6 +35,8 @@ void set_max_fds(int max_fds);#define pthread_cleanup_push_cast (f, arg) \ pthread_cleanup_push(((void (*)(void *))&f), (arg)) +void close_fd (void *arg); +struct scandir_result {struct dirent **di;int n;
multipath/main.c +0 -4
@@ -388,10 +388,6 @@ enum { };static const char shm_find_mp_dir[] =MULTIPATH_SHM_BASE "find_multipaths" ; -static void close_fd (void *arg) -{ -close ((long )arg); -}/** * find_multipaths_check_timeout(wwid, tmo)
Signature · 1 line
2.19.2
PATCH v2 10/20 libmultipath: restore PG prio in update_multipath_strings
In reply to Martin Wilckupdate_multipath_strings() destroys and recreates the pathgroup vector. This wipes information previously stored. Restore the path group priorities.
printing"
--- libmultipath/structs_vec.c | 8 ++++++++ 1 file changed, 8 insertions(+)
libmultipath/structs_vec.c +8 -0
@@ -18,6 +18,7 @@#include "configure.h" #include "libdevmapper.h" #include "io_err_stat.h" +#include "switchgroup.h" /* * creates or updates mpp->paths reading mpp->pg
@@ -261,6 +262,9 @@ void sync_paths(struct multipath *mpp, vector pathvec)int update_multipath_strings (struct multipath *mpp,vector pathvec,int is_daemon) { +struct pathgroup *pgp; +int i; +if (!mpp)return 1 ;
@@ -278,6 +282,10 @@ update_multipath_strings(struct multipath *mpp, vector pathvec, int is_daemon)if (update_multipath_status (mpp))return 1 ; + vector_foreach_slot(mpp->pg, pgp, i) +if (pgp->paths) +path_group_prio_update (pgp); +return 0 ; }
Signature · 1 line
2.19.2
PATCH v2 11/20 multipathd: don't check foreign paths every tick
In reply to Martin WilckWe don't do this for native paths, so don't do it for foreigns, either. Instead use max_checkint for foreign paths, always.
--- multipathd/main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
multipathd/main.c +10 -1
@@ -2271,6 +2271,7 @@ checkerloop (void *ap)unsigned int i;struct timespec last_time;struct config *conf; +int foreign_tick =0 ;pthread_cleanup_push (rcu_unregister,NULL );rcu_register_thread ();
@@ -2368,7 +2369,15 @@ checkerloop (void *ap) diff_time.tv_sec); } } -check_foreign (); + +if (foreign_tick ==0 ) { + conf =get_multipath_config (); + foreign_tick = conf->max_checkint; +put_multipath_config (conf); + } +if (--foreign_tick ==0 ) +check_foreign (); +post_config_state (DAEMON_IDLE ); conf =get_multipath_config (); strict_timing = conf->strict_timing;
Signature · 1 line
2.19.2
PATCH v2 12/20 libmultipath: add files from nvme-cli for NVMe support
In reply to Martin WilckAdded code from https://github.com/linux-nvme/nvme-cli in the "libmultipath/nvme" subdirectory.
This code is licensed under GPL v2.0.
The idea is to add this code unmodified and add a simple wrapper for libmultipath, so that upstream nvme-cli bug fixes can be most easily integrated.
--- libmultipath/nvme/argconfig.h | 99 +++ libmultipath/nvme/json.h | 87 ++ libmultipath/nvme/linux/nvme.h | 1450 ++++++++++++++++++++++++++++++++ libmultipath/nvme/nvme-ioctl.c | 869 +++++++++++++++++++ libmultipath/nvme/nvme-ioctl.h | 139 +++ libmultipath/nvme/nvme.h | 163 ++++ libmultipath/nvme/plugin.h | 36 + 7 files changed, 2843 insertions(+) create mode 100644 libmultipath/nvme/argconfig.h create mode 100644 libmultipath/nvme/json.h create mode 100644 libmultipath/nvme/linux/nvme.h create mode 100644 libmultipath/nvme/nvme-ioctl.c create mode 100644 libmultipath/nvme/nvme-ioctl.h create mode 100644 libmultipath/nvme/nvme.h create mode 100644 libmultipath/nvme/plugin.h
libmultipath/nvme/argconfig.h new file +99 -0
@@ -0,0 +1,99 @@ +//////////////////////////////////////////////////////////////////////// +// +// Copyright 2014 PMC-Sierra, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +// +// Author: Logan Gunthorpe <[email protected]> +// Logan Gunthorpe +// +// Date: Oct 23 2014 +// +// Description: +// Header file for argconfig.c +// +//////////////////////////////////////////////////////////////////////// + +#ifndef argconfig_H +#define argconfig_H + +#include <string.h> +#include <getopt.h> +#include <stdarg.h> + +enum argconfig_types { +CFG_NONE , +CFG_STRING , +CFG_INT , +CFG_SIZE , +CFG_LONG , +CFG_LONG_SUFFIX , +CFG_DOUBLE , +CFG_BOOL , +CFG_BYTE , +CFG_SHORT , +CFG_POSITIVE , +CFG_INCREMENT , +CFG_SUBOPTS , +CFG_FILE_A , +CFG_FILE_W , +CFG_FILE_R , +CFG_FILE_AP , +CFG_FILE_WP , +CFG_FILE_RP , +}; + +struct argconfig_commandline_options { +const char *option; +const char short_option; +const char *meta; +enum argconfig_types config_type; +void *default_value; +int argument_type; +const char *help; +}; + +#define CFG_MAX_SUBOPTS 500 +#define MAX_HELP_FUNC 20 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void argconfig_help_func (); +void argconfig_append_usage (const char *str); +void argconfig_print_help (const char *program_desc, +const struct argconfig_commandline_options *options); +int argconfig_parse (int argc,char *argv[],const char *program_desc, +const struct argconfig_commandline_options *options, +void *config_out,size_t config_size); +int argconfig_parse_subopt_string (char *string,char **options, +size_t max_options); +unsigned argconfig_parse_comma_sep_array (char *string,int *ret, +unsigned max_length); +unsigned argconfig_parse_comma_sep_array_long (char *string, +unsigned long long *ret, +unsigned max_length); +void argconfig_register_help_func (argconfig_help_func * f); + +void print_word_wrapped (const char *s,int indent,int start); +#ifdef __cplusplus +} +#endif +#endif
libmultipath/nvme/json.h new file +87 -0
87 lines not on this page · raw message
libmultipath/nvme/linux/nvme.h new file +1450 -0
1,450 lines not on this page · raw message
libmultipath/nvme/nvme-ioctl.c new file +869 -0
869 lines not on this page · raw message
libmultipath/nvme/nvme-ioctl.h new file +139 -0
139 lines not on this page · raw message
libmultipath/nvme/nvme.h new file +163 -0
163 lines not on this page · raw message
libmultipath/nvme/plugin.h new file +36 -0
@@ -0,0 +1,36 @@ +#ifndef PLUGIN_H +#define PLUGIN_H + +#include <stdbool.h> + +struct program { +const char *name; +const char *version; +const char *usage; +const char *desc; +const char *more; +struct command **commands; +struct plugin *extensions; +}; + +struct plugin { +const char *name; +const char *desc; +struct command **commands; +struct program *parent; +struct plugin *next; +struct plugin *tail; +}; + +struct command { +char *name; +char *help; +int (*fn)(int argc,char **argv,struct command *command,struct plugin *plugin); +char *alias; +}; + +void usage (struct plugin *plugin); +void general_help (struct plugin *plugin); +int handle_plugin (int argc,char **argv,struct plugin *plugin); + +#endif
Signature · 6 lines
2.19.2 -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel
PATCH v2 13/20 libmultipath: add wrapper library for nvme ioctls
In reply to Martin WilckCreate a small wrapper around the code from nvme-cli provide the necessary functionality (and only that) for libmultipath.
libmultipath code should include "nvme-lib.h" and possibly "nvme.h" (the latter with -Invme"). The nvme-cli code is rewritten, changing all functions to static linkage, and included by nvme-lib.c, so that only those functions that are actually exported via nvme-lib.c become part of libmultipath.
This allows us to include the nvme-cli code without modifications, and at the same time not carry around binary code for stuff we don't need.
When additional functionality from nvme-cli is needed, more wrappers need to be added to nvme-lib.[hc].
--- libmultipath/Makefile | 17 ++++++++++++++++- libmultipath/nvme-lib.c | 36 ++++++++++++++++++++++++++++++++++++ libmultipath/nvme-lib.h | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 libmultipath/nvme-lib.c create mode 100644 libmultipath/nvme-lib.h
libmultipath/Makefile +16 -1
@@ -45,8 +45,23 @@ OBJS = memory.o parser.o vector.o devmapper.o callout.o \ lock.o file.o wwids.o prioritizers/alua_rtpg.o prkey.o \ io_err_stat.o dm-generic.o generic.o foreign.o +ifneq ($(call check_file,/usr/include/linux/nvme_ioctl.h),0) + OBJS += nvme-lib.o +endif + all: $(LIBS) +nvme-lib.o: nvme-lib.c nvme-ioctl.c nvme-ioctl.h + $(CC) $(CFLAGS) -Wno-unused-function -I. -Invme -c -o $@ $< + +make_static = $(shell sed '/^static/!s/^\([a-z]\{1,\} \)/static \1/' <$1 >$2) + +nvme-ioctl.c: nvme/nvme-ioctl.c + $(call make_static,$<,$@) + +nvme-ioctl.h: nvme/nvme-ioctl.h + $(call make_static,$<,$@) + $(LIBS): $(OBJS) $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ -o $@ $(OBJS) $(LIBDEPS) $(LN) $@ $(DEVLIB)
@@ -62,7 +77,7 @@ uninstall: $(RM) $(DESTDIR)$(syslibdir)/$(DEVLIB) clean: dep_clean - $(RM) core *.a *.o *.so *.so.* *.gz + $(RM) core *.a *.o *.so *.so.* *.gz nvme-ioctl.c nvme-ioctl.h include $(wildcard $(OBJS:.o=.d))
libmultipath/nvme-lib.c new file +36 -0
@@ -0,0 +1,36 @@ +#include <sys/types.h> +/* avoid inclusion of standard API */ +#define _NVME_LIB_C 1 +#include "nvme-lib.h" +#include "nvme-ioctl.c" +#include "debug.h" + +int log_nvme_errcode (int err,const char *dev,const char *msg) +{ +if (err >0 ) +condlog (3 ,"%s: %s: NVMe status %d" , dev, msg, err); +else if (err <0 ) +condlog (3 ,"%s: %s: %s" , dev, msg,strerror (errno)); +return err; +} + +int libmp_nvme_get_nsid (int fd) +{ +return nvme_get_nsid (fd); +} + +int libmp_nvme_identify_ctrl (int fd,struct nvme_id_ctrl *ctrl) +{ +return nvme_identify_ctrl (fd, ctrl); +} + +int libmp_nvme_identify_ns (int fd,__u32 nsid,bool present, +struct nvme_id_ns *ns) +{ +return nvme_identify_ns (fd, nsid, present, ns); +} + +int libmp_nvme_ana_log (int fd,void *ana_log,size_t ana_log_len,int rgo) +{ +return nvme_ana_log (fd, ana_log, ana_log_len, rgo); +}
libmultipath/nvme-lib.h new file +33 -0
@@ -0,0 +1,33 @@ +#ifndef NVME_LIB_H +#define NVME_LIB_H + +#include "nvme.h" + +int log_nvme_errcode (int err,const char *dev,const char *msg); +int libmp_nvme_get_nsid (int fd); +int libmp_nvme_identify_ctrl (int fd,struct nvme_id_ctrl *ctrl); +int libmp_nvme_identify_ns (int fd,__u32 nsid,bool present, +struct nvme_id_ns *ns); +int libmp_nvme_ana_log (int fd,void *ana_log,size_t ana_log_len,int rgo); + +#ifndef _NVME_LIB_C +/* +* In all files except nvme-lib.c, the nvme functions can be called +* by their usual name. +*/ +#define nvme_get_nsid libmp_nvme_get_nsid +#define nvme_identify_ctrl libmp_nvme_identify_ctrl +#define nvme_identify_ns libmp_nvme_identify_ns +#define nvme_ana_log libmp_nvme_ana_log +/* +* Undefine these to avoid clashes with libmultipath's byteorder.h +*/ +#undef cpu_to_le16 +#undef cpu_to_le32 +#undef cpu_to_le64 +#undef le16_to_cpu +#undef le32_to_cpu +#undef le64_to_cpu +#endif + +#endif /* NVME_LIB_H */
Signature · 1 line
2.19.2
PATCH v2 14/20 multipath-tools: add ANA support for NVMe device
In reply to Martin WilckFrom: lijie <[email protected]>
Add support for Asynchronous Namespace Access as specified in NVMe 1.3 TP 4004. The states are updated through reading the ANA log page.
By default, the native nvme multipath takes over the nvme device. We can pass a false to the parameter 'multipath' of the nvme-core.ko module,when we want to use multipath-tools.
--- libmultipath/prio.h | 1 + libmultipath/prioritizers/Makefile | 1 + libmultipath/prioritizers/ana.c | 292 +++++++++++++++++++++++++++++ libmultipath/prioritizers/ana.h | 221 ++++++++++++++++++++++ multipath/multipath.conf.5 | 8 + 5 files changed, 523 insertions(+) create mode 100644 libmultipath/prioritizers/ana.c create mode 100644 libmultipath/prioritizers/ana.h
libmultipath/prio.h +1 -0
@@ -30,6 +30,7 @@ struct path;#define PRIO_WEIGHTED_PATH "weightedpath"#define PRIO_SYSFS "sysfs"#define PRIO_PATH_LATENCY "path_latency" +#define PRIO_ANA "ana"/* * Value used to mark the fact prio was not defined
libmultipath/prioritizers/Makefile +1 -0
@@ -19,6 +19,7 @@ LIBS = \ libpriordac.so \ libprioweightedpath.so \ libpriopath_latency.so \ + libprioana.so \ libpriosysfs.so all: $(LIBS)
libmultipath/prioritizers/ana.c new file +292 -0
292 lines not on this page · raw message
libmultipath/prioritizers/ana.h new file +221 -0
221 lines not on this page · raw message
multipath/multipath.conf.5 +8 -0
@@ -334,6 +334,10 @@ priority provided as argument. Requires prio_args keyword. Generate the path priority based on a latency algorithm. Requires prio_args keyword. .TP +.I ana +(Hardware-dependent) +Generate the path priority based on the NVMe ANA settings. +.TP .I datacore (Hardware-dependent) Generate the path priority for some DataCore storage arrays. Requires prio_args
@@ -1437,6 +1441,10 @@ Active/Standby mode exclusively. .I 1 alua (Hardware-dependent) Hardware handler for SCSI-3 ALUA compatible arrays. +.TP +.I 1 ana +(Hardware-dependent) +Hardware handler for NVMe ANA compatible arrays. .PP The default is: \fB<unset>\fR .PP
Signature · 1 line
2.19.2
PATCH v2 15/20 libmultipath: ANA prioritzer: use nvme wrapper library
In reply to Martin WilckUse the previously introduced NVME wrapper library for the passthrough commands from the ANA prioritizer. Discard code duplicated from nvme-cli from the ana code itself.
Furthermore, make additional cleanups in the ANA prioritizer:
- don't use the same enum for priorities and error codes
- use char* arrays for error messages and state names
- return -1 prio to libmultipath for all error cases
- check for overflow in check_ana_state()
- get_ana_info(): improve readability with is_anagrpid_const
- priorities: PERSISTENT_LOSS state is worse than INACCESSIBLE and CHANGE
--- libmultipath/prioritizers/Makefile | 6 +- libmultipath/prioritizers/ana.c | 334 ++++++++++++----------------- libmultipath/prioritizers/ana.h | 221 ------------------- 3 files changed, 143 insertions(+), 418 deletions(-) delete mode 100644 libmultipath/prioritizers/ana.h
libmultipath/prioritizers/Makefile +5 -1
@@ -19,9 +19,13 @@ LIBS = \ libpriordac.so \ libprioweightedpath.so \ libpriopath_latency.so \ - libprioana.so \ libpriosysfs.so +ifneq ($(call check_file,/usr/include/linux/nvme_ioctl.h),0) + LIBS += libprioana.so + CFLAGS += -I../nvme +endif + all: $(LIBS) libprioalua.so: alua.o alua_rtpg.o
libmultipath/prioritizers/ana.c +138 -196
409 lines not on this page · raw message
libmultipath/prioritizers/ana.h deleted +0 -221
221 lines not on this page · raw message
Signature · 6 lines
2.19.2 -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel
PATCH v2 16/20 libmultipath: detect_prio: try ANA for NVMe
In reply to Martin WilckCheck NVMe devices support ANA, and if yes, use ANA for priority checks. The patch moves the ANA detection functionality from the ANA prioritizer into generic code, and uses it.
--- libmultipath/Makefile | 1 + libmultipath/nvme-lib.c | 13 +++++++++++++ libmultipath/nvme-lib.h | 6 ++++++ libmultipath/prioritizers/ana.c | 6 ++---- libmultipath/propsel.c | 25 +++++++++++++++++++------ 5 files changed, 41 insertions(+), 10 deletions(-)
libmultipath/Makefile +1 -0
@@ -47,6 +47,7 @@ OBJS = memory.o parser.o vector.o devmapper.o callout.o \ ifneq ($(call check_file,/usr/include/linux/nvme_ioctl.h),0) OBJS += nvme-lib.o + CFLAGS += -Invme endif all: $(LIBS)
libmultipath/nvme-lib.c +13 -0
@@ -34,3 +34,16 @@ int libmp_nvme_ana_log(int fd, void *ana_log, size_t ana_log_len, int rgo) {return nvme_ana_log (fd, ana_log, ana_log_len, rgo); } + +int nvme_id_ctrl_ana (int fd,struct nvme_id_ctrl *ctrl) +{ +int rc; +struct nvme_id_ctrl c; + + rc =nvme_identify_ctrl (fd, &c); +if (rc <0 ) +return rc; +if (ctrl) + *ctrl = c; +return c.cmic & (1 <<3 ) ?1 :0 ; +}
libmultipath/nvme-lib.h +6 -0
@@ -9,6 +9,12 @@ int libmp_nvme_identify_ctrl(int fd, struct nvme_id_ctrl *ctrl);int libmp_nvme_identify_ns (int fd,__u32 nsid,bool present,struct nvme_id_ns *ns);int libmp_nvme_ana_log (int fd,void *ana_log,size_t ana_log_len,int rgo); +/* +* Identify controller, and return true if ANA is supported +* ctrl will be filled in if controller is identified, even w/o ANA +* ctrl may be NULL +*/ +int nvme_id_ctrl_ana (int fd,struct nvme_id_ctrl *ctrl);#ifndef _NVME_LIB_C/*
libmultipath/prioritizers/ana.c +2 -4
@@ -116,13 +116,11 @@ int get_ana_info(struct path * pp, unsigned int timeout)size_t ana_log_len;bool is_anagrpid_const; - rc =nvme_identify_ctrl (pp->fd, &ctrl); + rc =nvme_id_ctrl_ana (pp->fd, &ctrl);if (rc <0 ) {log_nvme_errcode (rc, pp->dev,"nvme_identify_ctrl" );return -ANA_ERR_GETCTRL_FAILED ; - } - -if (!(ctrl.cmic & (1 <<3 ))) + }else if (rc ==0 )return -ANA_ERR_NOT_SUPPORTED ; nsid =nvme_get_nsid (pp->fd);
libmultipath/propsel.c +19 -6
@@ -5,6 +5,7 @@*/ #include <stdio.h> +#include "nvme-lib.h" #include "checkers.h" #include "memory.h" #include "vector.h"
@@ -550,13 +551,25 @@ detect_prio(struct config *conf, struct path * pp) {struct prio *p = &pp->prio;char buff[512 ]; -char *default_prio =PRIO_ALUA ; - -if (pp->tpgs <=0 ) -return ; -if (pp->tpgs ==2 || !check_rdac (pp)) { -if (sysfs_get_asymmetric_access_state (pp, buff,512 ) >=0 ) +char *default_prio; + +switch (pp->bus) { +case SYSFS_BUS_NVME : +if (nvme_id_ctrl_ana (pp->fd,NULL ) ==0 ) +return ; + default_prio =PRIO_ANA ; +break ; +case SYSFS_BUS_SCSI : +if (pp->tpgs <=0 ) +return ; +if ((pp->tpgs ==2 || !check_rdac (pp)) && +sysfs_get_asymmetric_access_state (pp, buff,512 ) >=0 ) default_prio =PRIO_SYSFS ; +else + default_prio =PRIO_ALUA ; +break ; +default : +return ; }prio_get (conf->multipath_dir, p, default_prio,DEFAULT_PRIO_ARGS ); }
Signature · 1 line
2.19.2
PATCH v2 17/20 libmultipath/foreign/nvme: use failover topology
In reply to Martin WilckThe native multipath driver does not use a multibus policy as the current topology output of the NVMe foreign code indicates. Rather, it uses failover policy, queueing all IO to the current path until a failure occurs.
Change the data structures of the nvme foreign library accordingly.
--- libmultipath/foreign/nvme.c | 92 +++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 44 deletions(-)
libmultipath/foreign/nvme.c +48 -44
@@ -40,17 +40,22 @@ static const char N_A[] = "n/a";const char *THIS ;struct nvme_map ; +struct nvme_pathgroup { +struct gen_pathgroup gen; +struct _vector pathvec; +}; +struct nvme_path {struct gen_path gen;struct udev_device *udev;struct udev_device *ctl;struct nvme_map *map;bool seen; -}; - -struct nvme_pathgroup { -struct gen_pathgroup gen; -vector pathvec; +/* +* The kernel works in failover mode. +* Each path has a separate path group. +*/ +struct nvme_pathgroup pg; };struct nvme_map {
@@ -58,11 +63,7 @@ struct nvme_map {struct udev_device *udev;struct udev_device *subsys;dev_t devt; -/* Just one static pathgroup for NVMe for now */ -struct nvme_pathgroup pg; -struct gen_pathgroup *gpg;struct _vector pgvec; -vector pathvec;int nr_live; };
@@ -76,29 +77,33 @@ struct nvme_map {#define const_gen_path_to_nvme (g) ((const struct nvme_path*)(g))#define gen_path_to_nvme (g) ((struct nvme_path*)(g))#define nvme_path_to_gen (n) &((n)->gen) +#define nvme_pg_to_path (x) (VECTOR_SLOT(&((x)->pathvec), 0)) +#define nvme_path_to_pg (x) &((x)->pg)static void cleanup_nvme_path (struct nvme_path *path) {condlog (5 ,"%s: %p %p" , __func__, path, path->udev);if (path->udev)udev_device_unref (path->udev); +vector_reset (&path->pg.pathvec); +/* ctl is implicitly referenced by udev, no need to unref */ free (path); }static void cleanup_nvme_map (struct nvme_map *map) { -if (map->pathvec) { -struct nvme_path *path; -int i; +struct nvme_pathgroup *pg; +struct nvme_path *path; +int i; - vector_foreach_slot_backwards(map->pathvec, path, i) { -condlog (5 ,"%s: %d %p" , __func__, i, path); -cleanup_nvme_path (path); -vector_del_slot (map->pathvec, i); - } + vector_foreach_slot_backwards(&map->pgvec, pg, i) { + path =nvme_pg_to_path (pg); +condlog (5 ,"%s: %d %p" , __func__, i, path); +cleanup_nvme_path (path); +vector_del_slot (&map->pgvec, i); } -vector_free (map->pathvec); +vector_reset (&map->pgvec);if (map->udev)udev_device_unref (map->udev);/* subsys is implicitly referenced by udev, no need to unref */
@@ -190,7 +195,7 @@ nvme_pg_get_paths(const struct gen_pathgroup *gpg) {const struct nvme_pathgroup *gp =const_gen_pg_to_nvme (gpg);/* This is all used under the lock, no need to copy */ -return gp->pathvec; +return &gp->pathvec; } static void
@@ -432,7 +437,7 @@ static struct nvme_map *_find_nvme_map_by_devt(const struct context *ctx,static struct nvme_path *_find_path_by_syspath (struct nvme_map *map,const char *syspath) { -struct nvme_path *path; +struct nvme_pathgroup *pg;char real[PATH_MAX ];const char *ppath;int i;
@@ -443,7 +448,9 @@ _find_path_by_syspath(struct nvme_map *map, const char *syspath) ppath = syspath; } - vector_foreach_slot(map->pathvec, path, i) { + vector_foreach_slot(&map->pgvec, pg, i) { +struct nvme_path *path =nvme_pg_to_path (pg); +if (!strcmp (ppath,udev_device_get_syspath (path->udev)))return path;
@@ -537,14 +544,17 @@ static void _find_controllers(struct context *ctx, struct nvme_map *map)struct dirent **di =NULL ;struct scandir_result sr;struct udev_device *subsys; +struct nvme_pathgroup *pg;struct nvme_path *path;int r, i, n;if (map ==NULL || map->udev ==NULL )return ; -vector_foreach_slot (map->pathvec, path, i) + vector_foreach_slot(&map->pgvec, pg, i) { + path =nvme_pg_to_path (pg); path->seen = false; + } subsys = udev_device_get_parent_with_subsystem_devtype(map->udev, "nvme-subsystem",
@@ -606,7 +616,8 @@ static void _find_controllers(struct context *ctx, struct nvme_map *map)if (udev ==NULL )continue ; - path =_find_path_by_syspath (map,udev_device_get_syspath (udev)); + path =_find_path_by_syspath (map, +udev_device_get_syspath (udev));if (path !=NULL ) { path->seen = true; condlog(4, "%s: %s already known",
@@ -630,24 +641,30 @@ static void _find_controllers(struct context *ctx, struct nvme_map *map)cleanup_nvme_path (path);continue ; } - -if (vector_alloc_slot (map->pathvec) ==NULL ) { + path->pg.gen.ops = &nvme_pg_ops; +if (vector_alloc_slot (&path->pg.pathvec) ==NULL ) {cleanup_nvme_path (path);continue ; } +vector_set_slot (&path->pg.pathvec, path); +if (vector_alloc_slot (&map->pgvec) ==NULL ) { +cleanup_nvme_path (path); +continue ; + } +vector_set_slot (&map->pgvec, &path->pg);condlog (3 ,"%s: %s: new path %s added to %s" , __func__,THIS ,udev_device_get_sysname (udev),udev_device_get_sysname (map->udev)); -vector_set_slot (map->pathvec, path); }pthread_cleanup_pop (1 ); map->nr_live =0 ; - vector_foreach_slot_backwards(map->pathvec, path, i) { + vector_foreach_slot_backwards(&map->pgvec, pg, i) { + path =nvme_pg_to_path (pg);if (!path->seen) {condlog (1 ,"path %d not found in %s any more" , i,udev_device_get_sysname (map->udev)); -vector_del_slot (map->pathvec, i); +vector_del_slot (&map->pgvec, i);cleanup_nvme_path (path); }else {static const char live_state[] ="live" ;
@@ -661,7 +678,7 @@ static void _find_controllers(struct context *ctx, struct nvme_map *map) }condlog (3 ,"%s: %s: map %s has %d/%d live paths" , __func__,THIS ,udev_device_get_sysname (map->udev), map->nr_live, -VECTOR_SIZE (map->pathvec)); +VECTOR_SIZE (&map->pgvec)); } static int _add_map(struct context *ctx, struct udev_device *ud,
@@ -686,19 +703,6 @@ static int _add_map(struct context *ctx, struct udev_device *ud, map->subsys = subsys; map->gen.ops = &nvme_map_ops; - map->pathvec =vector_alloc (); -if (map->pathvec ==NULL ) { -cleanup_nvme_map (map); -return FOREIGN_ERR ; - } - - map->pg.gen.ops = &nvme_pg_ops; - map->pg.pathvec = map->pathvec; - map->gpg =nvme_pg_to_gen (&map->pg); - - map->pgvec.allocated =1 ; - map->pgvec.slot = (void **)&map->gpg; -if (vector_alloc_slot (ctx->mpvec) ==NULL ) {cleanup_nvme_map (map);return FOREIGN_ERR ;
@@ -842,8 +846,8 @@ const struct _vector * get_paths(const struct context *ctx)condlog (5 ,"%s called for \"%s\"" , __func__,THIS ); vector_foreach_slot(ctx->mpvec, gm, i) {const struct nvme_map *nm =const_gen_mp_to_nvme (gm); - paths =vector_convert (paths, nm->pathvec, - struct gen_path, identity); + paths =vector_convert (paths, &nm->pgvec, + struct nvme_pathgroup, nvme_pg_to_path); }return paths; }
Signature · 1 line
2.19.2
PATCH v2 18/20 libmultipath/foreign/nvme: show ANA state
In reply to Martin WilckObtain the ana_state attribute from the kernel and use it to display information about path state and "priority" of native NVMe multipath.
--- libmultipath/foreign/nvme.c | 43 +++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-)
libmultipath/foreign/nvme.c +36 -7
@@ -204,12 +204,6 @@ nvme_pg_rel_paths(const struct gen_pathgroup *gpg, const struct _vector *v)/* empty */ } -static int snprint_nvme_pg (const struct gen_pathgroup *gmp, -char *buff,int len,char wildcard) -{ -return snprintf (buff, len,N_A ); -} -static int snprint_hcil (const struct nvme_path *np,char *buf,int len) {unsigned int nvmeid, ctlid, nsid;
@@ -249,6 +243,23 @@ static int snprint_nvme_path(const struct gen_path *gp,case 'o' :sysfs_attr_get_value (np->ctl,"state" , fld,sizeof (fld));return snprintf (buff, len,"%s" , fld); +case 'T' : +if (sysfs_attr_get_value (np->udev,"ana_state" , fld, +sizeof (fld)) >0 ) +return snprintf (buff, len,"%s" , fld); +break ; +case 'p' : +if (sysfs_attr_get_value (np->udev,"ana_state" , fld, +sizeof (fld)) >0 ) { +rstrip (fld); +if (!strcmp (fld,"optimized" )) +return snprintf (buff, len,"%d" ,50 ); +else if (!strcmp (fld,"non-optimized" )) +return snprintf (buff, len,"%d" ,10 ); +else +return snprintf (buff, len,"%d" ,0 ); + } +break ;case 's' : snprintf(fld, sizeof(fld), "%s", udev_device_get_sysattr_value(np->ctl,
@@ -286,12 +297,30 @@ static int snprint_nvme_path(const struct gen_path *gp, udev_device_get_sysname(pci));/* fall through */ default : -return snprintf (buff, len,"%s" ,N_A );break ; } +return snprintf (buff, len,"%s" ,N_A );return 0 ; } +static int snprint_nvme_pg (const struct gen_pathgroup *gmp, +char *buff,int len,char wildcard) +{ +const struct nvme_pathgroup *pg =const_gen_pg_to_nvme (gmp); +const struct nvme_path *path =nvme_pg_to_path (pg); + +switch (wildcard) { +case 't' : +return snprint_nvme_path (nvme_path_to_gen (path), + buff, len,'T' ); +case 'p' : +return snprint_nvme_path (nvme_path_to_gen (path), + buff, len,'p' ); +default : +return snprintf (buff, len,N_A ); + } +} +static int nvme_style (const struct gen_multipath * gm,char *buf,int len,int verbosity) {
Signature · 1 line
2.19.2
PATCH v2 19/20 libmultipath/foreign/nvme: indicate ANA support
In reply to Martin WilckIndicate ANA support in the "hwhandler" output field.
--- libmultipath/foreign/Makefile | 2 +- libmultipath/foreign/nvme.c | 47 +++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-)
libmultipath/foreign/Makefile +1 -1
@@ -3,7 +3,7 @@ # include ../../Makefile.inc -CFLAGS += $(LIB_CFLAGS) -I.. +CFLAGS += $(LIB_CFLAGS) -I.. -I../nvme # If you add or remove a checker also update multipath/multipath.conf.5 LIBS= \
libmultipath/foreign/nvme.c +45 -2
86 lines not on this page · raw message
Signature · 1 line
2.19.2
PATCH v2 20/20 libmultipath/foreign/nvme: fix ouput for "%n" wildcard
In reply to Martin WilckThe output for "%n" ("name") is broken: it omits the NSID, and thus it isn't unique per namespace; and it duplicates the NQN. Change the format to "$NQN:nsid.$NSID".
Real-world example:
nqn.1992-08.com.netapp:sn.7c6b997ca1f611e8abb200a09890f5bf:subsystem.netapp-nvme-svm-subsystem:nsid.1
--- libmultipath/foreign/nvme.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
libmultipath/foreign/nvme.c +4 -3
@@ -148,10 +148,11 @@ static int snprint_nvme_map(const struct gen_multipath *gmp,return snprintf (buff, len,"%s" ,udev_device_get_sysname (nvm->udev));case 'n' : -return snprintf (buff, len,"%s:NQN:%s" , -udev_device_get_sysname (nvm->subsys), +return snprintf (buff, len,"%s:nsid.%s" ,udev_device_get_sysattr_value (nvm->subsys, -"subsysnqn" )); +"subsysnqn" ), +udev_device_get_sysattr_value (nvm->udev, +"nsid" ));case 'w' : return snprintf(buff, len, "%s", udev_device_get_sysattr_value(nvm->udev,
Signature · 1 line
2.19.2