From 900ce145adb34dafe1668f86d32d86666bf169dd Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Thu, 18 Sep 2014 12:11:50 -0700 Subject: [PATCH 1/2] libiscsi.def: add missing scsi_cdb_compareandwrite and scs_malloc symbols Signed-off-by: Ronnie Sahlberg --- lib/libiscsi.def | 2 ++ lib/libiscsi.syms | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/libiscsi.def b/lib/libiscsi.def index 5695b94..60da14a 100644 --- a/lib/libiscsi.def +++ b/lib/libiscsi.def @@ -156,6 +156,7 @@ iscsi_writesame16_sync iscsi_writesame16_task scsi_association_to_str scsi_cdb_inquiry +scsi_cdb_compareandwrite scsi_cdb_get_lba_status scsi_cdb_modeselect6 scsi_cdb_modeselect10 @@ -209,6 +210,7 @@ scsi_get_uint16 scsi_get_uint32 scsi_get_uint64 scsi_inquiry_pagecode_to_str +scsi_malloc scsi_modesense_dataout_marshall scsi_modesense_get_page scsi_protocol_identifier_to_str diff --git a/lib/libiscsi.syms b/lib/libiscsi.syms index 685a168..533cb71 100644 --- a/lib/libiscsi.syms +++ b/lib/libiscsi.syms @@ -153,6 +153,7 @@ iscsi_writesame10_task iscsi_writesame16_sync iscsi_writesame16_task scsi_association_to_str +scsi_cdb_compareandwrite scsi_cdb_inquiry scsi_cdb_get_lba_status scsi_cdb_modeselect6 @@ -207,6 +208,7 @@ scsi_get_uint16 scsi_get_uint32 scsi_get_uint64 scsi_inquiry_pagecode_to_str +scsi_malloc scsi_modesense_dataout_marshall scsi_modesense_get_page scsi_protocol_identifier_to_str From f6d57ef3b0f03d1d85dd4ccaa4e660eb86f7ffc8 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Tue, 23 Sep 2014 17:23:27 -0700 Subject: [PATCH 2/2] connect.c: remove UA whitelist and just consume up to 10 UAs before failing Lets not use a whitelist of UnitAttentions that we consume during the connect phase. Instead we can just loop and fail after the 10th. If there are more than 10 UAs then we have a problem, otherwise just consume them all, forget them and then pass control back to the caller. Signed-off-by: Ronnie Sahlberg --- lib/connect.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/connect.c b/lib/connect.c index 94835fa..1c681ef 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -34,6 +34,7 @@ struct connect_task { iscsi_command_cb cb; void *private_data; int lun; + int num_uas; }; static void @@ -48,14 +49,24 @@ iscsi_testunitready_cb(struct iscsi_context *iscsi, int status, struct scsi_task *task = command_data; if (status != 0) { - if (task->sense.key == SCSI_SENSE_UNIT_ATTENTION - && (task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET || - task->sense.ascq == SCSI_SENSE_ASCQ_POWER_ON_OCCURED || - task->sense.ascq == SCSI_SENSE_ASCQ_NEXUS_LOSS)) { + if (task->sense.key == SCSI_SENSE_UNIT_ATTENTION) { /* This is just the normal unitattention/busreset * you always get just after a fresh login. Try - * again. + * again. Instead of enumerating all of them we + * assume that there will be at most 10 or else + * there is something broken. */ + ct->num_uas++; + if (ct->num_uas > 10) { + iscsi_set_error(iscsi, "iscsi_testunitready " + "Too many UnitAttentions " + "during login."); + ct->cb(iscsi, SCSI_STATUS_ERROR, NULL, + ct->private_data); + iscsi_free(iscsi, ct); + scsi_free_scsi_task(task); + return; + } if (iscsi_testunitready_task(iscsi, ct->lun, iscsi_testunitready_cb, ct) == NULL) { @@ -166,6 +177,7 @@ iscsi_full_connect_async(struct iscsi_context *iscsi, const char *portal, } ct->cb = cb; ct->lun = lun; + ct->num_uas = 0; ct->private_data = private_data; if (iscsi_connect_async(iscsi, portal, iscsi_connect_cb, ct) != 0) { iscsi_free(iscsi, ct);