From bb5a54b79a414082d0b39d478a8b3332c56d68e5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 26 Mar 2017 15:12:11 +0300 Subject: [block] Add basic multipath support Add basic support for multipath block devices. The "sanboot" and "sanhook" commands now accept a list of SAN URIs. We open all URIs concurrently. The first connection to become available for issuing block device commands is marked as the active path and used for all subsequent commands; all other connections are then closed. Whenever the active path fails, we reopen all URIs and repeat the process. Signed-off-by: Michael Brown --- src/hci/commands/sanboot_cmd.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/hci') diff --git a/src/hci/commands/sanboot_cmd.c b/src/hci/commands/sanboot_cmd.c index 24ec8bc4..9965ec15 100644 --- a/src/hci/commands/sanboot_cmd.c +++ b/src/hci/commands/sanboot_cmd.c @@ -71,12 +71,12 @@ static union { /** "sanhook" command descriptor */ static struct command_descriptor sanhook_cmd = - COMMAND_DESC ( struct sanboot_options, opts.sanhook, 1, 1, + COMMAND_DESC ( struct sanboot_options, opts.sanhook, 1, MAX_ARGUMENTS, "" ); /** "sanboot" command descriptor */ static struct command_descriptor sanboot_cmd = - COMMAND_DESC ( struct sanboot_options, opts.sanboot, 0, 1, + COMMAND_DESC ( struct sanboot_options, opts.sanboot, 0, MAX_ARGUMENTS, "[]" ); /** "sanunhook" command descriptor */ @@ -96,9 +96,10 @@ static int sanboot_core_exec ( int argc, char **argv, struct command_descriptor *cmd, int default_flags, int no_root_path_flags ) { struct sanboot_options opts; - const char *root_path; - struct uri *uri; + struct uri *uris[argc]; + int count; int flags; + int i; int rc; /* Initialise options */ @@ -109,17 +110,14 @@ static int sanboot_core_exec ( int argc, char **argv, if ( ( rc = reparse_options ( argc, argv, cmd, &opts ) ) != 0 ) goto err_parse_options; - /* Parse root path, if present */ - if ( argc > optind ) { - root_path = argv[optind]; - uri = parse_uri ( root_path ); - if ( ! uri ) { + /* Parse root paths, if present */ + count = ( argc - optind ); + for ( i = 0 ; i < count ; i++ ) { + uris[i] = parse_uri ( argv[ optind + i ] ); + if ( ! uris[i] ) { rc = -ENOMEM; goto err_parse_uri; } - } else { - root_path = NULL; - uri = NULL; } /* Construct flags */ @@ -128,16 +126,18 @@ static int sanboot_core_exec ( int argc, char **argv, flags |= URIBOOT_NO_SAN_DESCRIBE; if ( opts.keep ) flags |= URIBOOT_NO_SAN_UNHOOK; - if ( ! root_path ) + if ( ! count ) flags |= no_root_path_flags; /* Boot from root path */ - if ( ( rc = uriboot ( NULL, uri, opts.drive, flags ) ) != 0 ) + if ( ( rc = uriboot ( NULL, uris, count, opts.drive, flags ) ) != 0 ) goto err_uriboot; err_uriboot: - uri_put ( uri ); + i = count; err_parse_uri: + for ( i-- ; i >= 0 ; i-- ) + uri_put ( uris[i] ); err_parse_options: return rc; } -- cgit v1.2.3-55-g7522