[dm-devel] [PATCH] multipath-tools: improve processing efficiency for addition and deletion of multipath devices
From: "tang.junhui" This patch used to improve processing efficiency for addition and deletion of multipath devices. This patch is tested pass by ZTE multipath automatic testing system. The modification reduces the system consumption(such as CPU) and shortens the processing time obviously in scene of massive multipath devices addition or deletion. The main processing flow of code is: 1) add uid_attrs configuration in the defaults section: It is configured udev attribute which providing a unique path identifier for corresponding type of path devices. If this field is configured and matched with type of device, it would override any other methods providing for device unique identifier in config file, and it would activate merging uevents according to the identifier to promote effiecncy in processing uevents. Tt has no default value, so defaultly only uevents filtering works, and uevents merging does not works, if users want to identify path by udev attribute and to activate merging uevents for SCSI and DAS device, they can set it's value as: "sd:ID_SERIAL dasd:ID_UID" 2) uevents accumulation in uevents burst scene: wait one seconds for more uevents in uevent_listen() in uevents burst situations 3) uevents preparing, filtering and merging: discard unuse uevents and fetch path idendifier from uevents; filter uevents; merge uevents. 4) uevents proccessing: proccess the merged uevents in uev->merge_node list without calling domap(); proccess the last uevents uev with calling domap(). Signed-off-by: tang.junhui --- libmultipath/config.c | 3 + libmultipath/config.h | 1 + libmultipath/dict.c| 3 + libmultipath/discovery.c | 5 +- libmultipath/discovery.h | 2 +- libmultipath/list.h| 41 ++ libmultipath/propsel.c | 7 + libmultipath/uevent.c | 320 +++-- libmultipath/uevent.h | 2 + libmultipath/util.c| 42 ++ libmultipath/util.h| 1 + multipath/multipath.conf.5 | 18 +++ multipathd/cli_handlers.c | 4 +- multipathd/main.c | 93 + multipathd/main.h | 4 +- 15 files changed, 471 insertions(+), 75 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index 9d3f3e1..bb6619b 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -493,6 +493,9 @@ free_config (struct config * conf) if (conf->uid_attribute) FREE(conf->uid_attribute); + if (conf->uid_attrs) + FREE(conf->uid_attrs); + if (conf->getuid) FREE(conf->getuid); diff --git a/libmultipath/config.h b/libmultipath/config.h index 9a90745..4f1d596 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -164,6 +164,7 @@ struct config { char * multipath_dir; char * selector; + char * uid_attrs; char * uid_attribute; char * getuid; char * features; diff --git a/libmultipath/dict.c b/libmultipath/dict.c index bababdb..82066f6 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -249,6 +249,8 @@ declare_ovr_snprint(selector, print_str) declare_mp_handler(selector, set_str) declare_mp_snprint(selector, print_str) +declare_def_handler(uid_attrs, set_str) +declare_def_snprint(uid_attrs, print_str) declare_def_handler(uid_attribute, set_str) declare_def_snprint_defstr(uid_attribute, print_str, DEFAULT_UID_ATTRIBUTE) declare_ovr_handler(uid_attribute, set_str) @@ -1396,6 +1398,7 @@ init_keywords(vector keywords) install_keyword("multipath_dir", &def_multipath_dir_handler, &snprint_def_multipath_dir); install_keyword("path_selector", &def_selector_handler, &snprint_def_selector); install_keyword("path_grouping_policy", &def_pgpolicy_handler, &snprint_def_pgpolicy); + install_keyword("uid_attrs", &def_uid_attrs_handler, &snprint_def_uid_attrs); install_keyword("uid_attribute", &def_uid_attribute_handler, &snprint_def_uid_attribute); install_keyword("getuid_callout", &def_getuid_handler, &snprint_def_getuid); install_keyword("prio", &def_prio_name_handler, &snprint_def_prio_name); diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 4e99845..7398040 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -34,7 +34,7 @@ int alloc_path_with_pathinfo (struct config *conf, struct udev_device *udevice, - int flag, struct path **pp_ptr) + char *wwid, int flag, struct path **pp_ptr) { int err = PATHINFO_FAILED; struct path * pp; @@ -52,6 +52,9 @@ alloc_path_with_pathinfo (struct config *conf, struct udev_device *udevice, if (!pp) return PATHINFO_FAILED; + if(wwid) + strncpy(pp->wwid, wwid, sizeof(pp->wwid)); + if (safe_sprintf(pp->dev, "%s", devname)) { condlog(0, "
Re: [dm-devel] [PATCH] Avoid that reloading a map sporadically triggers I/O errors
Oh yes, sorry, this patch slipped past my cursor. This patch highlights the lack of consistency in function prototypes in devmapper.c : some using "no_flush", others using "flush". Anyway, your patch is now applied. Thanks. On Mon, Feb 27, 2017 at 4:18 PM, Bart Van Assche wrote: > Hello Christophe, > > The patch below was posted more than three months ago but has not yet > received any feedback from you. Had I sent this patch to the right person? > Do you perhaps want me to repost it? > > Bart. > > > On 01/04/17 11:56, Benjamin Marzinski wrote: > >> On Wed, Dec 07, 2016 at 03:37:44PM -0800, Bart Van Assche wrote: >> >> ACK >> >> -Ben >> >> Christophe and Hannes, do you want to comment on this patch? >>> >>> Thanks, >>> >>> Bart. >>> >>> On 11/18/2016 01:33 PM, Bart Van Assche wrote: >>> Avoid that reloading a map while there are no paths triggers a flush and hence unwanted I/O errors if 'queue_if_no_path' is enabled. Fixes: commit d569988e7528 ("libmultipath: Fixup 'DM_DEVICE_RELOAD' handling") Signed-off-by: Bart Van Assche Cc: Hannes Reinecke --- libmultipath/devmapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index f92ebce..31f1962 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -390,7 +390,7 @@ int dm_addmap_reload(struct multipath *mpp, char *params, int flush) params, ADDMAP_RO, SKIP_KPARTX_OFF); } if (r) - r = dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, flush, + r = dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, !flush, 1, udev_flags, 0); return r; } >>> > -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel
Re: [dm-devel] [PATCH v4 0/6] misc patches
Applied. Thanks. On Mon, Feb 27, 2017 at 7:26 PM, Benjamin Marzinski wrote: > Here's a couple of minor features bugfixes and cleanups. The biggest > change is that the detect_checker option now sets the checker for > devices with detected ALUA to TUR. Also, udev wasn't correctly > disabling rules for multipath devices that lost their last usable > path through a table reload. This was causing lvmetad some problems > on failing multipath devices. > > Differences from v3: > Rebased patches > > Benjamin Marzinski (6): > libmultipath: add detect_checker option > libmultipath: cleanup orphan device states > multipathd: don't update priority of failed paths > multipathd: add messages on delayed path addition > multipathd: allow resetting stats > fix udev rules for failed multipath devices > > libmultipath/config.c | 3 ++ > libmultipath/config.h | 2 ++ > libmultipath/defaults.h | 1 + > libmultipath/devmapper.c | 3 +- > libmultipath/devmapper.h | 6 > libmultipath/dict.c | 10 ++ > libmultipath/discovery.c | 28 +-- > libmultipath/hwtable.c| 1 + > libmultipath/print.c | 4 +-- > libmultipath/prioritizers/alua_spc3.h | 1 + > libmultipath/propsel.c| 31 ++-- > libmultipath/propsel.h| 1 + > libmultipath/structs.c| 2 ++ > libmultipath/structs.h| 7 > multipath/11-dm-mpath.rules | 67 -- > - > multipath/multipath.conf.5| 18 ++ > multipathd/cli.c | 2 ++ > multipathd/cli_handlers.c | 44 +++ > multipathd/cli_handlers.h | 2 ++ > multipathd/main.c | 8 - > 20 files changed, 205 insertions(+), 36 deletions(-) > > -- > 1.8.3.1 > > -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel
[dm-devel] [PATCH] dm raid: fix data corruption on reshape request
From: Heinz Mauelshagen The lvm2 sequence to process constructor flags triggering a rebuild or a reshape is defined as: - load with table flags (e.g. rebuild/delta_disks/data_offset) - clear out the flags in lvm2 - store the lvm2 metadata reloading the adjusted mapping in order to prevent requesting a rebuild or a reshape over and over again on activation Currently, loading an inactive table with those flags dm-raid directly starts the rebuild/reshape thus updating the raid metadata on resume about the progress. The aforementioned second reload to reset the flags accesses the versatile progress state kept in raid superblocks in the constructor. Because the active mapping is still processing the reshape, that position will be stale by the time the device is resumed. In case of reshaping, this causes data corruption by processing already reshaped stripes again. In case of rebuilds it does _not_ cause data corruption but involves superfluous rebuilds. Fix by keeping the raid set frozen during the first table load and allowing it during the second. This patch is based on https://patchwork.kernel.org/patch/9485615 "dm raid: fix transient device failure processing" https://patchwork.kernel.org/patch/9454975 "dm raid: journal device support" Signed-off-by: Heinz Mauelshagen --- drivers/md/dm-raid.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index b8f978e..f750493 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c @@ -92,6 +92,8 @@ struct raid_dev { #define CTR_FLAG_DATA_OFFSET (1 << __CTR_FLAG_DATA_OFFSET) #define CTR_FLAG_RAID10_USE_NEAR_SETS (1 << __CTR_FLAG_RAID10_USE_NEAR_SETS) +#define RESUME_STAY_FROZEN_FLAGS (CTR_FLAG_DELTA_DISKS | \ +CTR_FLAG_DATA_OFFSET) /* * Definitions of various constructor flags to * be used in checks of valid / invalid flags @@ -3643,7 +3645,15 @@ static void raid_resume(struct dm_target *ti) mddev->ro = 0; mddev->in_sync = 0; - clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); + /* +* Keep the RAID set frozen in case flags respective to +* reshape or rebuild are set until an imminent inactive +* table load/resume occurs. This ensures that the +* constructor for the inactive table retrieves an +* up-to-date reshape_position. +*/ + if (!(rs->ctr_flags & RESUME_STAY_FROZEN_FLAGS)) + clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); if (mddev->suspended) mddev_resume(mddev); @@ -3651,7 +3661,7 @@ static void raid_resume(struct dm_target *ti) static struct target_type raid_target = { .name = "raid", - .version = {1, 9, 1}, + .version = {1, 10, 2}, .module = THIS_MODULE, .ctr = raid_ctr, .dtr = raid_dtr, -- 2.9.3 -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel
[dm-devel] [PATCH v4 1/6] libmultipath: add detect_checker option
This patch adds a detect_checker option that works just like the detect_prio option. It currently only detects ALUA devices, and if it finds ALUA support, it sets the priortizier to TUR. This is useful for devices like the VNX2, where it should be using the TUR checker when in ALUA mode (or so I have been told). It is set on by default just like detect_prio and retain_attached_hw_handler. Signed-off-by: Benjamin Marzinski --- libmultipath/config.c | 3 +++ libmultipath/config.h | 2 ++ libmultipath/defaults.h | 1 + libmultipath/dict.c | 10 ++ libmultipath/discovery.c | 28 ++-- libmultipath/hwtable.c| 1 + libmultipath/prioritizers/alua_spc3.h | 1 + libmultipath/propsel.c| 31 +-- libmultipath/propsel.h| 1 + libmultipath/structs.c| 2 ++ libmultipath/structs.h| 7 +++ multipath/multipath.conf.5| 18 ++ 12 files changed, 93 insertions(+), 12 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index 5837dc6..9d3f3e1 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -343,6 +343,7 @@ merge_hwe (struct hwentry * dst, struct hwentry * src) merge_num(user_friendly_names); merge_num(retain_hwhandler); merge_num(detect_prio); + merge_num(detect_checker); merge_num(deferred_remove); merge_num(delay_watch_checks); merge_num(delay_wait_checks); @@ -423,6 +424,7 @@ store_hwe (vector hwtable, struct hwentry * dhwe) hwe->user_friendly_names = dhwe->user_friendly_names; hwe->retain_hwhandler = dhwe->retain_hwhandler; hwe->detect_prio = dhwe->detect_prio; + hwe->detect_checker = dhwe->detect_checker; if (dhwe->bl_product && !(hwe->bl_product = set_param_str(dhwe->bl_product))) goto out; @@ -610,6 +612,7 @@ load_config (char * file) conf->fast_io_fail = DEFAULT_FAST_IO_FAIL; conf->retain_hwhandler = DEFAULT_RETAIN_HWHANDLER; conf->detect_prio = DEFAULT_DETECT_PRIO; + conf->detect_checker = DEFAULT_DETECT_CHECKER; conf->force_sync = DEFAULT_FORCE_SYNC; conf->partition_delim = DEFAULT_PARTITION_DELIM; conf->processed_main_config = 0; diff --git a/libmultipath/config.h b/libmultipath/config.h index 9e47894..9a90745 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -62,6 +62,7 @@ struct hwentry { int user_friendly_names; int retain_hwhandler; int detect_prio; + int detect_checker; int deferred_remove; int delay_watch_checks; int delay_wait_checks; @@ -139,6 +140,7 @@ struct config { int reassign_maps; int retain_hwhandler; int detect_prio; + int detect_checker; int force_sync; int deferred_remove; int processed_main_config; diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h index 3ef1579..db2b756 100644 --- a/libmultipath/defaults.h +++ b/libmultipath/defaults.h @@ -22,6 +22,7 @@ #define DEFAULT_DEV_LOSS_TMO 600 #define DEFAULT_RETAIN_HWHANDLER RETAIN_HWHANDLER_ON #define DEFAULT_DETECT_PRIODETECT_PRIO_ON +#define DEFAULT_DETECT_CHECKER DETECT_CHECKER_ON #define DEFAULT_DEFERRED_REMOVEDEFERRED_REMOVE_OFF #define DEFAULT_DELAY_CHECKS NU_NO #define DEFAULT_ERR_CHECKS NU_NO diff --git a/libmultipath/dict.c b/libmultipath/dict.c index 3521c78..bababdb 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -379,6 +379,13 @@ declare_ovr_snprint(detect_prio, print_yes_no_undef) declare_hw_handler(detect_prio, set_yes_no_undef) declare_hw_snprint(detect_prio, print_yes_no_undef) +declare_def_handler(detect_checker, set_yes_no_undef) +declare_def_snprint_defint(detect_checker, print_yes_no_undef, YNU_NO) +declare_ovr_handler(detect_checker, set_yes_no_undef) +declare_ovr_snprint(detect_checker, print_yes_no_undef) +declare_hw_handler(detect_checker, set_yes_no_undef) +declare_hw_snprint(detect_checker, print_yes_no_undef) + declare_def_handler(force_sync, set_yes_no) declare_def_snprint(force_sync, print_yes_no) @@ -1419,6 +1426,7 @@ init_keywords(vector keywords) install_keyword("reservation_key", &def_reservation_key_handler, &snprint_def_reservation_key); install_keyword("retain_attached_hw_handler", &def_retain_hwhandler_handler, &snprint_def_retain_hwhandler); install_keyword("detect_prio", &def_detect_prio_handler, &snprint_def_detect_prio); + install_keyword("detect_checker", &def_detect_checker_handler, &snprint_def_detect_checker); install_keyword("force_sync", &def_force_sync_handler, &snprint_def_force_sync); install_keyword("strict_timing", &def_strict_timing_handler, &snprint_def_strict_timing); install_keyword("deferred_remove", &de
[dm-devel] [PATCH v4 6/6] fix udev rules for failed multipath devices
11-dm-mpath.rules was only correctly dealing with the case where the multipath device was unusable because the last path had failed. If instead, the last working path was removed from the device on a table reload, it was not correctly marking the device as unusable. One problem with fixing this is that when the device table is reloaded, device-mapper doesn't know if the path devices are usable or not. To deal with this, multipath now flags reloads with no usable paths with DM_SUBSYSTEM_UDEV_FLAG2. 11-dm-mpath.rules now checks for both PATH_FAILED events and reloads with no valid paths. and disables the other rules. Signed-off-by: Benjamin Marzinski --- libmultipath/devmapper.c| 3 +- libmultipath/devmapper.h| 6 multipath/11-dm-mpath.rules | 67 +++-- 3 files changed, 55 insertions(+), 21 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 9c0b240..9b6b053 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -374,7 +374,8 @@ int dm_addmap_reload(struct multipath *mpp, char *params, int flush) int r; uint16_t udev_flags = (flush ? 0 : MPATH_UDEV_RELOAD_FLAG) | ((mpp->skip_kpartx == SKIP_KPARTX_ON)? - MPATH_UDEV_NO_KPARTX_FLAG : 0); + MPATH_UDEV_NO_KPARTX_FLAG : 0) | + ((mpp->nr_active)? 0 : MPATH_UDEV_NO_PATHS_FLAG); /* * DM_DEVICE_RELOAD cannot wait on a cookie, as diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index 411177d..3ea4329 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -18,6 +18,12 @@ #define MPATH_UDEV_NO_KPARTX_FLAG 0 #endif +#ifdef DM_SUBSYSTEM_UDEV_FLAG2 +#define MPATH_UDEV_NO_PATHS_FLAG DM_SUBSYSTEM_UDEV_FLAG2 +#else +#define MPATH_UDEV_NO_PATHS_FLAG 0 +#endif + void dm_init(int verbosity); int dm_prereq (void); int dm_drv_version (unsigned int * version, char * str); diff --git a/multipath/11-dm-mpath.rules b/multipath/11-dm-mpath.rules index 5559af3..b131a10 100644 --- a/multipath/11-dm-mpath.rules +++ b/multipath/11-dm-mpath.rules @@ -2,39 +2,66 @@ ACTION!="add|change", GOTO="mpath_end" ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="mpath_end" ENV{DM_UUID}!="mpath-?*", GOTO="mpath_end" +IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD" +IMPORT{db}="MPATH_DEVICE_READY" + +# If this uevent didn't come from dm, don't try to update the +# device state +ENV{DM_COOKIE}!="?*", ENV{DM_ACTION}!="PATH_*", IMPORT{db}="DM_UDEV_DISABLE_OTHER_RULES_FLAG", IMPORT{db}="DM_NOSCAN", GOTO="scan_import" + +ENV{.MPATH_DEVICE_READY_OLD}="$env{MPATH_DEVICE_READY}" + +# multipath sets DM_SUBSYSTEM_UDEV_FLAG2 when it reloads a +# table with no active devices. If this happens, mark the +# device not ready +ENV{DM_SUBSYSTEM_UDEV_FLAG2}=="1", ENV{MPATH_DEVICE_READY}="0",\ + GOTO="mpath_action" + +# If the last path has failed mark the device not ready +ENV{DM_ACTION}=="PATH_FAILED", ENV{DM_NR_VALID_PATHS}=="0",\ + ENV{MPATH_DEVICE_READY}="0", GOTO="mpath_action" + +# Don't mark a device ready on a PATH_FAILED event. even if +# DM_NR_VALID_PATHS is greater than 0. Just keep the existing +# value +ENV{DM_ACTION}=="PATH_FAILED", GOTO="mpath_action" + +# This event is either a PATH_REINSTATED or a table reload where +# there are active paths. Mark the device ready +ENV{MPATH_DEVICE_READY}="" + +LABEL="mpath_action" +# DM_SUBSYSTEM_UDEV_FLAG0 is the "RELOAD" flag for multipath subsystem. +# Drop the DM_ACTIVATION flag here as mpath reloads tables if any of its +# paths are lost/recovered. For any stack above the mpath device, this is not +# something that should be reacted upon since it would be useless extra work. +# It's exactly mpath's job to provide *seamless* device access to any of the +# paths that are available underneath. +ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", ENV{DM_ACTIVATION}="0" + # Do not initiate scanning if no path is available, # otherwise there would be a hang or IO error on access. # We'd like to avoid this, especially within udev processing. -ENV{DM_NR_VALID_PATHS}!="?*", IMPORT{db}="DM_NR_VALID_PATHS" -ENV{DM_NR_VALID_PATHS}!="0", GOTO="mpath_blkid_end" -ENV{ID_FS_TYPE}!="?*", IMPORT{db}="ID_FS_TYPE" -ENV{ID_FS_USAGE}!="?*", IMPORT{db}="ID_FS_USAGE" -ENV{ID_FS_UUID}!="?*", IMPORT{db}="ID_FS_UUID" -ENV{ID_FS_ENC}!="?*", IMPORT{db}="ID_FS_UUID_ENC" -ENV{ID_FS_VERSION}!="?*", IMPORT{db}="ID_FS_VERSION" -LABEL="mpath_blkid_end" +ENV{MPATH_DEVICE_READY}=="0", ENV{DM_NOSCAN}="1" # Also skip all foreign rules if no path is available. # Remember the original value of DM_DISABLE_OTHER_RULES_FLAG # and restore it back once we have at least one path available. -IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD" -ENV{DM_ACTION}=="PATH_FAILED",\ - ENV{DM_NR_VALID_PATHS}=="0",\ +ENV{MPATH_DEVICE_READY}=="0", ENV{.MPATH_DEVICE_READY_OLD}!="0",\ ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}=="",\
[dm-devel] [PATCH v4 5/6] multipathd: allow resetting stats
This patch adds two multipathd interactive commands: multipathd reset maps stats and multipathd reset map stats to reset the statistics that are shown with the "show stats" commands. Signed-off-by: Benjamin Marzinski --- multipathd/cli.c | 2 ++ multipathd/cli_handlers.c | 44 multipathd/cli_handlers.h | 2 ++ multipathd/main.c | 2 ++ 4 files changed, 50 insertions(+) diff --git a/multipathd/cli.c b/multipathd/cli.c index 50161be..32d4976 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -547,6 +547,8 @@ cli_init (void) { add_handler(LIST+BLACKLIST, NULL); add_handler(LIST+DEVICES, NULL); add_handler(LIST+WILDCARDS, NULL); + add_handler(RESET+MAPS+STATS, NULL); + add_handler(RESET+MAP+STATS, NULL); add_handler(ADD+PATH, NULL); add_handler(DEL+PATH, NULL); add_handler(ADD+MAP, NULL); diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index b0eeca6..b20b054 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -277,6 +277,17 @@ show_config (char ** r, int * len) return 0; } +void +reset_stats(struct multipath * mpp) +{ + mpp->stat_switchgroup = 0; + mpp->stat_path_failures = 0; + mpp->stat_map_loads = 0; + mpp->stat_total_queueing_time = 0; + mpp->stat_queueing_timeouts = 0; + mpp->stat_map_failures = 0; +} + int cli_list_config (void * v, char ** reply, int * len, void * data) { @@ -627,6 +638,39 @@ cli_list_daemon (void * v, char ** reply, int * len, void * data) } int +cli_reset_maps_stats (void * v, char ** reply, int * len, void * data) +{ + struct vectors * vecs = (struct vectors *)data; + int i; + struct multipath * mpp; + + condlog(3, "reset multipaths stats (operator)"); + + vector_foreach_slot(vecs->mpvec, mpp, i) { + reset_stats(mpp); + } + return 0; +} + +int +cli_reset_map_stats (void * v, char ** reply, int * len, void * data) +{ + struct vectors * vecs = (struct vectors *)data; + struct multipath * mpp; + char * param = get_keyparam(v, MAP); + + param = convert_dev(param, 0); + mpp = find_mp_by_str(vecs->mpvec, param); + + if (!mpp) + return 1; + + condlog(3, "reset multipath %s stats (operator)", param); + reset_stats(mpp); + return 0; +} + +int cli_add_path (void * v, char ** reply, int * len, void * data) { struct vectors * vecs = (struct vectors *)data; diff --git a/multipathd/cli_handlers.h b/multipathd/cli_handlers.h index 19e003d..f4d02cc 100644 --- a/multipathd/cli_handlers.h +++ b/multipathd/cli_handlers.h @@ -19,6 +19,8 @@ int cli_list_config (void * v, char ** reply, int * len, void * data); int cli_list_blacklist (void * v, char ** reply, int * len, void * data); int cli_list_devices (void * v, char ** reply, int * len, void * data); int cli_list_wildcards (void * v, char ** reply, int * len, void * data); +int cli_reset_maps_stats (void * v, char ** reply, int * len, void * data); +int cli_reset_map_stats (void * v, char ** reply, int * len, void * data); int cli_add_path (void * v, char ** reply, int * len, void * data); int cli_del_path (void * v, char ** reply, int * len, void * data); int cli_add_map (void * v, char ** reply, int * len, void * data); diff --git a/multipathd/main.c b/multipathd/main.c index 1d73f9d..e317a4c 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1238,6 +1238,8 @@ uxlsnrloop (void * ap) set_handler_callback(LIST+BLACKLIST, cli_list_blacklist); set_handler_callback(LIST+DEVICES, cli_list_devices); set_handler_callback(LIST+WILDCARDS, cli_list_wildcards); + set_handler_callback(RESET+MAPS+STATS, cli_reset_maps_stats); + set_handler_callback(RESET+MAP+STATS, cli_reset_map_stats); set_handler_callback(ADD+PATH, cli_add_path); set_handler_callback(DEL+PATH, cli_del_path); set_handler_callback(ADD+MAP, cli_add_map); -- 1.8.3.1 -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel
[dm-devel] [PATCH v4 4/6] multipathd: add messages on delayed path addition
When multipath delays adding a path because the device is waiting for udev to finish initialization, it now logs a message, so the users know what happened to the path. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/multipathd/main.c b/multipathd/main.c index 553d1d1..1d73f9d 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -486,6 +486,8 @@ ev_add_map (char * dev, char * alias, struct vectors * vecs) if (mpp) { if (mpp->wait_for_udev > 1) { + condlog(2, "%s: performing delayed actions", + mpp->alias); if (update_map(mpp, vecs)) /* setup multipathd removed the map */ return 1; @@ -720,6 +722,7 @@ ev_add_path (struct path * pp, struct vectors * vecs) (pathcount(mpp, PATH_UP) > 0 || (pathcount(mpp, PATH_GHOST) > 0 && pp->tpgs != TPGS_IMPLICIT))) { /* if wait_for_udev is set and valid paths exist */ + condlog(2, "%s: delaying path addition until %s is fully initialized", pp->dev, mpp->alias); mpp->wait_for_udev = 2; orphan_path(pp, "waiting for create to complete"); return 0; -- 1.8.3.1 -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel
[dm-devel] [PATCH v4 0/6] misc patches
Here's a couple of minor features bugfixes and cleanups. The biggest change is that the detect_checker option now sets the checker for devices with detected ALUA to TUR. Also, udev wasn't correctly disabling rules for multipath devices that lost their last usable path through a table reload. This was causing lvmetad some problems on failing multipath devices. Differences from v3: Rebased patches Benjamin Marzinski (6): libmultipath: add detect_checker option libmultipath: cleanup orphan device states multipathd: don't update priority of failed paths multipathd: add messages on delayed path addition multipathd: allow resetting stats fix udev rules for failed multipath devices libmultipath/config.c | 3 ++ libmultipath/config.h | 2 ++ libmultipath/defaults.h | 1 + libmultipath/devmapper.c | 3 +- libmultipath/devmapper.h | 6 libmultipath/dict.c | 10 ++ libmultipath/discovery.c | 28 +-- libmultipath/hwtable.c| 1 + libmultipath/print.c | 4 +-- libmultipath/prioritizers/alua_spc3.h | 1 + libmultipath/propsel.c| 31 ++-- libmultipath/propsel.h| 1 + libmultipath/structs.c| 2 ++ libmultipath/structs.h| 7 multipath/11-dm-mpath.rules | 67 --- multipath/multipath.conf.5| 18 ++ multipathd/cli.c | 2 ++ multipathd/cli_handlers.c | 44 +++ multipathd/cli_handlers.h | 2 ++ multipathd/main.c | 8 - 20 files changed, 205 insertions(+), 36 deletions(-) -- 1.8.3.1 -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel
[dm-devel] [PATCH v4 3/6] multipathd: don't update priority of failed paths
Multipathd shouldn't be updating the priority of failed paths in the checkerloop. The current avoids this in almost all cases, but not all. Close the loophole. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/multipathd/main.c b/multipathd/main.c index 0f32b2c..553d1d1 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1467,7 +1467,8 @@ int update_prio(struct path *pp, int refresh_all) } oldpriority = pp->priority; conf = get_multipath_config(); - pathinfo(pp, conf, DI_PRIO); + if (pp->state != PATH_DOWN) + pathinfo(pp, conf, DI_PRIO); put_multipath_config(conf); if (pp->priority == oldpriority) -- 1.8.3.1 -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel
[dm-devel] [PATCH v4 2/6] libmultipath: cleanup orphan device states
After a path device is orphaned, multipathd stops checking its state. However, multipathd show state still shows its old state. It should display "undef unknown" instead. Signed-off-by: Benjamin Marzinski --- libmultipath/print.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libmultipath/print.c b/libmultipath/print.c index 5b03383..00a3626 100644 --- a/libmultipath/print.c +++ b/libmultipath/print.c @@ -392,7 +392,7 @@ snprint_dev_t (char * buff, size_t len, struct path * pp) static int snprint_offline (char * buff, size_t len, struct path * pp) { - if (!pp) + if (!pp || !pp->mpp) return snprintf(buff, len, "unknown"); else if (pp->offline) return snprintf(buff, len, "offline"); @@ -403,7 +403,7 @@ snprint_offline (char * buff, size_t len, struct path * pp) static int snprint_chk_state (char * buff, size_t len, struct path * pp) { - if (!pp) + if (!pp || !pp->mpp) return snprintf(buff, len, "undef"); switch (pp->state) { -- 1.8.3.1 -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel
Re: [dm-devel] [PATCH] Avoid that reloading a map sporadically triggers I/O errors
Hello Christophe, The patch below was posted more than three months ago but has not yet received any feedback from you. Had I sent this patch to the right person? Do you perhaps want me to repost it? Bart. On 01/04/17 11:56, Benjamin Marzinski wrote: On Wed, Dec 07, 2016 at 03:37:44PM -0800, Bart Van Assche wrote: ACK -Ben Christophe and Hannes, do you want to comment on this patch? Thanks, Bart. On 11/18/2016 01:33 PM, Bart Van Assche wrote: Avoid that reloading a map while there are no paths triggers a flush and hence unwanted I/O errors if 'queue_if_no_path' is enabled. Fixes: commit d569988e7528 ("libmultipath: Fixup 'DM_DEVICE_RELOAD' handling") Signed-off-by: Bart Van Assche Cc: Hannes Reinecke --- libmultipath/devmapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index f92ebce..31f1962 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -390,7 +390,7 @@ int dm_addmap_reload(struct multipath *mpp, char *params, int flush) params, ADDMAP_RO, SKIP_KPARTX_OFF); } if (r) - r = dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, flush, + r = dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, !flush, 1, udev_flags, 0); return r; } -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel
Re: [dm-devel] [PATCH] multipath-tools: improve processing efficiency for addition and deletion of multipath devices
Hi Christophe, OK, I'll post it later. regards, Tang Junhui 原始邮件 发件人: <christophe.varo...@opensvc.com> 收件人: <bmarz...@redhat.com> 抄送人:唐文俊10144149唐军辉10074136张凯10072500 <dm-devel@redhat.com> <bart.vanass...@sandisk.com> <mwi...@suse.com> 日 期 :2017年02月27日 14:22 主 题 :Re: [dm-devel] [PATCH] multipath-tools: improve processing efficiency for addition and deletion of multipath devices Hi Junhui, It seems I did not receive the patch version Acked by Ben,Can you rebase and post please ? Thanks. On Thu, Feb 16, 2017 at 5:27 PM, Benjamin Marzinski <bmarz...@redhat.com> wrote: On Thu, Feb 16, 2017 at 02:54:01PM +0800, tang.jun...@zte.com.cn wrote: > From: "tang.junhui" <tang.jun...@zte.com.cn> ACK Thanks for all your work on this. -Ben > > Change-Id: I3f81a55fff389f991f915927000b281d7e263cc5 > Signed-off-by: tang.junhui <tang.jun...@zte.com.cn> > > This patch used to improve processing efficiency for addition and deletion > of multipath devices. > > This patch is tested pass by ZTE multipath automatic testing system. > The modification reduces the system consumption(such as CPU) and shortens > the processing time obviously in scene of massive multipath devices > addition or deletion. > > The main processing flow of code is: > 1) add uid_attrs configuration in the defaults section: >It is configured udev attribute which providing a unique path identifier >for corresponding type of path devices. If this field is configured and >matched with type of device, it would override any other methods providing >for device unique identifier in config file, and it would activate merging >uevents according to the identifier to promote effiecncy in processing >uevents. Tt has no default value, so defaultly only uevents filtering >works, and uevents merging does not works, if users want to identify path >by udev attribute and to activate merging uevents for SCSI and DAS device, >they can set it's value as: >"sd:ID_SERIAL dasd:ID_UID" > 2) uevents accumulation in uevents burst scene: >wait one seconds for more uevents in uevent_listen() in uevents burst >situations > 3) uevents preparing, filtering and merging: >discard unuse uevents and fetch path idendifier from uevents >filter uevents >merge uevents. > 4) uevents proccessing: >proccess the merged uevents in uev->merge_node list without calling >domap() >proccess the last uevents uev with calling domap(). > --- > libmultipath/config.c | 3 + > libmultipath/config.h | 1 + > libmultipath/dict.c| 3 + > libmultipath/discovery.c | 5 +- > libmultipath/discovery.h | 2 +- > libmultipath/list.h| 41 ++ > libmultipath/propsel.c | 7 + > libmultipath/uevent.c | 320 +++-- > libmultipath/uevent.h | 2 + > libmultipath/util.c| 42 ++ > libmultipath/util.h| 1 + > multipath/multipath.conf.5 | 18 +++ > multipathd/cli_handlers.c | 4 +- > multipathd/main.c | 93 + > multipathd/main.h | 4 +- > 15 files changed, 471 insertions(+), 75 deletions(-) > > diff --git a/libmultipath/config.c b/libmultipath/config.c > index 15ddbd8..765e91d 100644 > --- a/libmultipath/config.c > +++ b/libmultipath/config.c > @@ -488,6 +488,9 @@ free_config (struct config * conf) > if (conf->uid_attribute) > FREE(conf->uid_attribute) > > + if (conf->uid_attrs) > + FREE(conf->uid_attrs) > + > if (conf->getuid) > FREE(conf->getuid) > > diff --git a/libmultipath/config.h b/libmultipath/config.h > index 9670020..ab85930 100644 > --- a/libmultipath/config.h > +++ b/libmultipath/config.h > @@ -153,6 +153,7 @@ struct config { > > char * multipath_dir > char * selector > + char * uid_attrs > char * uid_attribute > char * getuid > char * features > diff --git a/libmultipath/dict.c b/libmultipath/dict.c > index dc21846..0a531d1 100644 > --- a/libmultipath/dict.c > +++ b/libmultipath/dict.c > @@ -249,6 +249,8 @@ declare_ovr_snprint(selector, print_str) > declare_mp_handler(selector, set_str) > declare_mp_snprint(selector, print_str) > > +declare_def_handler(uid_attrs, set_str) > +declare_def_snprint(uid_attrs, print_str) > declare_def_handler(uid_attribute, set_str) > declare_def_snprint_defstr(uid_attribute, print_str, DEFAULT_UID_ATTRIBUTE) > declare_ovr_handler(uid_attribute, set_str) > @@ -1367,6 +1369,7 @@ init_keywords(vector keywords) > install_keyword("multipath_dir", &def_multipath_dir_handler, &snprint_def_multipath_dir) > install_keyword("path_selector", &def_selector_handler, &snprint_def_selector) > install_keyword("path_grouping_policy", &def_pgpolicy_handler, &snprint_def_pgpolicy) > + install_keyword("uid_attrs", &de