Two multipath features.
Benjamin Marzinski
maintainerv2 cover Two multipath features.
This patchset implements two features that I had requests for. The first commit adds the ability for multipath to control the scsi max_retries sysfs setting. This is useful for instances where a path hangs when attempting IO, but the path checker completes successfully. It allows the multipath device to fail quicker. When it's used like this it needs to be paired with the shaky path detection options, since multipathd will restore the path on the next checker run.
The rest of the patches add the auto_resize option. This option allows users to control when multipathd will automatically resize a device, if it sees that all of its path devices have been resized. By default it is set to "never" and multipath behaves like it always has, where users need to manually resize multipath devices after all the paths have been resized.
Differences from v1 (all from suggestions by Martin Wilck):
1/7: make the option default section only. used max_retries specific
enums, and clarified man page entry.
3/7: Assume path size hasn't changed if we fail to get it from sysfs. 6/7: make the option default section only. removed "multipath -r"
mention in man page. Fixed whitespace issue
7/7: removed
Benjamin Marzinski (6):
libmultipath: Add max_retries config option
libmutipath: Retain device size if sysfs_get_size fails.
multipathd: check and update all paths when in cli_resize
multipathd: move post-reloading commands into resize_map()
multipathd: move resize_map() to multipathd/main.c
multipathd: Add auto_resize config option
libmultipath/config.h | 2 ++ libmultipath/defaults.h | 1 + libmultipath/dict.c | 63 +++++++++++++++++++++++++++++++++ libmultipath/dict.h | 1 + libmultipath/discovery.c | 41 +++++++++++++++++++++- libmultipath/structs.h | 13 +++++++ libmultipath/sysfs.c | 1 - multipath/multipath.conf.5.in | 29 +++++++++++++++ multipathd/cli_handlers.c | 66 ++++++++++++----------------------- multipathd/main.c | 57 ++++++++++++++++++++++++++++++ multipathd/main.h | 2 ++ 11 files changed, 230 insertions(+), 46 deletions(-)
Signature · 1 line
2.41.0
Benjamin Marzinski
maintainerPATCH v2 1/6 libmultipath: Add max_retries config option
This option lets multipath set a scsi disk's max_retries sysfs value. Setting this can be helpful for cases where the path checker succeeds, but IO commands hang and timeout. By default, the SCSI layer will retry IOs 5 times. Reducing this value will allow multipath to retry the IO down another path sooner.
--- libmultipath/config.h | 1 + libmultipath/dict.c | 25 +++++++++++++++++++++ libmultipath/discovery.c | 41 ++++++++++++++++++++++++++++++++++- libmultipath/structs.h | 6 +++++ multipath/multipath.conf.5.in | 14 ++++++++++++ 5 files changed, 86 insertions(+), 1 deletion(-)
libmultipath/config.h +1 -0
@@ -162,6 +162,7 @@ struct config {int fast_io_fail;unsigned int dev_loss;int eh_deadline; +int max_retries;int log_checker_err;int allow_queueing;int allow_usb_devices;
libmultipath/dict.c +25 -0
@@ -1152,6 +1152,30 @@ declare_hw_snprint(eh_deadline, print_undef_off_zero) declare_pc_handler(eh_deadline, set_undef_off_zero) declare_pc_snprint(eh_deadline, print_undef_off_zero) +static int +def_max_retries_handler (struct config *conf,vector strvec,const char *file, +int line_nr) +{ +char * buff; + + buff =set_value (strvec); +if (!buff) +return 1 ; + +if (strcmp (buff,"off" ) ==0 ) + conf->max_retries =MAX_RETRIES_OFF ; +else if (strcmp (buff,"0" ) ==0 ) + conf->max_retries =MAX_RETRIES_ZERO ; +else +do_set_int (strvec, &conf->max_retries,1 ,5 , file, line_nr, + buff); + +free (buff); +return 0 ; +} + +declare_def_snprint(max_retries, print_undef_off_zero) +static int set_pgpolicy (vector strvec,void *ptr,const char *file,int line_nr) {
@@ -2079,6 +2103,7 @@ init_keywords(vector keywords)install_keyword ("fast_io_fail_tmo" , &def_fast_io_fail_handler, &snprint_def_fast_io_fail);install_keyword ("dev_loss_tmo" , &def_dev_loss_handler, &snprint_def_dev_loss);install_keyword ("eh_deadline" , &def_eh_deadline_handler, &snprint_def_eh_deadline); +install_keyword ("max_retries" , &def_max_retries_handler, &snprint_def_max_retries);install_keyword ("bindings_file" , &deprecated_bindings_file_handler, &snprint_deprecated);install_keyword ("wwids_file" , &deprecated_wwids_file_handler, &snprint_deprecated);install_keyword ("prkeys_file" , &deprecated_prkeys_file_handler, &snprint_deprecated);
libmultipath/discovery.c +40 -1
59 lines not on this page · raw message
libmultipath/structs.h +6 -0
@@ -295,6 +295,12 @@ enum eh_deadline_states { EH_DEADLINE_ZERO = UOZ_ZERO, }; +enum max_retries_states { +MAX_RETRIES_UNSET =UOZ_UNDEF , +MAX_RETRIES_OFF =UOZ_OFF , +MAX_RETRIES_ZERO =UOZ_ZERO , +}; +enum recheck_wwid_states {RECHECK_WWID_UNDEF =YNU_UNDEF ,RECHECK_WWID_OFF =YNU_NO ,
multipath/multipath.conf.5.in +14 -0
@@ -793,6 +793,20 @@ The default is: \fB<unset>\fR . . .TP +.B max_retries +Specify the maximum number of times the SCSI layer will retry IO commands for +some types of SCSI errors before returning failure. Setting this can be helpful +for cases where IO commands hang and timeout. By default, the SCSI layer will +retry IOs 5 times. Reducing this value will allow multipath to retry the IO +down another path sooner. Valid values are +\fB0\fR through \fB5\fR. +.RS +.TP +The default is: \fB<unset>\fR +.RE +. +. +.TP .B bindings_file (Deprecated) This option is not supported any more, and will be ignored. .RS
Signature · 1 line
2.41.0
Re: [PATCH v2 1/6] libmultipath: Add max_retries config option
Quoted 9 lines · Benjamin Marzinski
This option lets multipath set a scsi disk's
max_retriessysfs value. Setting this can be helpful for cases where the path checker succeeds,
but IO commands hang and timeout. By default, the SCSI layer will retry
IOs 5 times. Reducing this value will allow multipath to retry the IO down another path sooner.Signed-off-by Benjamin Marzinski <[email protected]>
Benjamin Marzinski
maintainerPATCH v2 2/6 libmutipath: Retain device size if sysfs_get_size fails.
In reply to Benjamin MarzinskiWhen paths are allocated their size is initialized to 0. If they've already set a size, and a future call to sysfs_get_size() fails during the parsing, assume that the size hasn't changed, instead of setting it to 0. All other failures in sysfs_get_size() already retain the existing size.
--- libmultipath/sysfs.c | 1 - 1 file changed, 1 deletion(-)
libmultipath/sysfs.c +0 -1
@@ -175,7 +175,6 @@ sysfs_get_size (struct path *pp, unsigned long long * size)if (r !=1 ) {condlog (3 ,"%s: Cannot parse size attribute" , pp->dev); - *size =0 ;return 1 ; }
Signature · 1 line
2.41.0
Benjamin Marzinski
maintainerPATCH v2 3/6 multipathd: check and update all paths when in cli_resize
In reply to Benjamin MarzinskiWhen resizing a multipath device, make sure that all the paths have been updated to the new size first.
--- multipathd/cli_handlers.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
multipathd/cli_handlers.c +18 -13
@@ -845,9 +845,11 @@ cli_resize(void *v, struct strbuf *reply, void *data)char * mapname =get_keyparam (v,KEY_MAP );struct multipath *mpp;int minor; -unsigned long long size; +unsigned long long size =0 ;struct pathgroup *pgp;struct path *pp; +unsigned int i, j; +bool mismatch = false; mapname =convert_dev (mapname,0 );condlog (2 ,"%s: resize map (operator)" , mapname);
@@ -867,21 +869,24 @@ cli_resize(void *v, struct strbuf *reply, void *data)return 1 ; } - pgp =VECTOR_SLOT (mpp->pg,0 ); - -if (!pgp){ -condlog (0 ,"%s: couldn't get path group. cannot resize" , - mapname); -return 1 ; + vector_foreach_slot(mpp->pg, pgp, i) { + vector_foreach_slot (pgp->paths, pp, j) { +sysfs_get_size (pp, &pp->size); +if (!pp->size) +continue ; +if (!size) + size = pp->size; +else if (pp->size != size) + mismatch = true; + } } - pp =VECTOR_SLOT (pgp->paths,0 ); - -if (!pp){ -condlog (0 ,"%s: couldn't get path. cannot resize" , mapname); +if (!size) { +condlog (0 ,"%s: couldn't get size from sysfs. cannot resize" , + mapname);return 1 ; } -if (!pp->udev ||sysfs_get_size (pp, &size)) { -condlog (0 ,"%s: couldn't get size for sysfs. cannot resize" , +if (mismatch) { +condlog (0 ,"%s: path size not consistent. cannot resize" , mapname);return 1 ; }
Signature · 1 line
2.41.0
Re: [PATCH v2 3/6] multipathd: check and update all paths when in cli_resize
Quoted 4 lines · Benjamin Marzinski
When resizing a multipath device, make sure that all the paths have been updated to the new size first.
Signed-off-by Benjamin Marzinski <[email protected]>
Benjamin Marzinski
maintainerPATCH v2 4/6 multipathd: move post-reloading commands into resize_map()
In reply to Benjamin MarzinskiIn preparation for reusing resize_map() in other code, move all code necessary to resize the map to the resize_map() function. Also track if map was removed in the function.
--- multipathd/cli_handlers.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
multipathd/cli_handlers.c +9 -7
@@ -835,6 +835,10 @@ static int resize_map(struct multipath *mpp, unsigned long long size, mpp->size = orig_size;return 1 ; } +if (setup_multipath (vecs, mpp) !=0 ) +return 2 ; +sync_map_state (mpp); +return 0 ; }
@@ -848,7 +852,7 @@ cli_resize(void *v, struct strbuf *reply, void *data)unsigned long long size =0 ;struct pathgroup *pgp;struct path *pp; -unsigned int i, j; +unsigned int i, j, ret;bool mismatch = false; mapname =convert_dev (mapname,0 );
@@ -898,14 +902,12 @@ cli_resize(void *v, struct strbuf *reply, void *data)condlog (3 ,"%s old size is %llu, new size is %llu" , mapname, mpp->size, size); -if (resize_map (mpp, size, vecs) !=0 ) -return 1 ; + ret =resize_map (mpp, size, vecs); -if (setup_multipath (vecs, mpp) !=0 ) -return 1 ; -sync_map_state (mpp); +if (ret ==2 ) +condlog (0 ,"%s: map removed while trying to resize" , mapname); -return 0 ; +return (ret !=0 ); } static int
Signature · 1 line
2.41.0
Benjamin Marzinski
maintainerPATCH v2 5/6 multipathd: move resize_map() to multipathd/main.c
In reply to Benjamin MarzinskiNo functional changes.
--- multipathd/cli_handlers.c | 29 ----------------------------- multipathd/main.c | 29 +++++++++++++++++++++++++++++ multipathd/main.h | 2 ++ 3 files changed, 31 insertions(+), 29 deletions(-)
multipathd/cli_handlers.c +0 -29
@@ -813,35 +813,6 @@ cli_reload(void *v, struct strbuf *reply, void *data)return reload_and_sync_map (mpp, vecs); } -static int resize_map (struct multipath *mpp,unsigned long long size, -struct vectors * vecs) -{ - char *params __attribute__((cleanup(cleanup_charp))) = NULL; -unsigned long long orig_size = mpp->size; - - mpp->size = size; -update_mpp_paths (mpp, vecs->pathvec); -if (setup_map (mpp, ¶ms, vecs) !=0 ) { -condlog (0 ,"%s: failed to setup map for resize : %s" , - mpp->alias,strerror (errno)); - mpp->size = orig_size; -return 1 ; - } - mpp->action =ACT_RESIZE ; - mpp->force_udev_reload =1 ; -if (domap (mpp, params,1 ) ==DOMAP_FAIL ) { -condlog (0 ,"%s: failed to resize map : %s" , mpp->alias, -strerror (errno)); - mpp->size = orig_size; -return 1 ; - } -if (setup_multipath (vecs, mpp) !=0 ) -return 2 ; -sync_map_state (mpp); - -return 0 ; -} -static int cli_resize (void *v,struct strbuf *reply,void *data) {
multipathd/main.c +29 -0
@@ -1530,6 +1530,35 @@ needs_ro_update(struct multipath *mpp, int ro)return true; } +int resize_map (struct multipath *mpp,unsigned long long size, +struct vectors * vecs) +{ + char *params __attribute__((cleanup(cleanup_charp))) = NULL; +unsigned long long orig_size = mpp->size; + + mpp->size = size; +update_mpp_paths (mpp, vecs->pathvec); +if (setup_map (mpp, ¶ms, vecs) !=0 ) { +condlog (0 ,"%s: failed to setup map for resize : %s" , + mpp->alias,strerror (errno)); + mpp->size = orig_size; +return 1 ; + } + mpp->action =ACT_RESIZE ; + mpp->force_udev_reload =1 ; +if (domap (mpp, params,1 ) ==DOMAP_FAIL ) { +condlog (0 ,"%s: failed to resize map : %s" , mpp->alias, +strerror (errno)); + mpp->size = orig_size; +return 1 ; + } +if (setup_multipath (vecs, mpp) !=0 ) +return 2 ; +sync_map_state (mpp); + +return 0 ; +} +static int uev_update_path (struct uevent *uev,struct vectors * vecs) {
multipathd/main.h +2 -0
@@ -52,4 +52,6 @@ int reload_and_sync_map(struct multipath *mpp, struct vectors *vecs);void handle_path_wwid_change (struct path *pp,struct vectors *vecs);bool check_path_wwid_change (struct path *pp);int finish_path_init (struct path *pp,struct vectors * vecs); +int resize_map (struct multipath *mpp,unsigned long long size, +struct vectors *vecs);#endif /* MAIN_H */
Signature · 1 line
2.41.0
Benjamin Marzinski
maintainerPATCH v2 6/6 multipathd: Add auto_resize config option
In reply to Benjamin MarzinskiThis option gives multipathd the ability to automatically resize a device when it detects that all of the path devices have changed. By default it is set to never, and multipathd will continue to work like it always has, where a users must manually resize a multipath device.
--- libmultipath/config.h | 1 + libmultipath/defaults.h | 1 + libmultipath/dict.c | 38 +++++++++++++++++++++++++++++++++++ libmultipath/dict.h | 1 + libmultipath/structs.h | 7 +++++++ multipath/multipath.conf.5.in | 15 ++++++++++++++ multipathd/main.c | 28 ++++++++++++++++++++++++++ 7 files changed, 91 insertions(+)
libmultipath/config.h +1 -0
@@ -202,6 +202,7 @@ struct config {int skip_delegate;unsigned int sequence_nr;int recheck_wwid; +int auto_resize;char * selector;struct _vector uid_attrs;
libmultipath/defaults.h +1 -0
@@ -56,6 +56,7 @@#define DEFAULT_UNKNOWN_FIND_MULTIPATHS_TIMEOUT 1#define DEFAULT_ALL_TG_PT ALL_TG_PT_OFF#define DEFAULT_RECHECK_WWID RECHECK_WWID_OFF +#define DEFAULT_AUTO_RESIZE AUTO_RESIZE_NEVER/* Enable no foreign libraries by default */ #define DEFAULT_ENABLE_FOREIGN "NONE"
libmultipath/dict.c +38 -0
@@ -1664,6 +1664,43 @@ declare_hw_snprint(recheck_wwid, print_yes_no_undef) declare_def_range_handler(uxsock_timeout, DEFAULT_REPLY_TIMEOUT, INT_MAX) +static int +def_auto_resize_handler (struct config *conf,vector strvec,const char *file, +int line_nr) +{ +char * buff; + + buff =set_value (strvec); +if (!buff) +return 1 ; + +if (strcmp (buff,"never" ) ==0 ) + conf->auto_resize =AUTO_RESIZE_NEVER ; +else if (strcmp (buff,"grow_only" ) ==0 ) + conf->auto_resize =AUTO_RESIZE_GROW_ONLY ; +else if (strcmp (buff,"grow_shrink" ) ==0 ) + conf->auto_resize =AUTO_RESIZE_GROW_SHRINK ; +else +condlog (1 ,"%s line %d, invalid value for auto_resize: \"%s\"" , + file, line_nr, buff); + +free (buff); +return 0 ; +} + +int +print_auto_resize (struct strbuf *buff,long v) +{ +if (!v) +return 0 ; +return append_strbuf_quoted (buff, + v ==AUTO_RESIZE_GROW_ONLY ?"grow_only" : + v ==AUTO_RESIZE_GROW_SHRINK ?"grow_shrink" : +"never" ); +} + +declare_def_snprint(auto_resize, print_auto_resize) +static int hw_vpd_vendor_handler (struct config *conf,vector strvec,const char *file,int line_nr)
@@ -2140,6 +2177,7 @@ init_keywords(vector keywords)install_keyword ("remove_retries" , &def_remove_retries_handler, &snprint_def_remove_retries);install_keyword ("max_sectors_kb" , &def_max_sectors_kb_handler, &snprint_def_max_sectors_kb);install_keyword ("ghost_delay" , &def_ghost_delay_handler, &snprint_def_ghost_delay); +install_keyword ("auto_resize" , &def_auto_resize_handler, &snprint_def_auto_resize);install_keyword ("find_multipaths_timeout" , &def_find_multipaths_timeout_handler, &snprint_def_find_multipaths_timeout);
libmultipath/dict.h +1 -0
@@ -17,4 +17,5 @@ int print_no_path_retry(struct strbuf *buff, long v);int print_undef_off_zero (struct strbuf *buff,long v);int print_dev_loss (struct strbuf *buff,unsigned long v);int print_off_int_undef (struct strbuf *buff,long v); +int print_auto_resize (struct strbuf *buff,long v);#endif /* _DICT_H */
libmultipath/structs.h +7 -0
@@ -179,6 +179,13 @@ enum queue_mode_states { QUEUE_MODE_RQ, }; +enum auto_resize_state { +AUTO_RESIZE_UNDEF =0 , +AUTO_RESIZE_NEVER , +AUTO_RESIZE_GROW_ONLY , +AUTO_RESIZE_GROW_SHRINK , +}; +#define PROTOCOL_UNSET -1enum scsi_protocol {
multipath/multipath.conf.5.in +15 -0
@@ -1331,6 +1331,21 @@ The default is: \fBno\fR . . .TP +.B auto_resize +Controls when multipathd will automatically resize a multipath device. If set +to \fInever\fR, multipath devices must always be manually resized by either +running \fBmultipathd resize map <name>\fR. If set to \fIgrow_only\fR, when +multipathd detects that all of a multipath device's paths have increased in +size, it will automatically grow the multipath device to the new size. If set +to \fIgrow_shrink\fR, multipathd will also automatically shrink the device +once it detects all of its paths have decreased in size. +.RS +.TP +The default is: \fBnever\fR +.RE +. +. +.TP .B enable_foreign Enables or disables foreign libraries (see section .I FOREIGN MULTIPATH SUPPORT
multipathd/main.c +28 -0
@@ -1590,6 +1590,11 @@ uev_update_path (struct uevent *uev, struct vectors * vecs)if (pp) {struct multipath *mpp = pp->mpp;char wwid[WWID_SIZE ]; +int auto_resize; + + conf =get_multipath_config (); + auto_resize = conf->auto_resize; +put_multipath_config (conf);if (pp->initialized ==INIT_REQUESTED_UDEV ) { needs_reinit =1 ;
@@ -1648,6 +1653,29 @@ uev_update_path (struct uevent *uev, struct vectors * vecs) } } } +if (auto_resize !=AUTO_RESIZE_NEVER && + !mpp->wait_for_udev) { +struct pathgroup *pgp; +struct path *pp2; +unsigned int i, j; +unsigned long long orig_size = mpp->size; + +if (!pp->size || pp->size == mpp->size || + (pp->size < mpp->size && + auto_resize ==AUTO_RESIZE_GROW_ONLY )) + goto out; + + vector_foreach_slot(mpp->pg, pgp, i) + vector_foreach_slot (pgp->paths, pp2, j) +if (pp2->size && pp2->size != pp->size) + goto out; + retval =resize_map (mpp, pp->size, vecs); +if (retval ==2 ) +condlog (2 ,"%s: map removed during resize" , pp->dev); +else if (retval ==0 ) +condlog (2 ,"%s: resized map from %llu to %llu" , + mpp->alias, orig_size, pp->size); + } } out:lock_cleanup_pop (vecs->lock);
Signature · 1 line
2.41.0
Re: [PATCH v2 6/6] multipathd: Add auto_resize config option
Quoted 7 lines · Benjamin Marzinski
This option gives multipathd the ability to automatically resize a device when it detects that all of the path devices have changed. By default it is set to never, and multipathd will continue to work like it
always has, where a users must manually resize a multipath device.Signed-off-by Benjamin Marzinski <[email protected]>