Misc multipath patches.
Benjamin Marzinski
maintainercover Misc multipath patches.
The first three of these patches are resends of earlier patches, just rebased. The next three are all related to adding support for deferred removes to multipath. With the deferred_remove option set to "yes" mutipathed will now use the new device-mapper deferred remove funationality to do deferred removes on multipath devices that are sill open when the last of their paths has been removed. This will cause the devices to get removed when the last user closes them, unless a path has not reappeared, and cancelled the deferred remove. The last two are new bugfixes.
Benjamin Marzinski (8):
correctly set partition delimiter on rename
libmultipath: fix sysfs_get_size bug
Revert "libmultipath: fixup strlcpy"
libmultipath: refactor partmaps code
multipathd: fix memory corruption issue
multipathd: add deferred_remove support
multipathd: don't buffer output with systemd
libmutipath: allow blanks in device blacklist
libmultipath/Makefile | 6 + libmultipath/blacklist.c | 16 ++- libmultipath/config.c | 5 + libmultipath/config.h | 4 + libmultipath/configure.c | 1 + libmultipath/defaults.h | 1 + libmultipath/devmapper.c | 284 +++++++++++++++++++++++++++++---------------- libmultipath/devmapper.h | 11 +- libmultipath/dict.c | 17 +++ libmultipath/propsel.c | 26 +++++ libmultipath/propsel.h | 1 + libmultipath/structs.h | 8 ++ libmultipath/structs_vec.c | 3 +- libmultipath/sysfs.c | 2 +- libmultipath/util.c | 3 +- multipath/multipath.conf.5 | 14 +++ multipathd/main.c | 34 ++++-- 17 files changed, 317 insertions(+), 119 deletions(-)
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH 1/8 correctly set partition delimiter on rename
When multipath renames a device and the name switches from ending in a number to ending in a letter or vice versa, it currently just keeps any existing delimiter between the device name and partition number. However the default behaviour in kpartx is to only use the 'p' delimiter when the name ends in a number. Unfortunately, without adding a kpartx.conf that kpartx uses to set the delimiter behavior, there's no way for multipath to know how kpartx was run for certain device names (ones ending in a number with a 'p' delimiter).
The patch adds a new multipath.conf defaults parameter, "partition_delimiter". If this value is not set, when multipath renames a device, it will act just like the kpartx default does, only adding a 'p' to names ending in a number. If this parameter is set, multipath will act like kpartx does with the -p option is used, and always add delimiter.
--- libmultipath/config.c | 3 +++ libmultipath/config.h | 1 + libmultipath/devmapper.c | 14 ++++++++++++-- libmultipath/dict.c | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-)
libmultipath/config.c +3 -0
@@ -502,6 +502,8 @@ free_config (struct config * conf)if (conf->alias_prefix)FREE (conf->alias_prefix); +if (conf->partition_delim) +FREE (conf->partition_delim);if (conf->prio_args)FREE (conf->prio_args);
@@ -563,6 +565,7 @@ load_config (char * file, struct udev *udev) conf->retain_hwhandler =DEFAULT_RETAIN_HWHANDLER ; conf->detect_prio =DEFAULT_DETECT_PRIO ; conf->force_sync =0 ; + conf->partition_delim =NULL ;/* * preload default hwtable
libmultipath/config.h +1 -0
@@ -140,6 +140,7 @@ struct config {char * prio_args;char * checker_name;char * alias_prefix; +char * partition_delim;unsigned char * reservation_key;vector keywords;
libmultipath/devmapper.c +12 -2
@@ -1142,6 +1142,8 @@ dm_rename_partmaps (char * old, char * new)unsigned long long size;char dev_t[32 ];int r =1 ; +int offset; +char *delim;if (!(dmt =dm_task_create (DM_DEVICE_LIST )))return 1 ;
@@ -1162,6 +1164,13 @@ dm_rename_partmaps (char * old, char * new)if (dm_dev_t (old, &dev_t[0 ],32 )) goto out; +if (conf->partition_delim) + delim = conf->partition_delim; +if (isdigit (new[strlen (new)-1 ])) + delim ="p" ; +else + delim ="" ; + do { if ( /*
@@ -1189,8 +1198,9 @@ dm_rename_partmaps (char * old, char * new)* then it's a kpartx generated partition. * Rename it. */ -snprintf (buff,PARAMS_SIZE ,"%s%s" , - new, names->name +strlen (old)); +for (offset =strlen (old); names->name[offset] && !(isdigit (names->name[offset])); offset++);/* do nothing */ +snprintf (buff,PARAMS_SIZE ,"%s%s%s" , + new, delim, names->name + offset);dm_rename (names->name, buff);condlog (4 ,"partition map %s renamed" , names->name);
libmultipath/dict.c +4 -0
@@ -230,6 +230,9 @@ declare_def_snprint(reassign_maps, print_yes_no) declare_def_handler(multipath_dir, set_str) declare_def_snprint(multipath_dir, print_str) +declare_def_handler(partition_delim, set_str) +declare_def_snprint(partition_delim, print_str) + declare_def_handler(selector, set_str) declare_def_snprint_defstr(selector, print_str, DEFAULT_SELECTOR)declare_hw_handler (selector, set_str)
@@ -1242,6 +1245,7 @@ init_keywords(void)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 ("force_sync" , &def_force_sync_handler, &snprint_def_force_sync); +install_keyword ("partition_delimiter" , &def_partition_delim_handler, &snprint_def_partition_delim);__deprecated install_keyword ("default_selector" , &def_selector_handler,NULL );__deprecated install_keyword ("default_path_grouping_policy" , &def_pgpolicy_handler,NULL );__deprecated install_keyword ("default_uid_attribute" , &def_uid_attribute_handler,NULL );
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH 2/8 libmultipath: fix sysfs_get_size bug
In reply to Benjamin Marzinskisysfs_get_size wasn't checking for a negative return value from sysfs_attr_get_value.
--- libmultipath/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/sysfs.c +1 -1
@@ -158,7 +158,7 @@ sysfs_get_size (struct path *pp, unsigned long long * size)return 1 ; attr[0 ] ='\0' ; -if (sysfs_attr_get_value (pp->udev,"size" , attr,255 ) ==0 ) { +if (sysfs_attr_get_value (pp->udev,"size" , attr,255 ) <=0 ) {condlog (3 ,"%s: No size attribute in sysfs" , pp->dev);return 1 ; }
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH 3/8 Revert "libmultipath: fixup strlcpy"
In reply to Benjamin MarzinskiThis reverts commit 3a64d6491a1e83adcaf5f97edd18b7898dce241d.
strlcpy already had a check to make sure that as long as the size passed in wasn't zero, it would leave enough space to write the final null. So, the only check that was necessary was to see if strlcpy was called with size = 0.
strlcpy returns the number of bytes that it took, or would take, to write the entire string. There is no reason why bytes would usually end up equalling size, so this commit caused strlcpy to stop null terminating many strings.
--- libmultipath/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
libmultipath/util.c +2 -1
@@ -112,7 +112,8 @@ size_t strlcpy(char *dst, const char *src, size_t size) bytes++; } -if (bytes == size) +/* If size == 0 there is no space for a final null... */ +if (size) *q ='\0' ;return bytes; }
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH 4/8 libmultipath: refactor partmaps code
In reply to Benjamin MarzinskiThere was a lot of code duplication between dm_remove_partmaps and dm_rename_partmaps. This patch factors that out into do_foreach_partmaps.
--- libmultipath/devmapper.c | 156 +++++++++++++++++++---------------------------- 1 file changed, 62 insertions(+), 94 deletions(-)
libmultipath/devmapper.c +62 -94
@@ -998,8 +998,9 @@ bad:return NULL ; } -int -dm_remove_partmaps (const char * mapname,int need_sync) +static int +do_foreach_partmaps (const char * mapname,int (*partmap_func)(char *,void *), +void *data) {struct dm_task *dmt;struct dm_names *names;
@@ -1051,26 +1052,8 @@ dm_remove_partmaps (const char * mapname, int need_sync)*/ strstr(params, dev_t) ) { -/* -* then it's a kpartx generated partition. -* remove it. -*/ -/* -* if the opencount is 0 maybe some other -* partitions depend on it. -*/ -if (dm_get_opencount (names->name)) { -dm_remove_partmaps (names->name, need_sync); -if (dm_get_opencount (names->name)) { -condlog (2 ,"%s: map in use" , - names->name); - goto out; - } - } -condlog (4 ,"partition map %s removed" , - names->name); -dm_simplecmd_flush (DM_DEVICE_REMOVE , names->name, - need_sync,0 ); +if (partmap_func (names->name, data) !=0 ) + goto out; } next = names->next;
@@ -1083,6 +1066,35 @@ out:return r; } +struct remove_data { +int need_sync; +}; + +static int +remove_partmap (char *name,void *data) +{ +struct remove_data *rd = (struct remove_data *)data; + +if (dm_get_opencount (name)) { +dm_remove_partmaps (name, rd->need_sync); +if (dm_get_opencount (name)) { +condlog (2 ,"%s: map in use" , name); +return 1 ; + } + } +condlog (4 ,"partition map %s removed" , name); +dm_simplecmd_flush (DM_DEVICE_REMOVE , name, + rd->need_sync,0 ); +return 0 ; +} + +int +dm_remove_partmaps (const char * mapname,int need_sync) +{ +struct remove_data rd = { need_sync }; +return do_foreach_partmaps (mapname, remove_partmap, &rd); +} +static struct dm_info *alloc_dminfo (void ) {
@@ -1132,88 +1144,44 @@ out:return r; } -int -dm_rename_partmaps (char * old,char * new) +struct rename_data { +char *old; +char *new; +char *delim; +}; + +static int +rename_partmap (char *name,void *data) { -struct dm_task *dmt; -struct dm_names *names; -unsigned next =0 ;char buff[PARAMS_SIZE ]; -unsigned long long size; -char dev_t[32 ]; -int r =1 ;int offset; -char *delim; +struct rename_data *rd = (struct rename_data *)data; -if (!(dmt =dm_task_create (DM_DEVICE_LIST ))) -return 1 ; - -dm_task_no_open_count (dmt); - -if (!dm_task_run (dmt)) - goto out; - -if (!(names =dm_task_get_names (dmt))) - goto out; +if (strncmp (name, rd->old,strlen (rd->old)) !=0 ) +return 0 ; +for (offset =strlen (rd->old); name[offset] && !(isdigit (name[offset])); offset++);/* do nothing */ +snprintf (buff,PARAMS_SIZE ,"%s%s%s" , rd->new, rd->delim, + name + offset); +dm_rename (name, buff); +condlog (4 ,"partition map %s renamed" , name); +return 0 ; +} -if (!names->dev) { - r =0 ;/* this is perfectly valid */ - goto out; - } +int +dm_rename_partmaps (char * old,char * new) +{ +struct rename_data rd; -if (dm_dev_t (old, &dev_t[0 ],32 )) - goto out; + rd.old = old; + rd.new = new;if (conf->partition_delim) - delim = conf->partition_delim; + rd.delim = conf->partition_delim;if (isdigit (new[strlen (new)-1 ])) - delim ="p" ; + rd.delim ="p" ;else - delim ="" ; - -do { -if ( -/* -* if devmap target is "linear" -*/ - (dm_type (names->name,TGT_PART ) >0 ) && - -/* -* and the multipath mapname and the part mapname start -* the same -*/ - !strncmp (names->name, old,strlen (old)) && - -/* -* and we can fetch the map table from the kernel -*/ - !dm_get_map (names->name, &size, &buff[0 ]) && - -/* -* and the table maps over the multipath map -*/ -strstr (buff, dev_t) - ) { -/* -* then it's a kpartx generated partition. -* Rename it. -*/ -for (offset =strlen (old); names->name[offset] && !(isdigit (names->name[offset])); offset++);/* do nothing */ -snprintf (buff,PARAMS_SIZE ,"%s%s%s" , - new, delim, names->name + offset); -dm_rename (names->name, buff); -condlog (4 ,"partition map %s renamed" , - names->name); - } - - next = names->next; - names = (void *) names + next; - }while (next); - - r =0 ; -out: -dm_task_destroy (dmt); -return r; + rd.delim ="" ; +return do_foreach_partmaps (old, rename_partmap, &rd); }int
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH 5/8 multipathd: fix memory corruption issue
In reply to Benjamin Marzinskisetup_multipath already removes the mpp if it fails, so we shouldn't be accessing the mpp at all if it fails, and especially not freeing it.
--- multipathd/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
multipathd/main.c +2 -3
@@ -657,9 +657,8 @@ ev_remove_path (struct path *pp, struct vectors * vecs)/* * update our state from kernel */ -if (setup_multipath (vecs, mpp)) { - goto fail; - } +if (setup_multipath (vecs, mpp)) +return 1 ;sync_map_state (mpp); condlog(2, "%s [%s]: path removed from map %s",
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH 6/8 multipathd: add deferred_remove support
In reply to Benjamin MarzinskiThis patch adds a new configuration option "deferrer_remove" If this is set to "yes", when the last path of a multipath device is removed, multipathd will do a deferred remove on it. This means that if the device cannot immediately be removed, device mapper will automatically remove it when the last user closes it. If a path is added to the device before then, the deferred remove will be cancelled.
Without this enabled, multipath will continue to work like before, where it will attempt a regular remove when the last path is removed. If that fails because the device is in use, then the multipath device will remain, even after the last user closes it.
--- libmultipath/Makefile | 6 ++ libmultipath/config.c | 2 + libmultipath/config.h | 3 + libmultipath/configure.c | 1 + libmultipath/defaults.h | 1 + libmultipath/devmapper.c | 142 ++++++++++++++++++++++++++++++++++++++++----- libmultipath/devmapper.h | 11 ++-- libmultipath/dict.c | 13 +++++ libmultipath/propsel.c | 26 +++++++++ libmultipath/propsel.h | 1 + libmultipath/structs.h | 8 +++ libmultipath/structs_vec.c | 3 +- multipath/multipath.conf.5 | 14 +++++ multipathd/main.c | 23 ++++++-- 14 files changed, 228 insertions(+), 26 deletions(-)
libmultipath/Makefile +6 -0
@@ -46,6 +46,12 @@ ifdef SYSTEMD CFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) endif +LIBDM_API_DEFERRED = $(shell grep -Ecs '^[a-z]*[[:space:]]+dm_task_deferred_remove' /usr/include/libdevmapper.h) + +ifneq ($(strip $(LIBDM_API_DEFERRED)),0) + CFLAGS += -DLIBDM_API_DEFERRED +endif + all: $(LIBS) $(LIBS): $(OBJS)
libmultipath/config.c +2 -0
@@ -340,6 +340,7 @@ merge_hwe (struct hwentry * dst, struct hwentry * src)merge_num (user_friendly_names);merge_num (retain_hwhandler);merge_num (detect_prio); +merge_num (deferred_remove);/* * Make sure features is consistent with
@@ -412,6 +413,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; + conf->deferred_remove =DEFAULT_DEFERRED_REMOVE ;if (dhwe->bl_product && !(hwe->bl_product =set_param_str (dhwe->bl_product))) goto out;
libmultipath/config.h +3 -0
@@ -59,6 +59,7 @@ struct hwentry {int user_friendly_names;int retain_hwhandler;int detect_prio; +int deferred_remove;char * bl_product; };
@@ -82,6 +83,7 @@ struct mpentry {int flush_on_last_del;int attribute_flags;int user_friendly_names; +int deferred_remove;uid_t uid;gid_t gid;mode_t mode;
@@ -124,6 +126,7 @@ struct config {int retain_hwhandler;int detect_prio;int force_sync; +int deferred_remove;unsigned int version[3 ];char * dev;
libmultipath/configure.c +1 -0
@@ -289,6 +289,7 @@ setup_map (struct multipath * mpp, char * params, int params_size)select_dev_loss (mpp);select_reservation_key (mpp);select_retain_hwhandler (mpp); +select_deferred_remove (mpp);sysfs_set_scsi_tmo (mpp);/*
libmultipath/defaults.h +1 -0
@@ -16,6 +16,7 @@#define DEFAULT_FAST_IO_FAIL 5#define DEFAULT_RETAIN_HWHANDLER RETAIN_HWHANDLER_OFF#define DEFAULT_DETECT_PRIO DETECT_PRIO_OFF +#define DEFAULT_DEFERRED_REMOVE DEFERRED_REMOVE_OFF#define DEFAULT_CHECKINT 5#define MAX_CHECKINT (a) (a << 2)
libmultipath/devmapper.c +127 -15
228 lines not on this page · raw message
libmultipath/devmapper.h +7 -4
@@ -23,9 +23,11 @@ int dm_map_present (const char *);int dm_get_map (const char *,unsigned long long *,char *);int dm_get_status (char *,char *);int dm_type (const char *,char *); -int _dm_flush_map (const char *,int ); -#define dm_flush_map (mapname) _dm_flush_map(mapname, 1) -#define dm_flush_map_nosync (mapname) _dm_flush_map(mapname, 0) +int _dm_flush_map (const char *,int ,int ); +int dm_flush_map_nopaths (const char * mapname,int deferred_remove); +#define dm_flush_map (mapname) _dm_flush_map(mapname, 1, 0) +#define dm_flush_map_nosync (mapname) _dm_flush_map(mapname, 0, 0) +int dm_cancel_deferred_remove (struct multipath *mpp);int dm_suspend_and_flush_map (const char * mapname);int dm_flush_maps (void );int dm_fail_path (char * mapname,char * path);
@@ -39,7 +41,8 @@ int dm_geteventnr (char *name);int dm_get_major (char *name);int dm_get_minor (char *name);char *dm_mapname (int major,int minor); -int dm_remove_partmaps (const char * mapname,int need_sync); +int dm_remove_partmaps (const char * mapname,int need_sync, +int deferred_remove);int dm_get_uuid (char *name,char *uuid);int dm_get_info (char * mapname,struct dm_info ** dmi);int dm_rename (char * old,char * new);
libmultipath/dict.c +13 -0
@@ -374,6 +374,15 @@ declare_hw_snprint(detect_prio, print_yes_no_undef) declare_def_handler(force_sync, set_yes_no) declare_def_snprint(force_sync, print_yes_no) +declare_def_handler(deferred_remove, set_yes_no_undef) +declare_def_snprint_defint(deferred_remove, print_yes_no_undef, YNU_NO) +declare_ovr_handler(deferred_remove, set_yes_no_undef) +declare_ovr_snprint(deferred_remove, print_yes_no_undef) +declare_hw_handler(deferred_remove, set_yes_no_undef) +declare_hw_snprint(deferred_remove, print_yes_no_undef) +declare_mp_handler(deferred_remove, set_yes_no_undef) +declare_mp_snprint(deferred_remove, print_yes_no_undef) +#define declare_def_attr_handler (option, function) \ static int \ def_ ## option ## _handler (vector strvec) \
@@ -1245,6 +1254,7 @@ init_keywords(void)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 ("force_sync" , &def_force_sync_handler, &snprint_def_force_sync); +install_keyword ("deferred_remove" , &def_deferred_remove_handler, &snprint_def_deferred_remove);install_keyword ("partition_delimiter" , &def_partition_delim_handler, &snprint_def_partition_delim);__deprecated install_keyword ("default_selector" , &def_selector_handler,NULL );__deprecated install_keyword ("default_path_grouping_policy" , &def_pgpolicy_handler,NULL );
@@ -1313,6 +1323,7 @@ init_keywords(void)install_keyword ("user_friendly_names" , &hw_user_friendly_names_handler, &snprint_hw_user_friendly_names);install_keyword ("retain_attached_hw_handler" , &hw_retain_hwhandler_handler, &snprint_hw_retain_hwhandler);install_keyword ("detect_prio" , &hw_detect_prio_handler, &snprint_hw_detect_prio); +install_keyword ("deferred_remove" , &hw_deferred_remove_handler, &snprint_hw_deferred_remove);install_sublevel_end ();install_keyword_root ("overrides" , &overrides_handler);
@@ -1337,6 +1348,7 @@ init_keywords(void)install_keyword ("user_friendly_names" , &ovr_user_friendly_names_handler, &snprint_ovr_user_friendly_names);install_keyword ("retain_attached_hw_handler" , &ovr_retain_hwhandler_handler, &snprint_ovr_retain_hwhandler);install_keyword ("detect_prio" , &ovr_detect_prio_handler, &snprint_ovr_detect_prio); +install_keyword ("deferred_remove" , &ovr_deferred_remove_handler, &snprint_ovr_deferred_remove);install_keyword_root ("multipaths" , &multipaths_handler);install_keyword_multi ("multipath" , &multipath_handler,NULL );
@@ -1360,5 +1372,6 @@ init_keywords(void)install_keyword ("gid" , &mp_gid_handler, &snprint_mp_gid);install_keyword ("reservation_key" , &mp_reservation_key_handler, &snprint_mp_reservation_key);install_keyword ("user_friendly_names" , &mp_user_friendly_names_handler, &snprint_mp_user_friendly_names); +install_keyword ("deferred_remove" , &mp_deferred_remove_handler, &snprint_mp_deferred_remove);install_sublevel_end (); }
libmultipath/propsel.c +26 -0
@@ -590,3 +590,29 @@ out: (pp->detect_prio == DETECT_PRIO_ON)? "yes" : "no", origin);return 0 ; } + +extern int +select_deferred_remove (struct multipath *mp) +{ +char *origin; + +#ifndef LIBDM_API_DEFERRED + mp->deferred_remove =DEFERRED_REMOVE_OFF ; + origin ="(not compiled with support)" ; + goto out; +#endif +if (mp->deferred_remove ==DEFERRED_REMOVE_IN_PROGRESS ) { +condlog (3 ,"%s: deferred remove in progress" , mp->alias); +return 0 ; + } +mp_set_mpe (deferred_remove); +mp_set_ovr (deferred_remove); +mp_set_hwe (deferred_remove); +mp_set_conf (deferred_remove); +mp_set_default (deferred_remove,DEFAULT_DEFERRED_REMOVE ); +out: +condlog (3 ,"%s: deferred_remove = %s %s" , mp->alias, + (mp->deferred_remove ==DEFERRED_REMOVE_ON )?"yes" :"no" , + origin); +return 0 ; +}
libmultipath/propsel.h +1 -0
@@ -19,3 +19,4 @@ int select_dev_loss(struct multipath *mp);int select_reservation_key (struct multipath *mp);int select_retain_hwhandler (struct multipath * mp);int select_detect_prio (struct path * pp); +int select_deferred_remove (struct multipath *mp);
libmultipath/structs.h +8 -0
@@ -120,6 +120,13 @@ enum detect_prio_states { DETECT_PRIO_ON = YNU_YES, }; +enum deferred_remove_states { +DEFERRED_REMOVE_UNDEF =YNU_UNDEF , +DEFERRED_REMOVE_OFF =YNU_NO , +DEFERRED_REMOVE_ON =YNU_YES , +DEFERRED_REMOVE_IN_PROGRESS , +}; +enum scsi_protocol {SCSI_PROTOCOL_FCP =0 ,/* Fibre Channel */ SCSI_PROTOCOL_SPI =1 ,/* parallel SCSI */
@@ -213,6 +220,7 @@ struct multipath {int attribute_flags;int fast_io_fail;int retain_hwhandler; +int deferred_remove;unsigned int dev_loss;uid_t uid;gid_t gid;
libmultipath/structs_vec.c +2 -1
@@ -392,6 +392,8 @@ __setup_multipath (struct vectors * vecs, struct multipath * mpp, int reset)select_pgfailback (mpp);set_no_path_retry (mpp);select_flush_on_last_del (mpp); +if (VECTOR_SIZE (mpp->paths) !=0 ) +dm_cancel_deferred_remove (mpp); }return 0 ;
@@ -564,7 +566,6 @@ int update_multipath (struct vectors *vecs, char *mapname, int reset) } } } -return 0 ; }
multipath/multipath.conf.5 +14 -0
@@ -422,6 +422,16 @@ only one checker will run at a time. This is useful in the case where many multipathd checkers running in parallel causes significant CPU pressure. The Default is .I no +.TP +.B deferred_remove +If set to +.I yes +, multipathd will do a deferred remove instead of a regular remove when the +last path device has been deleted. This means that if the multipath device is +still in use, it will be freed when the last user closes it. If path is added +to the multipath device before the last user closes it, the deferred remove +will be canceled. Default is +.I no . .SH "blacklist section" The
@@ -540,6 +550,8 @@ section: .B features .TP .B reservation_key +.TP +.B deferred_remove .RE .PD .LP
@@ -630,6 +642,8 @@ section: .B retain_attached_hw_handler .TP .B detect_prio +.TP +.B deferred_remove .RE .PD .LP
multipathd/main.c +17 -6
@@ -218,19 +218,30 @@ sync_maps_state(vector mpvec) }static int -flush_map (struct multipath * mpp,struct vectors * vecs) +flush_map (struct multipath * mpp,struct vectors * vecs,int nopaths) { +int r; + +if (nopaths) + r =dm_flush_map_nopaths (mpp->alias, mpp->deferred_remove); +else + r =dm_flush_map (mpp->alias);/* * clear references to this map before flushing so we can ignore * the spurious uevent we may generate with the dm_flush_map call below */ -if (dm_flush_map (mpp->alias)) { +if (r) {/* * May not really be an error -- if the map was already flushed * from the device mapper by dmsetup(8) for instance. */ -condlog (0 ,"%s: can't flush" , mpp->alias); -return 1 ; +if (r ==1 ) +condlog (0 ,"%s: can't flush" , mpp->alias); +else { +condlog (2 ,"%s: devmap deferred remove" , mpp->alias); + mpp->deferred_remove =DEFERRED_REMOVE_IN_PROGRESS ; + } +return r; }else {dm_lib_release ();
@@ -376,7 +387,7 @@ ev_remove_map (char * devname, char * alias, int minor, struct vectors * vecs) mpp->alias, mpp->dmi->minor, minor);return 0 ; } -return flush_map (mpp, vecs); +return flush_map (mpp, vecs,0 ); } static int
@@ -627,7 +638,7 @@ ev_remove_path (struct path *pp, struct vectors * vecs) mpp->flush_on_last_del =FLUSH_IN_PROGRESS ;dm_queue_if_no_path (mpp->alias,0 ); } -if (!flush_map (mpp, vecs)) { +if (!flush_map (mpp, vecs,1 )) {condlog (2 ,"%s: removed map after" " removing all paths" , alias);
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH 7/8 multipathd: don't buffer output with systemd
In reply to Benjamin MarzinskiWhen stdout isn't hooked up to a tty (like it isn't when you start multipathd through systemd) the stream is buffered, so messages only come out in big chunks, or when the program quits. Instead, we should send the messages out to systemd as we generate them, so that users know what's happening, and in the event of a crash, they get the most recent messages.
I realize that there is a performance impact to this. If people are against this approach, we could change condlog to print messages above a certain priority to stderr and messages below that priority to stdout. If we included a configuration option to change the priority level, then we could always change it up if we needed to do debugging. However, the standard level messages are very helpful in quickly diagnosing a number of problems, so you could make a good argument that we always want priority 2 messages printed immediately. And if we intentionally bumped up the debugging level, we would usually want those messages printed immediately. This is exactly what we get with just unbuffering stdout.
--- multipathd/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
multipathd/main.c +4 -2
@@ -2011,9 +2011,11 @@ main (int argc, char *argv[])exit (0 ); } -if (logsink <1 ) +if (logsink <1 ) { +if (!isatty (fileno (stdout))) +setbuf (stdout,NULL ); err =0 ; -else + }else err =daemonize ();if (err <0 )
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH 8/8 libmutipath: allow blanks in device blacklist
In reply to Benjamin MarzinskiAs Brian De Wolf noticed, multipath crashes if you don't have both vendor and product specified in a device blacklist entry. This patch makes device blacklists work when either the vendor or the product is blank. If both are missing, the entry is ignored.
--- libmultipath/blacklist.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
libmultipath/blacklist.c +12 -4
@@ -135,8 +135,12 @@ _blacklist_exceptions_device(vector elist, char * vendor, char * product)struct blentry_device * ble; vector_foreach_slot (elist, ble, i) { -if (!regexec (&ble->vendor_reg, vendor,0 ,NULL ,0 ) && - !regexec (&ble->product_reg, product,0 ,NULL ,0 )) +if (!ble->vendor && !ble->product) +continue ; +if ((!ble->vendor || + !regexec (&ble->vendor_reg, vendor,0 ,NULL ,0 )) && + (!ble->product || + !regexec (&ble->product_reg, product,0 ,NULL ,0 )))return 1 ; }return 0 ;
@@ -149,8 +153,12 @@ _blacklist_device (vector blist, char * vendor, char * product)struct blentry_device * ble; vector_foreach_slot (blist, ble, i) { -if (!regexec (&ble->vendor_reg, vendor,0 ,NULL ,0 ) && - !regexec (&ble->product_reg, product,0 ,NULL ,0 )) +if (!ble->vendor && !ble->product) +continue ; +if ((!ble->vendor || + !regexec (&ble->vendor_reg, vendor,0 ,NULL ,0 )) && + (!ble->product || + !regexec (&ble->product_reg, product,0 ,NULL ,0 )))return 1 ; }return 0 ;
Signature · 1 line
1.8.3.1