diff options
author | Lee Duncan <leeman.duncan@gmail.com> | 2020-08-15 13:08:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-15 13:08:07 -0700 |
commit | f6f2316f15d2c21a8fb777d86aacca10bc703b40 (patch) | |
tree | 4722bba4e44d9b422b7e5b01101aadc9d43d3977 | |
parent | 802688debcd88c48edabe86deb7e7ed47ebadc26 (diff) | |
parent | 46183ffd36c9c2a6a1e67383c639897c572acad1 (diff) | |
download | open-iscsi-f6f2316f15d2c21a8fb777d86aacca10bc703b40.tar.gz |
Merge pull request #218 from gonzoleeman/async-login-v2
Add ability to attempt target logins asynchronously
-rw-r--r-- | doc/iscsiadm.8 | 10 | ||||
-rw-r--r-- | usr/iscsiadm.c | 35 |
2 files changed, 30 insertions, 15 deletions
diff --git a/doc/iscsiadm.8 b/doc/iscsiadm.8 index bf23dd2..22263eb 100644 --- a/doc/iscsiadm.8 +++ b/doc/iscsiadm.8 @@ -51,6 +51,7 @@ iscsiadm \- open-iscsi administration utility .IR printlevel ] .RB [ \-L .IR all,manual,automatic,onboot ] +.RB [ \-W ] .RB [ \-U .IR all,manual,automatic,onboot ] .RB [ \-S ] @@ -292,7 +293,14 @@ in or all running session, except ones marked onboot, if all is passed in. This option is only valid for node mode (it is valid but not functional for session mode). .TP -\fB\-m, \-\-mode \fIop\fR +\fB\-W\fR, \fB\-\-\-no_wait\fR +In node mode, when logging in to one or more targets using the +\fB\-\-loginall\fR option, do not wait for a response from the targets. +This means that success will be returned if the command is able to +send the login requests, whether or not they succeed. In this case, it will +be up to the caller to poll for success (i.e. session creation). +.TP +\fB\-m\fR, \fB\-\-mode \fIop\fR specify the mode. \fIop\fR must be one of \fIdiscovery\fR, \fIdiscoverydb\fR, \fInode\fR, \fIfw\fR, \fIhost\fR \fIiface\fR or \fIsession\fR. diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c index f2bd721..336801c 100644 --- a/usr/iscsiadm.c +++ b/usr/iscsiadm.c @@ -133,9 +133,10 @@ static struct option const long_options[] = {"interval", required_argument, NULL, 'i'}, {"index", required_argument, NULL, 'x'}, {"portal_type", optional_argument, NULL, 'A'}, + {"no_wait", no_argument, NULL, 'W'}, {NULL, 0, NULL, 0}, }; -static char *short_options = "RlDVhm:a:b:c:C:p:P:T:H:i:I:U:k:L:d:r:n:v:o:sSt:ux:A:"; +static char *short_options = "RlDVhm:a:b:c:C:p:P:T:H:i:I:U:k:L:d:r:n:v:o:sSt:ux:A:W"; static void usage(int status) { @@ -144,15 +145,15 @@ static void usage(int status) program_name); else { printf("\ -iscsiadm -m discoverydb [ -hV ] [ -d debug_level ] [-P printlevel] [ -t type -p ip:port -I ifaceN ... [ -Dl ] ] | [ [ -p ip:port -t type] \ -[ -o operation ] [ -n name ] [ -v value ] [ -lD ] ] \n\ -iscsiadm -m discovery [ -hV ] [ -d debug_level ] [-P printlevel] [ -t type -p ip:port -I ifaceN ... [ -l ] ] | [ [ -p ip:port ] [ -l | -D ] ] \n\ -iscsiadm -m node [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -L all,manual,automatic ] [ -U all,manual,automatic ] [ -S ] [ [ -T targetname -p ip:port -I ifaceN ] [ -l | -u | -R | -s] ] \ -[ [ -o operation ] [ -n name ] [ -v value ] ]\n\ -iscsiadm -m session [ -hV ] [ -d debug_level ] [ -P printlevel] [ -r sessionid | sysfsdir [ -R | -u | -s ] [ -o operation ] [ -n name ] [ -v value ] ]\n\ -iscsiadm -m iface [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -I ifacename | -H hostno|MAC ] [ [ -o operation ] [ -n name ] [ -v value ] ] [ -C ping [ -a ip ] [ -b packetsize ] [ -c count ] [ -i interval ] ]\n\ -iscsiadm -m fw [ -d debug_level ] [ -l ]\n\ -iscsiadm -m host [ -P printlevel ] [ -H hostno|MAC ] [ [ -C chap [ -x chap_tbl_idx ] ] | [ -C flashnode [ -A portal_type ] [ -x flashnode_idx ] ] | [ -C stats ] ] [ [ -o operation ] [ -n name ] [ -v value ] ] \n\ +iscsiadm -m discoverydb [-hV] [-d debug_level] [-P printlevel] [-t type -p ip:port -I ifaceN ... [-Dl]] | [[-p ip:port -t type] \ +[-o operation] [-n name] [-v value] [-lD]] \n\ +iscsiadm -m discovery [-hV] [-d debug_level] [-P printlevel] [-t type -p ip:port -I ifaceN ... [-l]] | [[-p ip:port] [-l | -D]] \n\ +iscsiadm -m node [-hV] [-d debug_level] [-P printlevel] [-L all,manual,automatic,onboot] [-W] [-U all,manual,automatic,onboot] [-S] [[-T targetname -p ip:port -I ifaceN] [-l | -u | -R | -s]] \ +[[-o operation ] [-n name] [-v value]]\n\ +iscsiadm -m session [-hV] [-d debug_level] [-P printlevel] [-r sessionid | sysfsdir [-R | -u | -s] [-o operation] [-n name] [-v value]]\n\ +iscsiadm -m iface [-hV] [-d debug_level] [-P printlevel] [-I ifacename | -H hostno|MAC] [[-o operation ] [-n name] [-v value]] [-C ping [-a ip] [-b packetsize] [-c count] [-i interval]]\n\ +iscsiadm -m fw [-d debug_level] [-l]\n\ +iscsiadm -m host [-P printlevel] [-H hostno|MAC] [[-C chap [-x chap_tbl_idx]] | [-C flashnode [-A portal_type] [-x flashnode_idx]] | [-C stats]] [[-o operation] [-n name] [-v value]] \n\ iscsiadm -k priority\n"); } exit(status); @@ -452,6 +453,8 @@ __do_leading_login(void *data, struct list_head *list, struct node_rec *rec) struct iface_rec *pattern_iface = data; int nr_found; + log_debug(1, "doing leading login using iface: %s", pattern_iface->name); + /* Skip any records that do not match the pattern iface */ if (!iface_match(pattern_iface, &rec->iface)) return -1; @@ -471,7 +474,7 @@ __do_leading_login(void *data, struct list_head *list, struct node_rec *rec) } static int -login_by_startup(char *mode) +login_by_startup(char *mode, bool wait) { int nr_found = 0, err, rc; struct startup_data startup; @@ -512,7 +515,7 @@ login_by_startup(char *mode) if (!list_empty(&startup.all_logins)) { log_debug(1, "Logging into normal (non-leading-login) portals"); /* Login all regular (non-leading-login) portals first */ - err = iscsi_login_portals(NULL, &nr_found, 1, + err = iscsi_login_portals(NULL, &nr_found, wait, &startup.all_logins, iscsi_login_portal); if (err) log_error("Could not log into all portals"); @@ -3559,6 +3562,7 @@ main(int argc, char **argv) struct iscsi_session **ses = NULL; uint32_t se_count = 0; struct iscsi_session *se = NULL; + bool wait = true; ctx = iscsi_context_new(); if (ctx == NULL) { @@ -3728,6 +3732,9 @@ main(int argc, char **argv) case 'A': portal_type = str_to_portal_type(optarg); break; + case 'W': + wait = false; + break; case 'h': usage(0); } @@ -3900,7 +3907,7 @@ main(int argc, char **argv) do_show); break; case MODE_NODE: - if ((rc = verify_mode_params(argc, argv, "RsPIdmlSonvupTUL", + if ((rc = verify_mode_params(argc, argv, "RsPIdmlSonvupTULW", 0))) { log_error("node mode: option '-%c' is not " "allowed/supported", rc); @@ -3909,7 +3916,7 @@ main(int argc, char **argv) } if (do_login_all) { - rc = login_by_startup(group_session_mgmt_mode); + rc = login_by_startup(group_session_mgmt_mode, wait); goto out; } |