[dm-devel] [PATCH 3/3] multipath: optimize program startup for frequent invocations

Benjamin Marzinski bmarzins at redhat.com
Tue Aug 23 21:53:41 UTC 2022


On Thu, Aug 18, 2022 at 11:06:30PM +0200, mwilck at suse.com wrote:
> From: Martin Wilck <mwilck at suse.com>
> 
> Neither "multipath -u" nor "multipath -U" need initialization of the
> prioritizers, checkers, and foreign libraries. Also, these commands
> need not fail if the bindings file is inconsistent. Move these
> possibly slow initialization steps after these special command
> invocations.
> 
> Signed-off-by: Martin Wilck <mwilck at suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins at redhat.com>
> ---
>  multipath/main.c | 33 +++++++++++++++++----------------
>  1 file changed, 17 insertions(+), 16 deletions(-)
> 
> diff --git a/multipath/main.c b/multipath/main.c
> index 034dd2f..8e5154a 100644
> --- a/multipath/main.c
> +++ b/multipath/main.c
> @@ -957,11 +957,6 @@ main (int argc, char *argv[])
>  		exit(RTVL_FAIL);
>  	}
>  
> -	if (check_alias_settings(conf)) {
> -		fprintf(stderr, "fatal configuration error, aborting");
> -		exit(RTVL_FAIL);
> -	}
> -
>  	if (optind < argc) {
>  		dev = calloc(1, FILE_NAME_SIZE);
>  
> @@ -988,20 +983,9 @@ main (int argc, char *argv[])
>  
>  	libmp_udev_set_sync_support(1);
>  
> -	if (init_checkers()) {
> -		condlog(0, "failed to initialize checkers");
> -		goto out;
> -	}
> -	if (init_prio()) {
> -		condlog(0, "failed to initialize prioritizers");
> -		goto out;
> -	}
> -
>  	if ((cmd == CMD_LIST_SHORT || cmd == CMD_LIST_LONG) && enable_foreign)
>  		conf->enable_foreign = strdup("");
>  
> -	/* Failing here is non-fatal */
> -	init_foreign(conf->enable_foreign);
>  	if (cmd == CMD_USABLE_PATHS) {
>  		r = check_usable_paths(conf, dev, dev_type) ?
>  			RTVL_FAIL : RTVL_OK;
> @@ -1036,6 +1020,23 @@ main (int argc, char *argv[])
>  		break;
>  	}
>  
> +	if (check_alias_settings(conf)) {
> +		fprintf(stderr, "fatal configuration error, aborting");
> +		exit(RTVL_FAIL);
> +	}
> +
> +	if (init_checkers()) {
> +		condlog(0, "failed to initialize checkers");
> +		goto out;
> +	}
> +	if (init_prio()) {
> +		condlog(0, "failed to initialize prioritizers");
> +		goto out;
> +	}
> +
> +	/* Failing here is non-fatal */
> +	init_foreign(conf->enable_foreign);
> +
>  	if (cmd == CMD_RESET_WWIDS) {
>  		struct multipath * mpp;
>  		int i;
> -- 
> 2.37.1


More information about the dm-devel mailing list