From fe265aef9c92d7f7f3d6afacd96e2d62ce224c6c Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Thu, 26 Mar 2015 10:48:01 +0100 Subject: [PATCH] connect: allow to avoid the testunit ready call in iscsi_full_connect_async iscsi-ls show luns command does not work when the target redirects at login. to avoid redundant code allow iscsi_full_connect_async to skip the testunit ready part. Signed-off-by: Peter Lieven --- aros/iscsi-ls.c | 9 ++------- lib/connect.c | 12 ++++++++---- utils/iscsi-ls.c | 9 ++------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/aros/iscsi-ls.c b/aros/iscsi-ls.c index 7eee050..2acbfa0 100644 --- a/aros/iscsi-ls.c +++ b/aros/iscsi-ls.c @@ -183,17 +183,12 @@ void list_luns(struct client_state *clnt, const char *target, const char *portal } iscsi_set_session_type(iscsi, ISCSI_SESSION_NORMAL); iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); - if (iscsi_connect_sync(iscsi, portal) != 0) { + + if (iscsi_full_connect_sync(iscsi, portal, -1) != 0) { printf("iscsi_connect failed. %s\n", iscsi_get_error(iscsi)); exit(10); } - if (iscsi_login_sync(iscsi) != 0) { - fprintf(stderr, "login failed :%s\n", iscsi_get_error(iscsi)); - exit(10); - } - - /* get initial reportluns data, all targets can report 16 bytes but some * fail if we ask for too much. */ diff --git a/lib/connect.c b/lib/connect.c index 837e4c9..617710f 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -130,10 +130,14 @@ iscsi_login_cb(struct iscsi_context *iscsi, int status, void *command_data _U_, return; } - if (iscsi_testunitready_task(iscsi, ct->lun, - iscsi_testunitready_cb, ct) == NULL) { - iscsi_set_error(iscsi, "iscsi_testunitready_async failed."); - ct->cb(iscsi, SCSI_STATUS_ERROR, NULL, ct->private_data); + if (ct->lun != -1) { + if (iscsi_testunitready_task(iscsi, ct->lun, + iscsi_testunitready_cb, ct) == NULL) { + iscsi_set_error(iscsi, "iscsi_testunitready_async failed."); + ct->cb(iscsi, SCSI_STATUS_ERROR, NULL, ct->private_data); + } + } else { + ct->cb(iscsi, SCSI_STATUS_GOOD, NULL, ct->private_data); } } diff --git a/utils/iscsi-ls.c b/utils/iscsi-ls.c index 0cf93ff..e4bd93e 100644 --- a/utils/iscsi-ls.c +++ b/utils/iscsi-ls.c @@ -180,17 +180,12 @@ void list_luns(struct client_state *clnt, const char *target, const char *portal } iscsi_set_session_type(iscsi, ISCSI_SESSION_NORMAL); iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); - if (iscsi_connect_sync(iscsi, portal) != 0) { + + if (iscsi_full_connect_sync(iscsi, portal, -1) != 0) { printf("iscsi_connect failed. %s\n", iscsi_get_error(iscsi)); exit(10); } - if (iscsi_login_sync(iscsi) != 0) { - fprintf(stderr, "login failed :%s\n", iscsi_get_error(iscsi)); - exit(10); - } - - /* get initial reportluns data, all targets can report 16 bytes but some * fail if we ask for too much. */